GNOME Bugzilla – Bug 596695
[AppSwitcher] deal with the user releasing Alt before we get the grab
Last modified: 2009-09-29 14:08:48 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.
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.
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.
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.