• altwin:left_meta_win - emacs super and meta on same key

    From Lionel Élie Mamane@3:633/10 to All on Thursday, May 21, 2026 12:30:01
    Hi,

    I'm using GNU Emacs from Debian package emacs-lucid version 1:30.1+1-6
    on xorg version 1:7.7+24+deb13u1 with xkb-data version 2.42-1.

    My keyboard is a Microsoft branded one, with menu, left and right
    "Microsoft Windows logo" keys and emoji key, along with a top bar of "multimedia" keys that are physically distinct from the F1-F12 keys.

    My /etc/default/keyboard contains

    XKBMODEL="microsoft4000"
    XKBLAYOUT="us"
    XKBVARIANT="euro"
    XKBOPTIONS="altwin:left_meta_win,compose:menu"
    BACKSPACE="guess"

    I've been using altwin:left_meta_win since "forever", certainly since
    I've had keyboard with "Microsoft Windows logo" keys, which might be
    as long as I've been using GNU/Linux and X11, a few decades ago. Its
    effect is to put the meta key on the left "Microsoft Windows logo"
    key, so that I have separate Meta key (useful in Emacs) and Alt key
    (that I use mainly for window manager bindings).

    But now Emacs has started to treat the left Microsoft Windows logo key
    as meta _and_ super at the same time, so that any binding in emacs
    that uses Meta is unusable, because emacs will say I pressed M-s-FOO
    when I pressed left Microsoft Windows logo key + FOO, which used to be
    just M-FOO. For example, left Microsoft Windows logo key + d, instead
    of being understood as M-d (bound to kill-word) is being understood as
    M-s-d and emacs says "M-s-d is undefined".

    I don't know if the change comes from an upgrade of emacs or of
    xkb/xorg, as I rarely close my emacs (daemon) or my X11 session (I
    rebooted for the latest high impact Linux security holes, my uptime
    before that was > 300 days).

    When I press and depress the left Microsoft Windows logo key with xev
    having focus, the events are:

    KeyPress event, serial 37, synthetic NO, window 0x5c00001,
    root 0x3cb, subw 0x0, time 60567700, (116,80), root:(1826,1536),
    state 0x10, keycode 133 (keysym 0xffe7, Meta_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

    KeyRelease event, serial 37, synthetic NO, window 0x5c00001,
    root 0x3cb, subw 0x0, time 60567892, (116,80), root:(1826,1536),
    state 0x50, keycode 133 (keysym 0xffe7, Meta_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

    When I press left Microsoft Windows logo key + d with xev having
    focus, the events are:

    KeyPress event, serial 37, synthetic NO, window 0x5c00001,
    root 0x3cb, subw 0x0, time 60643492, (89,77), root:(1786,1513),
    state 0x10, keycode 133 (keysym 0xffe7, Meta_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

    KeyPress event, serial 37, synthetic NO, window 0x5c00001,
    root 0x3cb, subw 0x0, time 60645396, (89,77), root:(1786,1513),
    state 0x50, keycode 40 (keysym 0x64, d), same_screen YES,
    XLookupString gives 1 bytes: (64) "d"
    XmbLookupString gives 1 bytes: (64) "d"
    XFilterEvent returns: False

    KeyRelease event, serial 37, synthetic NO, window 0x5c00001,
    root 0x3cb, subw 0x0, time 60645580, (89,77), root:(1786,1513),
    state 0x50, keycode 40 (keysym 0x64, d), same_screen YES,
    XLookupString gives 1 bytes: (64) "d"
    XFilterEvent returns: False

    KeyRelease event, serial 37, synthetic NO, window 0x5c00001,
    root 0x3cb, subw 0x0, time 60645756, (89,77), root:(1786,1513),
    state 0x50, keycode 133 (keysym 0xffe7, Meta_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

    showing that state bit 0x40 gets set on the "d" press.

    "xmodmodmap" output:

    shift Shift_L (0x32), Shift_R (0x3e)
    lock Caps_Lock (0x42)
    control Control_L (0x25), Control_R (0x69)
    mod1 Alt_L (0x40), Alt_L (0xcc)
    mod2 Num_Lock (0x4d)
    mod3 ISO_Level5_Shift (0xcb)
    mod4 Meta_L (0x85), Super_R (0x86), Meta_L (0xcd), Super_L (0xce), Hyper_L (0xcf)
    mod5 ISO_Level3_Shift (0x5c)

    I tried "xmodmap -e 'remove mod4 = Super_R Super_L Hyper_L'" to get

    mod4 Meta_L (0x85), Meta_L (0xcd)

    + start a new emacs, but it did not change anything.

    I would really really appreciate any hint on how to fix this.

    Thanks!

    --
    Lionel

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lionel lie Mamane@3:633/10 to All on Thursday, May 21, 2026 13:00:01
    On Thu, May 21, 2026 at 12:19:01PM +0200, Lionel ?lie Mamane wrote:
    My /etc/default/keyboard contains

    XKBMODEL="microsoft4000"
    XKBLAYOUT="us"
    XKBVARIANT="euro"
    XKBOPTIONS="altwin:left_meta_win,compose:menu"
    BACKSPACE="guess"

    But now Emacs has started to treat the left Microsoft Windows logo
    key as meta _and_ super at the same time, so that any binding in
    emacs that uses Meta is unusable, because emacs will say I pressed
    M-s-FOO when I pressed left Microsoft Windows logo key + FOO, which
    used to be just M-FOO.

    "xmodmodmap" output:

    shift Shift_L (0x32), Shift_R (0x3e)
    lock Caps_Lock (0x42)
    control Control_L (0x25), Control_R (0x69)
    mod1 Alt_L (0x40), Alt_L (0xcc)
    mod2 Num_Lock (0x4d)
    mod3 ISO_Level5_Shift (0xcb)
    mod4 Meta_L (0x85), Super_R (0x86), Meta_L (0xcd), Super_L (0xce), Hyper_L (0xcf)
    mod5 ISO_Level3_Shift (0x5c)

    I tried "xmodmap -e 'remove mod4 = Super_R Super_L Hyper_L'" to get

    mod4 Meta_L (0x85), Meta_L (0xcd)

    + start a new emacs, but it did not change anything.


    I've had more success with

    $ xmodmap -e 'remove mod4 = Meta_L'
    $ xmodmap -e 'add mod1 = Meta_L'

    which gives

    mod1 Alt_L (0x40), Meta_L (0x85), Alt_L (0xcc), Meta_L (0xcd)
    mod4 Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)

    (where from did Alt_L suddenly get into mod1 again???)
    but now emacs treat both Alt_L and Meta_L (Microsoft Windows logo key)
    as Meta; I tried "xmodmap -e 'remove mod1 = Alt_L'" which gives

    mod1 Meta_L (0x85), Meta_L (0xcd)
    mod4 Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)

    but emacs still wrongly treats the Alt_L key as Meta.

    But this in turns breaks using the Alt key for the window manager, the
    Window manager now uses Meta_L (Microsoft Windows logo key) for Alt

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Stefan Monnier@3:633/10 to All on Thursday, May 21, 2026 22:30:01
    Hi Lionel,

    "xmodmodmap" output:

    shift Shift_L (0x32), Shift_R (0x3e)
    lock Caps_Lock (0x42)
    control Control_L (0x25), Control_R (0x69)
    mod1 Alt_L (0x40), Alt_L (0xcc)
    mod2 Num_Lock (0x4d)
    mod3 ISO_Level5_Shift (0xcb)
    mod4 Meta_L (0x85), Super_R (0x86), Meta_L (0xcd), Super_L (0xce), Hyper_L (0xcf)
    mod5 ISO_Level3_Shift (0x5c)

    Given my vague knowledge of how Emacs recognized modifiers, the above
    weird `mod4` setup would indeed sound like a likely culprit (it doesn't
    sound like a "sane" setup to me), tho I can't see why you'd get
    `M-s-FOO` rather than `H-M-s-FOO`.

    I tried "xmodmap -e 'remove mod4 = Super_R Super_L Hyper_L'" to get

    mod4 Meta_L (0x85), Meta_L (0xcd)

    That's also what I'd have done.

    + start a new Emacs, but it did not change anything.

    Hmm... yeah, that's not what I would have expected either.
    It's possible that Emacs changed how it recognizes which key is which
    modifier, but even if it doesn't the behavior you describe (after the
    `xmodmap` made the setup sane) sounds like a bug, so I'd `M-x report-emacs-bug`.


    === Stefan

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Max Nikulin@3:633/10 to All on Sunday, May 24, 2026 06:20:01
    On 21/05/2026 5:19 pm, Lionel lie Mamane wrote:

    My /etc/default/keyboard contains

    I recommend to check

    setxkbmap -print

    output to get actual state of keyboard configuration.

    that uses Meta is unusable, because emacs will say I pressed M-s-FOO
    when I pressed left Microsoft Windows logo key + FOO, which used to be
    just M-FOO.

    Just to be sure, I would try "showkey" from a VT. I have seen that at
    least some additional keys may send modifiers even when the
    corresponding key is not pressed.

    "xmodmodmap" output:

    Just a notice: you may need to run xmodmap again after disconnecting and reconnecting a keyboard. Native XKB tools should not suffer from this issue.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)