xserver: Branch 'mpx' - 3 commits

Peter Hutterer whot at kemper.freedesktop.org
Thu May 31 23:23:20 PDT 2007


 Xi/exevents.c      |    3 +
 Xi/setcptr.c       |    7 ++-
 dix/events.c       |  110 +++++++++++++++++++++++++++++++++++------------------
 include/inputstr.h |    4 +
 4 files changed, 85 insertions(+), 39 deletions(-)

New commits:
diff-tree 26b21157cf934ae387b15faa9ebb060120e6a0d6 (from 182ab3a3d5b28daa86e6d6155e76ce759687ae6d)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu May 31 17:05:14 2007 +0930

    Add a deviceMask to the GrabRec and don't interfere with passiveGrabs.
    
    This quickfixes event delivery problems with XI events when a grab was on.
    deviceMask is only used when the grab was from a ButtonPress to preserve
    potential XI event masks.
    
    This is not an ideal solution but it works until I have time to work on
    PassiveGrabs.

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 98c2885..2e9e826 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -126,6 +126,9 @@ ProcessOtherEvent(xEventPtr xE, DeviceIn
     ValuatorClassPtr v = device->valuator;
     deviceValuator *xV = (deviceValuator *) xE;
 
+    if (grab && grab->coreGrab && !device->deviceGrab.fromPassiveGrab)
+        return;
+
     if (xE->u.u.type != DeviceValuator && xE->u.u.type != GenericEvent) {
         DeviceIntPtr mouse = NULL, kbd = NULL;
 	GetSpritePosition(device, &rootX, &rootY);
diff --git a/dix/events.c b/dix/events.c
index 9dddf2c..ba1463a 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1839,6 +1839,10 @@ TryClientEvents (ClientPtr client, xEven
  * Deliver events to a window. At this point, we do not yet know if the event
  * actually needs to be delivered. May activate a grab if the event is a
  * button press.
+ * 
+ * Core events are always delivered to the window owner. If the filter is
+ * something other than CantBeFiltered, the event is also delivered to other
+ * clients with the matching mask on the window.
  *
  * More than one event may be delivered at a time. This is the case with
  * DeviceMotionNotifies which may be followed by DeviceValuator events.
@@ -1964,6 +1968,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev,
     if ((type == ButtonPress) && deliveries && (!grab))
     {
 	GrabRec tempGrab;
+        OtherInputMasks *inputMasks;
 
 	tempGrab.device = pDev;
 	tempGrab.resource = client->clientAsMask;
@@ -1975,6 +1980,11 @@ DeliverEventsToWindow(DeviceIntPtr pDev,
 	tempGrab.confineTo = NullWindow;
 	tempGrab.cursor = NullCursor;
         tempGrab.coreGrab = True;
+
+        /* get the XI device mask */
+        inputMasks = wOtherInputMasks(pWin);
+        tempGrab.deviceMask = (inputMasks) ? inputMasks->inputEvents[pDev->id]: 0;
+
         tempGrab.genericMasks = NULL;
 	(*inputInfo.pointer->deviceGrab.ActivateGrab)(pDev, &tempGrab,
 					   currentTime, TRUE);
@@ -3221,10 +3231,14 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIn
                         grab);
             } else 
             {
+                Mask mask = grab->eventMask;
+                if (grabinfo->fromPassiveGrab && (xE->u.u.type &
+                            EXTENSION_EVENT_BASE))
+                    mask = grab->deviceMask;
+
                 FixUpEventFromWindow(thisDev, xE, grab->window, None, TRUE);
                 deliveries = TryClientEvents(rClient(grab), xE, count,
-                        (Mask)grab->eventMask,
-                        filters[xE->u.u.type], grab);
+                        mask, filters[xE->u.u.type], grab);
             }
             if (deliveries && (xE->u.u.type == MotionNotify
 #ifdef XINPUT
@@ -5716,7 +5730,8 @@ IsInterferingGrab(ClientPtr client, Devi
     {
         if (it != dev)
         {
-            if (it->deviceGrab.grab && SameClient(it->deviceGrab.grab, client))
+            if (it->deviceGrab.grab && SameClient(it->deviceGrab.grab, client)
+                        && !it->deviceGrab.fromPassiveGrab)
             {
                 return TRUE;
             }
diff --git a/include/inputstr.h b/include/inputstr.h
index a535884..986232c 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -117,6 +117,9 @@ typedef struct _GenericMaskRec {
  * ButtonPressMask).
  * If the grab is a device grab (GrabDevice), then the eventMask is a
  * combination of event masks for a given XI event type (see SetEventInfo).
+ *
+ * If the grab is a result of a ButtonPress, then eventMask is the core mask
+ * and deviceMask is set to the XI event mask for the grab.
  */
 typedef struct _GrabRec {
     GrabPtr		next;		/* for chain of passive grabs */
@@ -135,6 +138,7 @@ typedef struct _GrabRec {
     WindowPtr		confineTo;	/* always NULL for keyboards */
     CursorPtr		cursor;		/* always NULL for keyboards */
     Mask		eventMask;
+    Mask                deviceMask;     
     GenericMaskPtr      genericMasks;   /* null terminated list */
 } GrabRec;
 
diff-tree 182ab3a3d5b28daa86e6d6155e76ce759687ae6d (from b5db863945fa8045995b3bf742c44e40f2650f04)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed May 30 17:44:31 2007 +0930

    Fix up comments for event.c

diff --git a/dix/events.c b/dix/events.c
index 402e3b3..9dddf2c 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -237,22 +237,24 @@ static int DontPropagateRefCnts[DNPMCOUN
  *     inputInfo.pointer 
  *     is the core pointer. Referred to as "virtual core pointer", "VCP",
  *     "core pointer" or inputInfo.pointer. There is exactly one core pointer,
- *     but multiple devices may send core events. If a device generates core
- *     events, those events will appear to originate from the core pointer.
+ *     but multiple devices may send core events. The VCP is only used if no
+ *     physical device is connected and does not have a visible cursor. 
+ *     Before the integration of MPX, any core request would operate on the
+ *     VCP/VCK. Core events would always come from one of those two. Now both
+ *     are only fallback devices if no physical devices are available.
  * 
  *     inputInfo.keyboard
  *     is the core keyboard ("virtual core keyboard", "VCK", "core keyboard").
  *     See inputInfo.pointer.
  * 
  *     inputInfo.devices
- *     linked list containing all devices including VCK and VCP. The VCK will
- *     always be the first entry, the VCP the second entry in the device list.
+ *     linked list containing all devices BUT NOT INCLUDING VCK and VCP. 
  *
  *     inputInfo.off_devices
  *     Devices that have not been initialized and are thus turned off.
  *
  *     inputInfo.numDevices
- *     Total number of devices.
+ *     Total number of devices (not counting VCP and VCK).
  */
 _X_EXPORT InputInfo inputInfo;
 
@@ -1387,11 +1389,12 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, 
 
 /**
  * Activate a pointer grab on the given device. A pointer grab will cause all
- * core pointer events to be delivered to the grabbing client only. Can cause
- * the cursor to change if a grab cursor is set.
+ * core pointer events of this device to be delivered to the grabbing client only. 
+ * No other device will send core events to the grab client while the grab is
+ * on, but core events will be sent to other clients.
+ * Can cause the cursor to change if a grab cursor is set.
  * 
- * As a pointer grab can only be issued on the core devices, mouse is always
- * inputInfo.pointer. Extension devices are set up for ActivateKeyboardGrab().
+ * Extension devices are set up for ActivateKeyboardGrab().
  * 
  * @param mouse The device to grab.
  * @param grab The grab structure, needs to be setup.
@@ -1433,8 +1436,7 @@ ActivatePointerGrab(DeviceIntPtr mouse, 
 /**
  * Delete grab on given device, update the sprite.
  *
- * As a pointer grab can only be issued on the core devices, mouse is always
- * inputInfo.pointer. Extension devices are set up for ActivateKeyboardGrab().
+ * Extension devices are set up for ActivateKeyboardGrab().
  */
 void
 DeactivatePointerGrab(DeviceIntPtr mouse)
@@ -1651,7 +1653,7 @@ AllowSome(ClientPtr client, 
 /**
  * Server-side protocol handling for AllowEvents request.
  *
- * Release some events from a frozen device. Only applicable for core devices.
+ * Release some events from a frozen device. 
  */
 int
 ProcAllowEvents(ClientPtr client)
@@ -2135,9 +2137,6 @@ FixUpEventFromWindow(
  * Deliver events caused by input devices. Called for all core input events
  * and XI events. No filtering of events happens before DeliverDeviceEvents(),
  * it will be called for any event that comes out of the event queue.
- * 
- * For all core events, dev is either inputInfo.pointer or inputInfo.keyboard.
- * For all extension events, dev is the device that caused the event.
  *
  * @param pWin Window to deliver event to.
  * @param xE Events to deliver.
@@ -2535,8 +2534,8 @@ void ReinitializeRootWindow(WindowPtr wi
 #endif
 
 /**
- * Set the given window to sane values, display the cursor in the center of
- * the screen. Called from main() with the root window on the first screen.
+ * Called from main() with the root window on the first screen. Used to do a
+ * lot more when MPX wasn't around yet. Things change.
  */
 void
 DefineInitialRootWindow(WindowPtr win)
@@ -2547,6 +2546,21 @@ DefineInitialRootWindow(WindowPtr win)
 
 }
 
+/**
+ * Initialize a sprite for the given device and set it to some sane values. If
+ * the device already has a sprite alloc'd, don't realloc but just reset to
+ * default values.
+ * If a window is supplied, the sprite will be initialized with the window's
+ * cursor and positioned in the center of the window's screen. The root window
+ * is a good choice to pass in here.
+ *
+ * It's a good idea to call it only for pointer devices, unless you have a
+ * really talented keyboard.
+ *
+ * @param pDev The device to initialize.
+ * @param pWin The window where to generate the sprite in.
+ * 
+ */
 void 
 InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
 {
@@ -3824,7 +3838,7 @@ CommonAncestor(
 
 /**
  * Assembles an EnterNotify or LeaveNotify and sends it event to the client. 
- * The core devices are used to fill in the event fields.
+ * Uses the paired keyboard to get some additional information.
  */
 static void
 EnterLeaveEvent(
@@ -4453,7 +4467,7 @@ ProcSetInputFocus(client)
 /**
  * Server-side protocol handling for GetInputFocus request.
  * 
- * Sends the current input focus for the virtual core keyboard back to the
+ * Sends the current input focus for the client's keyboard back to the
  * client.
  */
 int
@@ -4481,8 +4495,8 @@ ProcGetInputFocus(ClientPtr client)
 /**
  * Server-side protocol handling for Grabpointer request.
  *
- * Sets an active grab on the inputInfo.pointer and returns success status to
- * client.
+ * Sets an active grab on the client's ClientPointer and returns success
+ * status to client.
  */
 int
 ProcGrabPointer(ClientPtr client)
@@ -4601,7 +4615,7 @@ ProcGrabPointer(ClientPtr client)
  * Changes properties of the grab hold by the client. If the client does not
  * hold an active grab on the device, nothing happens. 
  *
- * Works on the core pointer only.
+ * Works on the client's ClientPointer.
  */
 int
 ProcChangeActivePointerGrab(ClientPtr client)
@@ -4652,7 +4666,7 @@ ProcChangeActivePointerGrab(ClientPtr cl
 /**
  * Server-side protocol handling for UngrabPointer request.
  *
- * Deletes the pointer grab on the core pointer device.
+ * Deletes the pointer grab on the client's ClientPointer device.
  */
 int
 ProcUngrabPointer(ClientPtr client)
@@ -4676,7 +4690,7 @@ ProcUngrabPointer(ClientPtr client)
 /**
  * Sets a grab on the given device.
  * 
- * Called from ProcGrabKeyboard to work on the inputInfo.keyboard.
+ * Called from ProcGrabKeyboard to work on the client's keyboard.
  * Called from ProcXGrabDevice to work on the device specified by the client.
  * 
  * The parameters this_mode and other_mode represent the keyboard_mode and
@@ -4761,7 +4775,7 @@ GrabDevice(ClientPtr client, DeviceIntPt
 /**
  * Server-side protocol handling for GrabKeyboard request.
  *
- * Grabs the inputInfo.keyboad and returns success status to client.
+ * Grabs the client's keyboard and returns success status to client.
  */
 int
 ProcGrabKeyboard(ClientPtr client)
@@ -4795,7 +4809,7 @@ ProcGrabKeyboard(ClientPtr client)
 /**
  * Server-side protocol handling for UngrabKeyboard request.
  *
- * Deletes a possible grab on the inputInfo.keyboard.
+ * Deletes a possible grab on the client's keyboard.
  */
 int
 ProcUngrabKeyboard(ClientPtr client)
@@ -4819,7 +4833,8 @@ ProcUngrabKeyboard(ClientPtr client)
 /**
  * Server-side protocol handling for QueryPointer request.
  *
- * Returns the current state and position of the core pointer to the client. 
+ * Returns the current state and position of the client's ClientPointer to the
+ * client. 
  */
 int
 ProcQueryPointer(ClientPtr client)
@@ -5029,8 +5044,8 @@ ProcSendEvent(ClientPtr client)
 /**
  * Server-side protocol handling for UngrabKey request.
  *
- * Deletes a passive grab for the given key. Only works on the
- * inputInfo.keyboard.
+ * Deletes a passive grab for the given key. Works on the
+ * client's keyboard.
  */
 int
 ProcUngrabKey(ClientPtr client)
@@ -5077,8 +5092,8 @@ ProcUngrabKey(ClientPtr client)
 /**
  * Server-side protocol handling for GrabKey request.
  *
- * Creates a grab for the inputInfo.keyboard and adds it to the list of
- * passive grabs. 
+ * Creates a grab for the client's keyboard and adds it to the list of passive
+ * grabs. 
  */
 int
 ProcGrabKey(ClientPtr client)
@@ -5138,8 +5153,8 @@ ProcGrabKey(ClientPtr client)
 /**
  * Server-side protocol handling for GrabButton request.
  *
- * Creates a grab for the inputInfo.pointer and adds it as a passive grab to
- * the list.
+ * Creates a grab for the client's ClientPointer and adds it as a passive grab
+ * to the list.
  */
 int
 ProcGrabButton(ClientPtr client)
@@ -5217,7 +5232,7 @@ ProcGrabButton(ClientPtr client)
 /**
  * Server-side protocol handling for UngrabButton request.
  *
- * Deletes a passive grab on the inputInfo.pointer from the list.
+ * Deletes a passive grab on the client's ClientPointer from the list.
  */
 int
 ProcUngrabButton(ClientPtr client)
@@ -5597,6 +5612,12 @@ WriteEventsToClient(ClientPtr pClient, i
 /*
  * Set the client pointer for the given client. Second parameter setter could
  * be used in the future to determine access rights. Unused for now.
+ *
+ * A client can have exactly one ClientPointer. Each time a
+ * request/reply/event is processed and the choice of devices is ambiguous
+ * (e.g. QueryPointer request), the server will pick the ClientPointer (see
+ * PickPointer()). 
+ * If a keyboard is needed, the first keyboard paired with the CP is used.
  */
 _X_EXPORT Bool
 SetClientPointer(ClientPtr client, ClientPtr setter, DeviceIntPtr device)
diff-tree b5db863945fa8045995b3bf742c44e40f2650f04 (from d0e8f474099dea40bbea555427772724ccb787d1)
Author: Paulo Ricardo Zanoni <prz05 at c3sl.ufpr.br>
Date:   Wed May 30 16:15:15 2007 +0930

    Allow value None for windows when setting ClientPointer.
    
    We need this for clients that need to set the ClientPointer but don't have a
    window on display yet. If used, it will set the device as the ClientPointer
    for the requesting client.

diff --git a/Xi/setcptr.c b/Xi/setcptr.c
index 25874f0..66c8981 100644
--- a/Xi/setcptr.c
+++ b/Xi/setcptr.c
@@ -70,6 +70,7 @@ ProcXSetClientPointer(ClientPtr client)
 {
     DeviceIntPtr pDev;
     WindowPtr pWin;
+    ClientPtr targetClient;
     int err;
 
     REQUEST(xSetClientPointerReq);
@@ -93,9 +94,11 @@ ProcXSetClientPointer(ClientPtr client)
                     stuff->win, err);
             return Success;
         }
-    }
+        targetClient= wClient(pWin);
+    } else
+        targetClient = client;
     
-    if (!SetClientPointer(wClient(pWin), client, pDev))
+    if (!SetClientPointer(targetClient, client, pDev))
     {
         SendErrorToClient(client, IReqCode, X_SetClientPointer, 
                 stuff->win, BadAccess);


More information about the xorg-commit mailing list