e0a45b
From 883ed64cd23ad286250894b42c04603da85b65b5 Mon Sep 17 00:00:00 2001
e0a45b
From: Peter Hutterer <peter.hutterer@who-t.net>
e0a45b
Date: Wed, 16 Dec 2009 13:43:22 +1000
e0a45b
Subject: [PATCH] dix: if owner-events is true for passive grabs, add the window mask (#25400)
e0a45b
e0a45b
A client requesting a GrabModeSync button grab, owner-events true, with only
e0a45b
the ButtonRelease mask set would never receive the press event even if the
e0a45b
grab window had the ButtonPress mask set.
e0a45b
e0a45b
The protocol requires that if owner-events is true, then the delivery mask
e0a45b
is the combination of the grab mask + the window event mask.
e0a45b
e0a45b
X.Org Bug 25400 <http: bugs.freedesktop.org="" show_bug.cgi?id="25400">
e0a45b
e0a45b
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
e0a45b
Tested-by: Jim Ramsay <i.am@jimramsay.com>
e0a45b
---
e0a45b
 dix/events.c |   36 ++++++++++++++++++++++++++++++++++++
e0a45b
 1 files changed, 36 insertions(+), 0 deletions(-)
e0a45b
e0a45b
diff --git a/dix/events.c b/dix/events.c
e0a45b
index 85c8f9a..b854d98 100644
e0a45b
--- a/dix/events.c
e0a45b
+++ b/dix/events.c
e0a45b
@@ -3580,6 +3580,8 @@ CheckPassiveGrabsOnWindow(
e0a45b
                 xE = &core;
e0a45b
                 count = 1;
e0a45b
                 mask = grab->eventMask;
e0a45b
+                if (grab->ownerEvents)
e0a45b
+                    mask |= pWin->eventMask;
e0a45b
             } else if (match & XI2_MATCH)
e0a45b
             {
e0a45b
                 rc = EventToXI2((InternalEvent*)event, &xE);
e0a45b
@@ -3601,6 +3603,24 @@ CheckPassiveGrabsOnWindow(
e0a45b
                     mask = grab->xi2mask[device->id][((xGenericEvent*)xE)->evtype/8];
e0a45b
                 else if (event->type == XI_Enter || event->type == XI_FocusIn)
e0a45b
                     mask = grab->xi2mask[device->id][event->type/8];
e0a45b
+
e0a45b
+                if (grab->ownerEvents && wOtherInputMasks(grab->window))
e0a45b
+                {
e0a45b
+                    InputClientsPtr icp =
e0a45b
+                        wOtherInputMasks(grab->window)->inputClients;
e0a45b
+
e0a45b
+                    while(icp)
e0a45b
+                    {
e0a45b
+                        if (rClient(icp) == rClient(grab))
e0a45b
+                        {
e0a45b
+                            int evtype = (xE) ? ((xGenericEvent*)xE)->evtype : event->type;
e0a45b
+                            mask |= icp->xi2mask[device->id][evtype/8];
e0a45b
+                            break;
e0a45b
+                        }
e0a45b
+
e0a45b
+                        icp = icp->next;
e0a45b
+                    }
e0a45b
+                }
e0a45b
             } else
e0a45b
             {
e0a45b
                 rc = EventToXI((InternalEvent*)event, &xE, &count);
e0a45b
@@ -3612,6 +3632,22 @@ CheckPassiveGrabsOnWindow(
e0a45b
                     continue;
e0a45b
                 }
e0a45b
                 mask = grab->eventMask;
e0a45b
+                if (grab->ownerEvents && wOtherInputMasks(grab->window))
e0a45b
+                {
e0a45b
+                    InputClientsPtr icp =
e0a45b
+                        wOtherInputMasks(grab->window)->inputClients;
e0a45b
+
e0a45b
+                    while(icp)
e0a45b
+                    {
e0a45b
+                        if (rClient(icp) == rClient(grab))
e0a45b
+                        {
e0a45b
+                            mask |= icp->mask[device->id];
e0a45b
+                            break;
e0a45b
+                        }
e0a45b
+
e0a45b
+                        icp = icp->next;
e0a45b
+                    }
e0a45b
+                }
e0a45b
             }
e0a45b
 
e0a45b
 	    (*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
e0a45b
-- 
e0a45b
1.6.6
e0a45b