Xpra: Ticket #668: Cant press multiple keys at once?

I was just trying to play a racing game remotely. It uses the Up arrow key to accelerate and the LEFT and RIGHT arrow key to turn the car. When i push the UP arrow key to accelerate and then use LEFT or RIGHT while keeping UP pushed, the car slows down.

A quick tool i found to test out is xkeycaps, it shows a keyboard and lights up the keys pressed, you can check by yourself that pushing two keys at once wont work with xpra.

Thu, 04 Sep 2014 07:28:42 GMT - kokoko3k: version changed; cc, keywords set

Forgot to set the version, sorry. I'm using 0.14.3 by winswitch.

Thu, 04 Sep 2014 09:39:55 GMT - Antoine Martin: owner, priority, status changed; milestone set


Thu, 04 Sep 2014 12:33:27 GMT - Antoine Martin:

Here's what I'm seeing with -d keyboard:


So we stop getting the repeat key event for Up as soon as we get the Left key press.

And so the server is expecting the repeat event for all the pressed keys, doesn't receive it and so it unpresses the key...

What makes this much more difficult to fix is that it behaves differently on win32 (haven't tried OSX yet): we're still missing the other key, but we get both a key up and a key down on win32...

Thu, 04 Sep 2014 12:58:43 GMT - Antoine Martin:

This is the minimal fix:

--- src/xpra/server/server_base.py	(revision 7502)
+++ src/xpra/server/server_base.py	(working copy)
@@ -1535,6 +1535,11 @@
             self.fake_key(keycode, False)
         is_mod = self.is_modifier(name, keycode)
         if pressed:
+            #cancel all repeat timers:
+            for timer in self.keys_repeat_timers.values():
+                self.source_remove(timer)
+            self.keys_repeat_timers = {}
             if keycode not in self.keys_pressed:
                 if not self.keyboard_sync and not is_mod:

But I'm not sure if this is what I'll merge yet.

Thu, 04 Sep 2014 13:11:52 GMT - Antoine Martin: owner, status changed

Better fix in r7512 + r7513, we may backport this to the 0.14.x branch but since this bug has been present for a very long time, let's not rush this.

@kokoko3k: does that fix things for you?

@afarr: can you confirm that we can now press multiple (non modifier) keys concurrently (xkeycaps is good for testing this), and that it doesn't break anything. In particular, I am worried that if multiple keys are pressed, one may get stuck if we somehow miss the key-release event (not sure how that would happen, but maybe alt-tabbing away or clicking away then releasing the key whilst xpra does not have keyboard focus).

Thu, 04 Sep 2014 18:27:13 GMT - kokoko3k:

It seems fixed to me, thank you very much for looking into this and for the fast fix!

However often during playing it seems that the keys are sent with a delay of 1..2 seconds, wvwn if the game stays smooth. I don't know if this issue is related to the fix.

Fri, 05 Sep 2014 00:32:58 GMT - alas:

Would you like -d keyboard logs for both?

Fri, 05 Sep 2014 02:52:19 GMT - Antoine Martin:

Replying to kokoko3k:

However often during playing it seems that the keys are sent with a delay of 1..2 seconds

That's a different issue, and one I am not seeing this time. Do you see the key events on the client with -d keyboard? If so, they should be forwarded to the server instantly (bar network latency)

Replying to afarr:

I'm not seeing any keys light up

OK, taking the ticket back, I'll test more on osx next week.

but the original two keys likewise remain lit (on windows)

This one sounded like a bug, but then I tried it without xpra and got the same behaviour.

Overall, it looks OK for backports I think.

Fri, 05 Sep 2014 02:52:29 GMT - Antoine Martin: owner, status changed

Backport of r7512 + r7513 was in r7527.

Sun, 18 Jan 2015 06:20:01 GMT - Antoine Martin: status changed; resolution set

It seems to work well enough for win32 and x11, and I don't see an easy way to coerce OSX into not acting stoopid. (not for the first time, see #708 for example)

So I am closing this ticket, feel free to re-open.

Sat, 23 Jan 2021 05:02:27 GMT - migration script:

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