Bug 106895 - [regression] XGrabKeyboard() noop focus events break TigerVNC
Summary: [regression] XGrabKeyboard() noop focus events break TigerVNC
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/Input/Core (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
Depends on:
Reported: 2018-06-12 07:42 UTC by Pierre Ossman
Modified: 2018-12-17 17:27 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Description Pierre Ossman 2018-06-12 07:42:46 UTC
So xserver 1.20 started sending out a few more events for XGrabKeyboard():


Unfortunately this breaks TigerVNC's vncviewer, and it isn't obvious how it should be fixed.

The issue is that TigerVNC tries to be a good citizen and release the grab when it loses focus (e.g. the user clicks another window with the ouse). However with the new commit we end up with:

1. TigerVNC grabs keyboard
2. TigerVNC recieves FocusOut
3. TigerVNC ungrabs keyboard
4. TigerVNC recieves FocusIn
5. goto 1

The obvious fix is to ignore these no-op focus events, but I cannot see a clear way to detect them.

FocusOut could be handled by calling XGetInputFocus(), even though that probably introduces a small race.

FocusIn is more difficult. It's too late to check things with XGetInputFocus(), and there is no call to see if TigerVNC already has the grab. Perhaps manually track the focus state, but that's a bit annoying and I'm concerned there might be corner cases.

I was thinking that something might be possible to do by tracking request serial numbers, but that's a bit hacky.

Some input on this would be nice. It will start breaking things for a lot of users once 1.20 becomes common.
Comment 1 Pierre Ossman 2018-06-12 14:01:47 UTC
Despite the hackishness, filtering events seems like the best approach (unless you have a better suggestion). This is the intended workaround:

Comment 2 GitLab Migration User 2018-12-17 17:27:50 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xorg/xserver/issues/587.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.