[PATCH 2/2] Report touch emulated buttons in XIQueryPointer for XI 2.1 and earlier

Chase Douglas chase.douglas at canonical.com
Fri Apr 20 11:07:18 PDT 2012


XInput 2.1 and earlier clients do not know about touches. We must report
touch emulated button presses for these clients. For later clients, we
only report true pointer button presses.

Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
 Xi/xiquerypointer.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index e2a940c..01827f9 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -79,10 +79,21 @@ ProcXIQueryPointer(ClientPtr client)
     XkbStatePtr state;
     char *buttons = NULL;
     int buttons_size = 0;       /* size of buttons array */
+    XIClientPtr xi_client;
+    Bool have_xi22 = FALSE;
 
     REQUEST(xXIQueryPointerReq);
     REQUEST_SIZE_MATCH(xXIQueryPointerReq);
 
+    /* Check if client is compliant with XInput 2.2 or later. Earlier clients
+     * do not know about touches, so we must report emulated button presses. 2.2
+     * and later clients are aware of touches, so we don't include emulated
+     * button presses in the reply. */
+    xi_client = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
+    if (version_compare(xi_client->major_version,
+                        xi_client->minor_version, 2, 2) >= 0)
+        have_xi22 = TRUE;
+
     rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixReadAccess);
     if (rc != Success) {
         client->errorValue = stuff->deviceid;
@@ -144,7 +155,9 @@ ProcXIQueryPointer(ClientPtr client)
 
         for (i = 0; i < pDev->button->numButtons; i++)
             /* Logical button state is stored as core protocol mask bits */
-            if (BitIsOn(&pDev->button->state, 8 + i))
+            if (BitIsOn(&pDev->button->state, 8 + i) ||
+                (!have_xi22 && pDev->touch &&
+                 BitIsOn(&pDev->touch->state, 8 + i)))
                 SetBit(buttons, i);
     }
     else
-- 
1.7.9.1



More information about the xorg-devel mailing list