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.
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...
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']
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:
1323281101.14 update_focus(1,True) _focused=None 1323281101.14 update_focus(1,True) _focused=1 1323281102.17 update_focus(1,False) _focused=1 1323281103.05 update_focus(2,False) _focused=None
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!?
There are more focus problems lurking:
^D
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.
Apparently keyevents are grabbed on the client per window, but delivered to the server globally.
patch to make it easier to debug focus problems by printing all focus debug only
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...
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/51