After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 596695 - [AppSwitcher] deal with the user releasing Alt before we get the grab
[AppSwitcher] deal with the user releasing Alt before we get the grab
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2009-09-29 03:37 UTC by Dan Winship
Modified: 2009-09-29 14:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[AppSwitcher] deal with the user releasing Alt before we get the grab (2.21 KB, patch)
2009-09-29 03:37 UTC, Dan Winship
committed Details | Review

Description Dan Winship 2009-09-29 03:37:36 UTC
If the user types Alt-Tab and releases Alt before we call Main.pushModal(),
then the KeyRelease event will generally be lost. (I think sometimes it
gets delivered to the root window, but not always.) Metacity/Mutter tests
for this case in its tab popup implementation, we need to do the same in
ours.
Comment 1 Dan Winship 2009-09-29 03:37:38 UTC
Created attachment 144225 [details] [review]
[AppSwitcher] deal with the user releasing Alt before we get the grab

Previously mutter was doing this for us, but now we need to do it
ourselves.
Comment 2 Owen Taylor 2009-09-29 13:55:20 UTC
Review of attachment 144225 [details] [review]:

It wasn't immediately obvious to me how the Alt-key release was being missed, so I did a bit of research, and determined the following:

 - Mutter grabs global keybindings passing SyncKeyboard - so an synchronous grab is established when Alt-Tab is pressed and the keyboard freezes
 - However, when metacity gets the key, it calls XAllowEvents(..., AsyncKeyboard) immediately, so keyboard event processing resumes
 - When the Tab key release is processed the grab is automatically deactivated. From XGrabKey(3):

    The active grab is terminated automatically when the logical state of the
    keyboard has the specified key released (independent of the logical state
    of the modifier keys), at which point a KeyRelease event is reported to the
    grabbing window.

So if Tab is released before the alt key, and the release is processed before we establish our active grab, we won't get the Alt release. Hence, we either we need to do something like what you do in the patch, or the other fix is to move the XAllowEvents() call until after keybinding handlers have been called.

The original metacity bug is bug 85916 which has some of the above background, though I didn't think of using synchronous grabs as a fix when Havoc asked for ideas.

I think this patch is fine as a simple fix, you may want to put some of the above background in the comment or in the commit message.
Comment 3 Dan Winship 2009-09-29 14:08:46 UTC
Attachment 144225 [details] pushed as 373fa3c - [AppSwitcher] deal with the user releasing Alt before we get the grab

I just added a link to this bug from the comment in altTab.js rather than
trying to summarize the analysis.