summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-04-30 21:35:17 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-04-30 21:35:17 +0800
commit8655885ced663539527f0b7aaa701bfe6008a34a (patch)
treed58a437e44e3d59e9b72fea527cb7c62a41e3b7b /src
parentd5211b00b7a895eadf57a207105b85be897216cc (diff)
downloadmobilebling-8655885ced663539527f0b7aaa701bfe6008a34a.tar.gz
mobilebling-8655885ced663539527f0b7aaa701bfe6008a34a.tar.bz2
Release implicit grabs as soon as we handle events.
Implicit keyboard grabs which are created by the pressing and holding of a key that was passively grabbed by XGrabKey are evil for a number of reasons.First of all, there isn't any way to track them or to track which window they are grabbed on so if a plugin makes an active grab and then releases it, the passive grab is released on release, which means there is an inconsistency between holding the key and having the grab. Secondly, if plugins actually need a grab on all keys, they are better switching to an active grab rather than relying on the passive one. Finally, if there is a passive grab by another application by a key-modifier combo which has the same modifier mask as the currently activated passive grab, then it means that this application won't get its grab activated as long as the modifier is held down.
Diffstat (limited to 'src')
-rw-r--r--src/event.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/event.cpp b/src/event.cpp
index b27e8b5..792989b 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -987,6 +987,7 @@ CompScreen::handleEvent (XEvent *event)
CompWindow *w = NULL;
XWindowAttributes wa;
+ bool actionEventHandled = false;
switch (event->type) {
case ButtonPress:
@@ -1015,9 +1016,24 @@ CompScreen::handleEvent (XEvent *event)
if (priv->grabs.empty ())
XAllowEvents (priv->dpy, AsyncPointer, event->xbutton.time);
- return;
+ actionEventHandled = true;
+ }
+
+ if (priv->grabs.empty ())
+ {
+ switch (event->type)
+ {
+ case KeyPress:
+ XUngrabKeyboard (priv->dpy, event->xkey.time);
+ break;
+ default:
+ break;
+ }
}
+ if (actionEventHandled)
+ return;
+
switch (event->type) {
case SelectionRequest:
priv->handleSelectionRequest (event);