diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2012-06-10 13:21:33 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2012-06-10 13:21:33 +0000 |
commit | 171e929a08098b6c844887adc43879c7579dc15f (patch) | |
tree | 6b4d2e3bc20dbd4dc9a1f031416e66614c53dd21 /xserver/Xi/xiquerypointer.c | |
parent | 68781b09de2c95b87ea898c4ecf3018dfb4460d2 (diff) |
Update to xserver 1.12.2. tested by naddy@, krw@, mpi@.
Diffstat (limited to 'xserver/Xi/xiquerypointer.c')
-rw-r--r-- | xserver/Xi/xiquerypointer.c | 116 |
1 files changed, 55 insertions, 61 deletions
diff --git a/xserver/Xi/xiquerypointer.c b/xserver/Xi/xiquerypointer.c index 51317994b..169436e14 100644 --- a/xserver/Xi/xiquerypointer.c +++ b/xserver/Xi/xiquerypointer.c @@ -33,10 +33,10 @@ #include <dix-config.h> #endif -#include <X11/X.h> /* for inputstr.h */ -#include <X11/Xproto.h> /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ +#include <X11/X.h> /* for inputstr.h */ +#include <X11/Xproto.h> /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XI2proto.h> #include "extnsionst.h" @@ -61,12 +61,10 @@ int SProcXIQueryPointer(ClientPtr client) { - char n; - REQUEST(xXIQueryPointerReq); - swaps(&stuff->length, n); - swaps(&stuff->deviceid, n); - swapl(&stuff->win, n); + swaps(&stuff->length); + swaps(&stuff->deviceid); + swapl(&stuff->win); return (ProcXIQueryPointer(client)); } @@ -80,30 +78,36 @@ ProcXIQueryPointer(ClientPtr client) SpritePtr pSprite; XkbStatePtr state; char *buttons = NULL; - int buttons_size = 0; /* size of buttons array */ + 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) - { + if (rc != Success) { client->errorValue = stuff->deviceid; return rc; } - if (pDev->valuator == NULL || IsKeyboardDevice(pDev) || - (!IsMaster(pDev) && !IsFloating(pDev))) /* no attached devices */ - { + if (pDev->valuator == NULL || IsKeyboardDevice(pDev) || (!IsMaster(pDev) && !IsFloating(pDev))) { /* no attached devices */ client->errorValue = stuff->deviceid; return BadDevice; } rc = dixLookupWindow(&pWin, stuff->win, client, DixGetAttrAccess); - if (rc != Success) - { - SendErrorToClient(client, IReqCode, X_XIQueryPointer, - stuff->win, rc); + if (rc != Success) { + SendErrorToClient(client, IReqCode, X_XIQueryPointer, stuff->win, rc); return Success; } @@ -111,7 +115,7 @@ ProcXIQueryPointer(ClientPtr client) MaybeStopHint(pDev, client); if (IsMaster(pDev)) - kbd = GetPairedDevice(pDev); + kbd = GetMaster(pDev, MASTER_KEYBOARD); else kbd = (pDev->key) ? pDev : NULL; @@ -127,8 +131,7 @@ ProcXIQueryPointer(ClientPtr client) rep.root_y = FP1616(pSprite->hot.y, 0); rep.child = None; - if (kbd) - { + if (kbd) { state = &kbd->key->xkbInfo->state; rep.mods.base_mods = state->base_mods; rep.mods.latched_mods = state->latched_mods; @@ -139,53 +142,48 @@ ProcXIQueryPointer(ClientPtr client) rep.group.locked_group = state->locked_group; } - if (pDev->button) - { - int i, down; - rep.buttons_len = bytes_to_int32(bits_to_bytes(pDev->button->numButtons)); + if (pDev->button) { + int i; + + rep.buttons_len = + bytes_to_int32(bits_to_bytes(pDev->button->numButtons)); rep.length += rep.buttons_len; buttons_size = rep.buttons_len * 4; buttons = calloc(1, buttons_size); if (!buttons) return BadAlloc; - down = pDev->button->buttonsDown; - - for (i = 0; i < pDev->button->numButtons && down; i++) - { + for (i = 1; i < pDev->button->numButtons; i++) if (BitIsOn(pDev->button->down, i)) - { - SetBit(buttons, i); - down--; - } - } - } else + 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; - if (pSprite->hot.pScreen == pWin->drawable.pScreen) - { + if (pSprite->hot.pScreen == pWin->drawable.pScreen) { rep.same_screen = xTrue; rep.win_x = FP1616(pSprite->hot.x - pWin->drawable.x, 0); rep.win_y = FP1616(pSprite->hot.y - pWin->drawable.y, 0); for (t = pSprite->win; t; t = t->parent) - if (t->parent == pWin) - { + if (t->parent == pWin) { rep.child = t->drawable.id; break; } - } else - { + } + else { rep.same_screen = xFalse; rep.win_x = 0; rep.win_y = 0; } #ifdef PANORAMIX - if(!noPanoramiXExtension) { + if (!noPanoramiXExtension) { rep.root_x += FP1616(screenInfo.screens[0]->x, 0); rep.root_y += FP1616(screenInfo.screens[0]->y, 0); - if (stuff->win == rep.root) - { + if (stuff->win == rep.root) { rep.win_x += FP1616(screenInfo.screens[0]->x, 0); rep.win_y += FP1616(screenInfo.screens[0]->y, 0); } @@ -209,21 +207,17 @@ ProcXIQueryPointer(ClientPtr client) */ void -SRepXIQueryPointer(ClientPtr client, int size, - xXIQueryPointerReply * rep) +SRepXIQueryPointer(ClientPtr client, int size, xXIQueryPointerReply * rep) { - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->root, n); - swapl(&rep->child, n); - swapl(&rep->root_x, n); - swapl(&rep->root_y, n); - swapl(&rep->win_x, n); - swapl(&rep->win_y, n); - swaps(&rep->buttons_len, n); - - WriteToClient(client, size, (char *)rep); + swaps(&rep->sequenceNumber); + swapl(&rep->length); + swapl(&rep->root); + swapl(&rep->child); + swapl(&rep->root_x); + swapl(&rep->root_y); + swapl(&rep->win_x); + swapl(&rep->win_y); + swaps(&rep->buttons_len); + + WriteToClient(client, size, (char *) rep); } - |