xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Opened 10 years ago

Closed 10 years ago

Last modified 8 months ago

#13 closed defect (fixed)

modifiers key get stuck (alt key generally)

Reported by: Antoine Martin Owned by: Antoine Martin
Priority: minor Milestone: 0.0.7.x
Component: client Version: 0.0.7.28
Keywords: Cc:

Description

  • 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

Attachments (5)

xpra.server.txt.gz (65.4 KB) - added by Timo Juhani Lindfors 10 years ago.
xpra.client.txt.gz (36.4 KB) - added by Timo Juhani Lindfors 10 years ago.
release-keys-on-unfocus1.diff (2.1 KB) - added by Timo Juhani Lindfors 10 years ago.
proof-of-concept to fix the bug
release-keys-on-focus1.diff (2.2 KB) - added by Timo Juhani Lindfors 10 years ago.
another prototype to fix the problem
squeeze-finnish-keyboard-test.png (67.0 KB) - added by Antoine Martin 10 years ago.
testing the alt-tab issue on Debian Squeeze (screenshot)

Download all attachments as: .zip

Change History (27)

comment:1 Changed 10 years ago by Antoine Martin

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

comment:2 Changed 10 years ago by Timo Juhani Lindfors

  • 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.

Changed 10 years ago by Timo Juhani Lindfors

Attachment: xpra.server.txt.gz added

Changed 10 years ago by Timo Juhani Lindfors

Attachment: xpra.client.txt.gz added

comment:3 Changed 10 years ago by Timo Juhani Lindfors

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.

comment:4 Changed 10 years ago by Timo Juhani Lindfors

$ 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.

Changed 10 years ago by Timo Juhani Lindfors

proof-of-concept to fix the bug

comment:5 Changed 10 years ago by Timo Juhani Lindfors

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.

comment:6 Changed 10 years ago by Timo Juhani Lindfors

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.

Changed 10 years ago by Timo Juhani Lindfors

Attachment: release-keys-on-focus1.diff added

another prototype to fix the problem

comment:7 Changed 10 years ago by Timo Juhani Lindfors

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

comment:8 Changed 10 years ago by Antoine Martin

Status: newaccepted

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.

comment:9 Changed 10 years ago by Timo Juhani Lindfors

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

comment:10 Changed 10 years ago by Antoine Martin

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?

comment:11 Changed 10 years ago by Antoine Martin

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...

Last edited 10 years ago by Antoine Martin (previous) (diff)

comment:12 Changed 10 years ago by Timo Juhani Lindfors

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

comment:13 Changed 10 years ago by Antoine Martin

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

comment:14 Changed 10 years ago by Timo Juhani Lindfors

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!

comment:15 Changed 10 years ago by Antoine Martin

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.

Changed 10 years ago by Antoine Martin

testing the alt-tab issue on Debian Squeeze (screenshot)

comment:16 Changed 10 years ago by Antoine Martin

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?

comment:17 Changed 10 years ago by Antoine Martin

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.

comment:18 Changed 10 years ago by Antoine Martin

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.

comment:19 Changed 10 years ago by Antoine Martin

Milestone: currentfuture
Priority: majorminor

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.

Last edited 10 years ago by Antoine Martin (previous) (diff)

comment:20 Changed 10 years ago by Antoine Martin

Resolution: fixed
Status: acceptedclosed

Not heard anything for 3 months, closing.

comment:21 Changed 10 years ago by Antoine Martin

Milestone: future0.0.7.x
Version: 0.0.7.28

comment:22 Changed 8 months ago by migration script

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/13

Note: See TracTickets for help on using tickets.