Bug 106895

Summary: [regression] XGrabKeyboard() noop focus events break TigerVNC
Product: xorg Reporter: Pierre Ossman <ossman>
Component: Server/Input/CoreAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED MOVED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: dvlohp
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
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():

https://cgit.freedesktop.org/xorg/xserver/commit/?id=c67f2eac56518163981af59f5accb7c79bc00f6a

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:

https://github.com/TigerVNC/tigervnc/pull/661
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.