Xpra: Ticket #51: new window keyboard focus problem

This was originally recorded as #150 on winswitch bug tracker (see there for details), so I forgot about it.. This bug is getting annoying, let's try to fix it.

Sun, 04 Dec 2011 18:37:16 GMT - Antoine Martin: owner, status changed; cc set

Tue, 06 Dec 2011 19:58:20 GMT - Antoine Martin:

Can reproduce it easily on win32 (and probably osx) by first connecting then starting a new terminal. On linux, the new window correctly gets focus, on win32 it does not...

Wed, 07 Dec 2011 15:56:45 GMT - Antoine Martin:

Found the problem, on win32 and osx (more often than on linux - but still not that often, even harder to trigger with the added delays introduced by debugging..) we get the focus update before the window is mapped, and the call to XSetInputFocus fails with BadMatch... Sequence of the network packets in this case:

got ['focus', '15', '[]']
got ['map-window', '15', '114', '175', '744', '456']

Wed, 07 Dec 2011 18:26:06 GMT - Antoine Martin:

This particular problem is fixed in r357 by waiting for the window to get mapped before firing the focus_change method. Problem is that there is still an issue when a second window pops up:

For some reason, gtk sets has-toplevel-focus to False for this one, so the focus never happens... and we don't seem to get notified either!?

Thu, 08 Dec 2011 15:01:56 GMT - Antoine Martin:

There are more focus problems lurking:

What I think is happening: the 'd' key is released when no xpra window has the focus (the focus should be on the root window in the server) and it is only when we focus 1 again that the keys get delivered.

Thu, 08 Dec 2011 15:27:26 GMT - Rainwoodman:

Apparently keyevents are grabbed on the client per window, but delivered to the server globally.

Thu, 08 Dec 2011 17:21:27 GMT - Antoine Martin: attachment set

patch to make it easier to debug focus problems by printing all focus debug only

Thu, 08 Dec 2011 17:40:32 GMT - Antoine Martin: status changed; resolution set

r369 ensures that we correctly unfocus windows when they are unmapped or destroyed. This fixes the bug described in comment:5.

This is all done client side and I think we probably ought to detect when the "world_window" gets the focus (server-side) and do something similar there. (clear keys, etc) But this will do for now...

Mon, 20 Feb 2012 19:30:20 GMT - Antoine Martin: milestone changed; version set

Sat, 23 Jan 2021 04:44:12 GMT - migration script:

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