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