1

I have changed the definition of Mod1 via xmodmap to not include ALT_R (to understand why scroll to the bottom). The current layout of the modifiers is below. Despite ALT_R not participating in the definition of mod1, recordings produced by xev show that the KeyEvent.state is set to mod1Mask (defined as 8 in /usr/include/X11/X.h) when either Alt key is pressed.

If xmodmask says that ALT_R is not mod1, why is X reporting ALT_R+f as if it was?

xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

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

The following sequence is ALT_L+f followed by ALT_R+f.

KeyPress event, serial 32, synthetic NO, window 0x1000001,
    root 0xc0, subw 0x0, time 4126632, (85,488), root:(86,489),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 32, synthetic NO, window 0x1000001,
    root 0xc0, subw 0x0, time 4126850, (85,488), root:(86,489),
    state 0x8, keycode 41 (keysym 0x66, f), same_screen YES,
    XLookupString gives 1 bytes: (66) "f"
    XmbLookupString gives 1 bytes: (66) "f"
    XFilterEvent returns: False

KeyRelease event, serial 32, synthetic NO, window 0x1000001,
    root 0xc0, subw 0x0, time 4126930, (85,488), root:(86,489),
    state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 32, synthetic NO, window 0x1000001,
    root 0xc0, subw 0x0, time 4126969, (85,488), root:(86,489),
    state 0x0, keycode 41 (keysym 0x66, f), same_screen YES,
    XLookupString gives 1 bytes: (66) "f"
    XFilterEvent returns: False

KeyPress event, serial 32, synthetic NO, window 0x1000001,
    root 0xc0, subw 0x0, time 4127907, (85,488), root:(86,489),
    state 0x0, keycode 108 (keysym 0xffea, Alt_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 32, synthetic NO, window 0x1000001,
    root 0xc0, subw 0x0, time 4128123, (85,488), root:(86,489),
    state 0x8, keycode 41 (keysym 0x66, f), same_screen YES,
    XLookupString gives 1 bytes: (66) "f"
    XmbLookupString gives 1 bytes: (66) "f"
    XFilterEvent returns: False

KeyRelease event, serial 32, synthetic NO, window 0x1000001,
    root 0xc0, subw 0x0, time 4128164, (85,488), root:(86,489),
    state 0x8, keycode 108 (keysym 0xffea, Alt_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 32, synthetic NO, window 0x1000001,
    root 0xc0, subw 0x0, time 4128203, (85,488), root:(86,489),
    state 0x0, keycode 41 (keysym 0x66, f), same_screen YES,
    XLookupString gives 1 bytes: (66) "f"
    XFilterEvent returns: False

Background:

I have an application that utilizes ALT_R+ENTER to perform a function. When using this application in Xmonad, the combination Mod1+ENTER triggers the function "swap the current window with the master window". By default, ALT_L and ALT_R are mapped to Mod1.

In my .xinitrc, before I start Xmonad, I've altered my key map with xmodmap such that ALT_R is not part of the Mod1 definition. Despite this, Xmonad still performs the window swapping behavior when entering ALT_R+ENTER. Xmonad seems to be unaware that Mod1 no longer includes ALT_R.

Here is my .xinitrc

# Java's GUI can't handle some non-reparenting window managers like
# Xmonad without being told how to behave
export _JAVA_AWT_WM_NONREPARENTING=1

# The right Alt key is useful in IntelliJ, tell Xmonad to ignore it
xmodmap ~/.Xmodmap

# Start Xmonad
xmonad

Here is the output of xmodmap after Xmonad starts is above.

I've recorded the sequence with xev and confirmed that the ENTER is never registered. Instead, several FocusIn/FocusOut events occur after the ALT_R is recorded.

KeyPress event, serial 32, synthetic NO, window 0x1200001,
    root 0xc0, subw 0x0, time 1432589, (92,374), root:(93,375),
    state 0x0, keycode 108 (keysym 0xffea, Alt_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

FocusOut event, serial 32, synthetic NO, window 0x1200001,
    mode NotifyGrab, detail NotifyAncestor

PropertyNotify event, serial 32, synthetic NO, window 0x1200001,
    atom 0x155 (WM_STATE), time 1433760, state PropertyNewValue

FocusOut event, serial 32, synthetic NO, window 0x1200001,
    mode NotifyUngrab, detail NotifyPointer

FocusIn event, serial 32, synthetic NO, window 0x1200001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 32, synthetic NO, window 0x0,
    keys:  0   0   0   0   0   0   0   0   0   0   0   0   0   16  0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

KeyRelease event, serial 32, synthetic NO, window 0x1200001,
    root 0xc0, subw 0x0, time 1434117, (92,374), root:(93,375),
    state 0x8, keycode 108 (keysym 0xffea, Alt_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False
  • so, sorry about the comments - that was a well-deserved admonition. but seriously, if these two questions aren't identical, it is very difficult to tell. just now i attempted to remove my downvote but, of course, to do so requires an edit. i could do it, or someone else could do it, but it would be best if you did. try accentuating your new/different problem rather than bulk copy/pasting swathes of text from one page to the next. you know what i mean? – mikeserv Nov 2 '15 at 2:39
  • @mikeserv I've edited the question to highlight the question I am actively asking and moved as much of the background as I could without withholding useful information into a section at the bottom. – Huckle Nov 2 '15 at 6:55
1

It seems that if Alt_R isn't assigned to any other modifier, it defaults to Mod1Mask.

Simply unbinding the right alt in my Xmodmap wasn't sufficient to get it to stop reporting state 0x8, I had to bind it to another modifier (I chose Mod3 since it was empty anyway), and then xev started reporting state 0x20.

Though it's more of a workaround than a solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.