unclechu / xlib-keys-hack

Keyboard behavior customization utility
GNU General Public License v3.0
9 stars 1 forks source link

After Alt (as Alternative Mode) + Shift + CapsLock (as LCtrl) + "+" - sometimes Ctrl kept pressed (not released properly) #25

Closed unclechu closed 5 years ago

unclechu commented 5 years ago

I found I way to reproduce it (just release Alt key before CapsLock/Enter).

It seems it's can be reproduced only after alternative mode is turned on and additional control (Caps Lock/Enter key) was pressed with some another key. Here's two ways to reproduce it:

  1. Hold Alt (alternative mode will be turned on);
  2. Hold Caps Lock;
  3. Press and release some letter key (J for example), Caps Lock interpreted as LCtrl key now;
  4. Release Alt (alternative mode won't be turned off, until you release Caps Lock);
  5. Release Caps Lock;
  6. Releasing event of LCtrl isn't triggered, LCtrl kept pressed for the system (just pressing and releasing of Caps Lock fixes it).

  1. Double press and hold Super key;
  2. Press and release a letter key (J for example), alternative mode will be turned on;
  3. Hold Caps Lock;
  4. Press and release a letter key again (J for example), if you skip this step, the bug won't reproduce, Caps Lock now interpreted as LCtrl;
  5. Release Super (alternative mode will be turned off);
  6. Release Caps Lock;
  7. Releasing event of LCtrl isn't triggered, LCtrl kept pressed for the system (just pressing and releasing of Caps Lock fixes it).

It doesn't matter which (left or right) Alt key or Super key you use, and it doesn't matter which additional control you use (Caps Lock or Enter), it will reproduce in all cases.

unclechu commented 5 years ago

I did some investigation, and it looks like releasing of additional control for some reason doesn't match any condition in key handling flow and does down to otherwise section which is just triggered alone key (which in case of Caps Lock is Escape key), and only after you press and release Caps Lock it somehow remembers it was interpreted as LCtrl earlier and triggers release of LCtrl.

Here is piece of --verbose log for both reproduce ways:

With held Alt key (I pressed LShift twice after releasing everything on purpose, to leave a mark in log):

...
CapsLockKey pressed with combo, triggering ControlLeftKey (X key code: 37)...
Triggering pressing of alternative ArrowDownKey (X key code: 116) by KKey...
KKey is released
Triggering releasing of alternative ArrowDownKey (X key code: 116) by KKey...
AltLeftKey is released
AltLeftKey is released but some alternative keys are still pressed, will turn alternative mode off after all those keys being released.
CapsLockKey is released
All alternative keys have been released after delayed turning alternative mode off, now turning alternative mode off...
Triggering releasing of CapsLockKey as EscapeKey (X key code: 9)...
Setting xmobar Alternative Mode indicator state Off...
ShiftLeftKey is pressed
Triggering pressing of ShiftLeftKey (X key code: 50)...
ShiftLeftKey is released
Triggering releasing of ShiftLeftKey (X key code: 50)...
ShiftLeftKey is pressed
Triggering pressing of ShiftLeftKey (X key code: 50)...
ShiftLeftKey is released
Triggering releasing of ShiftLeftKey (X key code: 50)...
CapsLockKey is pressed
CapsLockKey is released
CapsLockKey released after pressed with combos, it means it was interpreted as ControlLeftKey
Triggering releasing of ControlLeftKey (X key code: 37)...
...

It also strange (but not part of the issue since it doesn't happening with double pressing of Super key but issue is reproduced the same way) that it says "some alternative keys are still pressed" while only Caps Lock is pressed.


With double pressing of Super key:

...
Triggering pressing of alternative ArrowDownKey (X key code: 116) by KKey...
KKey is released
Triggering releasing of alternative ArrowDownKey (X key code: 116) by KKey...
CapsLockKey is pressed
CapsLockKey was pressed with some another keys that hadn't be released in time, these another keys WONT be taken as combo with additional control
Storing keys was pressed before CapsLockKey: [SuperLeftKey]...
KKey is pressed
CapsLockKey pressed with combo, triggering ControlLeftKey (X key code: 37)...
Triggering pressing of alternative ArrowDownKey (X key code: 116) by KKey...
KKey is released
Triggering releasing of alternative ArrowDownKey (X key code: 116) by KKey...
SuperLeftKey is released
SuperLeftKey released after some alternative keys had triggered in context of double press of Super key feature, triggering off events for unreleased keys: [CapsLockKey], turning alternative mode off and resetting state of this feature...
Triggering releasing of CapsLockKey (as EscapeKey) (X key code: 9)...
Setting xmobar Alternative Mode indicator state Off...
CapsLockKey is released
ShiftLeftKey is pressed
Triggering pressing of ShiftLeftKey (X key code: 50)...
ShiftLeftKey is released
Triggering releasing of ShiftLeftKey (X key code: 50)...
ShiftLeftKey is pressed
Triggering pressing of ShiftLeftKey (X key code: 50)...
ShiftLeftKey is released
Triggering releasing of ShiftLeftKey (X key code: 50)...
CapsLockKey is pressed
CapsLockKey is released
CapsLockKey released after pressed with combos, it means it was interpreted as ControlLeftKey
Triggering releasing of ControlLeftKey (X key code: 37)...
...
unclechu commented 5 years ago

Fixed that "some alternative keys are still pressed" unrelated issue by 0348b78175f5d72f7366130ffd162f4c7dd3a00a and it accidentally fixed this issue for held Alt for alternative mode (but not for double pressing Super key).

unclechu commented 5 years ago

Fixed by 65487cced7469ef5fe752f65a01701fcf4ef4d51