Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modifiers key get stuck (alt key generally) #13

Closed
totaam opened this issue Aug 18, 2011 · 33 comments
Closed

modifiers key get stuck (alt key generally) #13

totaam opened this issue Aug 18, 2011 · 33 comments

Comments

@totaam
Copy link
Collaborator

totaam commented Aug 18, 2011

Issue migrated from trac ticket # 13

component: client | priority: minor | resolution: fixed

2011-08-18 13:36:23: antoine created the issue


  • Improve guessing/detection: code had already been improved, we probably could do better rather than just trying keys until we find one!
  • assuming we have to keep guessing, at least cache the results
@totaam
Copy link
Collaborator Author

totaam commented Aug 18, 2011

2011-08-18 17:25:50: antoine commented


To those who are experiencing this, can you please post details:

  • svn/version
  • which distro version for both client and server
  • keyboard layout / input method
  • output from setxkbmap -query and setxkbmap -print
  • anything else that might be relevant
    Thanks

@totaam
Copy link
Collaborator Author

totaam commented Aug 21, 2011

2011-08-21 17:03:32: lindi commented


  • SVN r135
  • debian squeeze (stable) on amd64
  • finnish keyboard
  • sid setxkbmap -query
rules:      evdev
model:      pc105
layout:     fi,latam
variant:    ,
options:    grp:alts_toggle
  • setxkbmap -print
xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwerty)"	};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+fi+latam:2+inet(evdev)+level3(ralt_switch_for_alts_toggle):1+level3(ralt_switch_for_alts_toggle):2+group(alts_toggle)"	};
	xkb_geometry  { include "pc(pc105)"	};
};

Steps to reproduce:

  1. xpra start --no-daemon --start-child gnome-terminal --exit-with-children :9 -d all > xpra.server.txt 2>&1
  2. xpra -d all attach :9 > xpra.client.txt 2>&1
  3. wait for gnome-terminal to appear, move mouse over it
  4. type a, b, c, d, e, f
  5. hit alt-tab to switch to some other window
  6. hit alt-tab again to switch back to gnome-terminal
  7. type f

Expected results:
4) & 7) gnome-terminal reads "abcdeff"

Actual results:
4 & 7) gnome-terminal reads "abcdef" and the File menu is open (since alt+F opens it)

More info:

  1. xpra.server.txt and xpra.client.txt are attached.

@totaam
Copy link
Collaborator Author

totaam commented Aug 21, 2011

2011-08-21 17:03:50: lindi uploaded file xpra.server.txt.gz (65.4 KiB)

@totaam
Copy link
Collaborator Author

totaam commented Aug 21, 2011

2011-08-21 17:03:59: lindi uploaded file xpra.client.txt.gz (36.4 KiB)

@totaam
Copy link
Collaborator Author

totaam commented Aug 21, 2011

2011-08-21 17:06:51: lindi commented


Oh and yes, I'm using gnome.

Also, keys getting stuck cause a lot of weird effects. For example starting xpra can take minutes. Apparently this is because of xmodmap:

$ xpra start --no-daemon --use-display :7
found /home/lindi/xpra-install/amd64/v0.0.7.22-60-ga4aabe0/
Xlib:  extension "RANDR" missing on display ":7.0".
Xlib:  extension "RANDR" missing on display ":7.0".
Xlib:  extension "RANDR" missing on display ":7.0".
Missing window or missing property or wrong property type WM_TRANSIENT_FOR (window)
Missing window or missing property or wrong property type _NET_WM_STRUT_PARTIAL (strut-partial)
Missing window or missing property or wrong property type _NET_WM_STRUT (strut)
Missing window or missing property or wrong property type _NET_WM_STRUT_PARTIAL (strut-partial)
Missing window or missing property or wrong property type _NET_WM_STRUT (strut)
xmodmap:  please release the following keys within 2 seconds:
    Control_L (keysym 0xffe3, keycode 37)
    d (keysym 0x64, keycode 40)
    KP_Up (keysym 0xff97, keycode 80)
xmodmap:  please release the following keys within 4 seconds:
    Control_L (keysym 0xffe3, keycode 37)
    d (keysym 0x64, keycode 40)
    KP_Up (keysym 0xff97, keycode 80)
xmodmap:  please release the following keys within 8 seconds:
    Control_L (keysym 0xffe3, keycode 37)
    d (keysym 0x64, keycode 40)
    KP_Up (keysym 0xff97, keycode 80)
xmodmap:  please release the following keys within 16 seconds:
    Control_L (keysym 0xffe3, keycode 37)
    d (keysym 0x64, keycode 40)
    KP_Up (keysym 0xff97, keycode 80)
xmodmap:  please release the following keys within 32 seconds:
    Control_L (keysym 0xffe3, keycode 37)
    d (keysym 0x64, keycode 40)
    KP_Up (keysym 0xff97, keycode 80)
xmodmap:  unable to set modifier mapping, keyboard problem
Randr not supported: X server does not support required extension Randr
randr enabled: False

xpra is ready.

@totaam
Copy link
Collaborator Author

totaam commented Aug 24, 2011

2011-08-24 22:11:49: lindi commented


$ grep key-action xpra.client.txt 
writing ['key-action', 1, 'a', True, [], 97, 'a', 38]
writing ['key-action', 1, 'a', False, [], 97, 'a', 38]
writing ['key-action', 1, 'b', True, [], 98, 'b', 56]
writing ['key-action', 1, 'b', False, [], 98, 'b', 56]
writing ['key-action', 1, 'c', True, [], 99, 'c', 54]
writing ['key-action', 1, 'c', False, [], 99, 'c', 54]
writing ['key-action', 1, 'd', True, [], 100, 'd', 40]
writing ['key-action', 1, 'd', False, [], 100, 'd', 40]
writing ['key-action', 1, 'e', True, [], 101, 'e', 26]
writing ['key-action', 1, 'e', False, [], 101, 'e', 26]
writing ['key-action', 1, 'f', True, [], 102, 'f', 41]
writing ['key-action', 1, 'f', False, [], 102, 'f', 41]
writing ['key-action', 1, 'Alt_L', True, [], 65513, '', 64]
writing ['key-action', 1, 'Tab', False, [], 65289, '', 23]
writing ['key-action', 1, 'f', True, [], 102, 'f', 41]
writing ['key-action', 1, 'f', False, [], 102, 'f', 41]

shows pretty clearly that the problem is client-side. Client never tells the server that I have released Alt.

@totaam
Copy link
Collaborator Author

totaam commented Aug 24, 2011

2011-08-24 23:31:52: lindi uploaded file release-keys-on-unfocus1.diff (2.1 KiB)

proof-of-concept to fix the bug

@totaam
Copy link
Collaborator Author

totaam commented Aug 24, 2011

2011-08-24 23:32:48: lindi commented


Since this bug really interferes with my ability to use the computer here's a proof-of-concept that works for me(tm) but definitely needs futher polishing.

@totaam
Copy link
Collaborator Author

totaam commented Aug 24, 2011

2011-08-24 23:56:38: lindi commented


Seems this is still not sufficient. At least quassel opens the menu if I press alt, release alt and then hit f. So, sending release event for alt is not enough.

@totaam
Copy link
Collaborator Author

totaam commented Aug 25, 2011

2011-08-25 00:01:13: lindi uploaded file release-keys-on-focus1.diff (2.2 KiB)

another prototype to fix the problem

@totaam
Copy link
Collaborator Author

totaam commented Aug 25, 2011

2011-08-25 00:01:43: lindi commented


It seems that if I send the release events when the window receives focus again then applications correctly handle this.

@totaam
Copy link
Collaborator Author

totaam commented Aug 25, 2011

2011-08-25 02:42:31: antoine changed status from new to accepted

@totaam
Copy link
Collaborator Author

totaam commented Aug 25, 2011

2011-08-25 02:42:31: antoine commented


The problem is not solved client-side at the moment (and I'm not sure it should be either).
The code you are looking for is _make_keymask_match in server.py
It fires whenever we get keypresses and is meant to ensure the modifiers set on the server match the ones set in the client. Not sure why it stopped working since the keymap changes but now that I have your keymap details I should be able to reproduce.

@totaam
Copy link
Collaborator Author

totaam commented Aug 25, 2011

2011-08-25 09:07:33: lindi commented


Also non-modifiers get stuck so I don't see how that code would help alone?

@totaam
Copy link
Collaborator Author

totaam commented Aug 25, 2011

2011-08-25 15:10:29: antoine commented


In fact, the _make_keymask_match must be server-side, as the client has no way of knowing what state the session is in at the moment, so this is the best place to do it.

Can you give me steps for getting non-modifier keys to get stuck? Do you get that often?

@totaam
Copy link
Collaborator Author

totaam commented Aug 25, 2011

2011-08-25 15:36:53: antoine commented


We now apply the full keymap, using 'xmodmap -pke' to grab all the raw keyval mappings from the client (if available) - done in r137

We now also clear all modifiers when a new client attaches to a session (r138), this should fix the xmodmap timeout (which I have not seen myself before).

Now, on to the alt-key gets stuck proper...

@totaam
Copy link
Collaborator Author

totaam commented Aug 25, 2011

2011-08-25 15:36:53: antoine

@totaam
Copy link
Collaborator Author

totaam commented Aug 25, 2011

2011-08-25 16:02:21: lindi commented


Yes, I often have one of the arrow keys stuck. You can imagine that this leads to rather bad behavior in different applications :-)

@totaam
Copy link
Collaborator Author

totaam commented Aug 25, 2011

2011-08-25 16:11:39: antoine commented


r139 batches the keymap updates and ensures we don't get the same xmodmap timeouts when keymap-changed fires: we also send the client's current modifiers and set them.

I just can't get the alt-tab to get stuck, despite setting my keyboard to as per comment:2

@totaam
Copy link
Collaborator Author

totaam commented Aug 25, 2011

2011-08-25 16:34:32: lindi commented


Here's how the Up arrow gets stuck with r135:

$ xpra start --no-daemon --start-child gnome-terminal --exit-with-children :9 -d all > xpra.server.txt 2>&1
$ xpra -d all attach :9 > xpra.client.txt 2>&1
# hold the up arrow down
#  notice how the shell is going through all your history entries
# hit alt-tab
# hit alt-tab again
$ grep -E "(key-action|focus)" xpra.client.txt
writing ['focus', 1]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Up', True, [], 65362, '', 111]
writing ['key-action', 1, 'Alt_L', True, [], 65513, '', 64]
writing ['key-action', 1, 'Up', True, ['meta'], 65362, '', 111]
writing ['key-action', 1, 'Up', True, ['meta'], 65362, '', 111]
writing ['focus', 0]
writing ['focus', 1]
writing ['key-action', 1, 'Alt_L', True, [], 65513, '', 64]
writing ['focus', 0]

The client never tells the server that I released the up arrow!

@totaam
Copy link
Collaborator Author

totaam commented Aug 25, 2011

2011-08-25 18:38:02: antoine commented


r142 ensures that we clear the keys that are currently pressed when we lose focus, we also send the list of modifiers when we gain focus so we can set them correctly again if any are set.
This should fix the problem with "arrow keys get stuck", but probably not "alt gets stuck"...
Please confirm if this is an improvement for you.

@totaam
Copy link
Collaborator Author

totaam commented Aug 31, 2011

2011-08-31 19:15:30: antoine uploaded file squeeze-finnish-keyboard-test.png (67.0 KiB)

testing the alt-tab issue on Debian Squeeze (screenshot)
squeeze-finnish-keyboard-test.png

@totaam
Copy link
Collaborator Author

totaam commented Aug 31, 2011

2011-08-31 19:17:18: antoine commented


I've just tested on r142 on a fresh install of Debian Squeeze, as you can see on the screenshot the keyboard is set to finnish. I've tried and tried again to reproduce the bug and I just can't do it! :(

Do I need to launch another VM with Debian Sid on it?

@totaam
Copy link
Collaborator Author

totaam commented Sep 7, 2011

2011-09-07 10:33:31: antoine commented


Another commit related to stuck keys: clear keys when client disconnects and ensure we don't re-set them by ignoring any packets arriving in the new "closing" state.

@totaam
Copy link
Collaborator Author

totaam commented Sep 7, 2011

2011-09-07 10:53:15: antoine commented


Finally, this is for the very unusual case where the server is control-Ced from within the client (via screen) and we end up with the control key stuck:
r159 always clears the modifiers on startup so users can re-attach to an existing display (with -use-display=) and not have xmodmap timeouts.

@totaam
Copy link
Collaborator Author

totaam commented Sep 23, 2011

2011-09-23 15:49:41: antoine changed priority from major to minor

@totaam
Copy link
Collaborator Author

totaam commented Sep 23, 2011

2011-09-23 15:49:41: antoine

@totaam
Copy link
Collaborator Author

totaam commented Sep 23, 2011

2011-09-23 15:49:41: antoine commented


r187 improves this further
Although I have seen the 'C' key getting stuck when I ^C the server from within xpra via screen, this is a unusual scenario and should no longer cause timeouts when re-starting the server.
Lowering priority, please raise again if any of this is wrong.

@totaam
Copy link
Collaborator Author

totaam commented Sep 23, 2011

2011-09-23 15:49:41: totaam

@totaam
Copy link
Collaborator Author

totaam commented Dec 8, 2011

2011-12-08 13:44:56: totaam changed status from accepted to closed

@totaam
Copy link
Collaborator Author

totaam commented Dec 8, 2011

2011-12-08 13:44:56: totaam changed resolution from ** to fixed

@totaam
Copy link
Collaborator Author

totaam commented Dec 8, 2011

2011-12-08 13:44:56: totaam commented


Not heard anything for 3 months, closing.

@totaam totaam closed this as completed Dec 8, 2011
@totaam
Copy link
Collaborator Author

totaam commented Feb 20, 2012

2012-02-20 20:13:14: totaam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant