sminez / penrose

A library for writing an X11 tiling window manager
https://sminez.github.io/penrose/
MIT License
1.26k stars 88 forks source link

Escape key not functional #277

Closed bacchist closed 12 months ago

bacchist commented 1 year ago

Describe the bug

The escape key is not being accepted as input for use in a standard binding. My remapped caps lock which functions as a second escape key works as expected.

To Reproduce

Using a keyboard with caps remapped to escape, build and run the example minimal config. Try to exit using "M-A-Escape" with the regular escape key. Nothing happens. "M-A-Escape" using the remapped caps lock key for escape works as expected and exits.

Expected behavior

The key binding should work using the keyboard's escape key.

Screenshots

No relevant screenshots are possible, but this is the output I got from showkey (note that in each instance, I first hit the keyboard's escape key, and then the remapped caps lock):

[bacchist@topdesk ~]$ sudo showkey --scancodes
kb mode was ?UNKNOWN?
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]

press any key (program terminates 10s after last keypress)...
^[0x01 
0x81 
^[0x3a 
0xba 
[bacchist@topdesk ~]$ sudo showkey --keycodes
kb mode was ?UNKNOWN?
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]

press any key (program terminates 10s after last keypress)...
^[keycode   1 press
keycode   1 release
^[keycode  58 press
keycode  58 release
[bacchist@topdesk ~]$ sudo showkey --ascii

Press any keys - Ctrl-D will terminate this program

^[  27 0033 0x1b
^[  27 0033 0x1b

Versions & OS Details

Arch Linux with kernel 6.4.7.

Using:

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us"
        Option "XkbModel" "pc104"
        Option "XkbVariant" ","
        Option "XkbOptions" "caps:escape"
EndSection
sminez commented 1 year ago

Penrose operates on keycodes not physical keys so that implies that your remapped caps lock and physical escape keys are emitting different key codes? Could you double check that both keys definitely generate the same keycode?

Without more information for the output you've included above I'd say it looks like they're not? If that's the case then Penrose is working as intended: if they are generating the same key code then this does sound like a bug and I'd need to see some trace level logging of both your window manager startup when keys are grabbed and when you try to trigger the binding.

bacchist commented 1 year ago

I'm not exactly sure what to do to get more detail about this. Based on the showkey output there does seem to be some difference, but I'm not sure what to make of it.

bacchist commented 1 year ago

It looks like you are using xmodmap to get the keycodes. I'm new to Rust, so I'm not totally sure what's going on in that function, but I have this output from xmodmap:

$ xmodmap -pke|grep Escape
keycode   9 = Escape NoSymbol Escape
keycode  66 = Escape NoSymbol Escape
sminez commented 12 months ago

Based on the showkey output there does seem to be some difference

Penrose maps key bindings based on the key codes being emitted rather than physical keys. If the two keys you are using for escape are emitting different codes then I'd expect only one of them to be bound (which sounds like what you are seeing?)

As I said above, without log output showing the incoming key events to help identify whether or not something is being incorrectly dropped there isn't anything else I can do to help I'm afraid. I'm not able to reproduce the behaviour you are seeing. Please feel free to reopen this issue if you have the requested log output and it is indicating that Penrose is incorrectly dropping events.