summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Douglas <chase.douglas@canonical.com>2012-05-01 10:21:12 -0700
committerPeter Hutterer <peter.hutterer@who-t.net>2012-05-14 15:54:26 +1000
commitdab90b60f3b2ebfd8df4fa761f3f34859250f4db (patch)
treed29969fd0cd8e7592985fb39c6eae9cccec8475a
parent04474fc6a4c21a06c1a65c7afcbc4e0a27e3d0f7 (diff)
Report touch emulated buttons in XIQueryPointer for XI 2.1 and earlier
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@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> (cherry picked from commit ee542b85590814ee25369babce1ad14feeb137af)
-rw-r--r--Xi/xiquerypointer.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index ba99752ef..169436e14 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;
@@ -145,6 +156,9 @@ ProcXIQueryPointer(ClientPtr client)
for (i = 1; i < pDev->button->numButtons; i++)
if (BitIsOn(pDev->button->down, i))
SetBit(buttons, pDev->button->map[i]);
+
+ if (!have_xi22 && pDev->touch && pDev->touch->buttonsDown > 0)
+ SetBit(buttons, pDev->button->map[1]);
}
else
rep.buttons_len = 0;