From 6dfa3b8cdf9e1479dae1150ecd0b906cbcc51357 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Thu, 13 Oct 2011 12:53:25 +0100 Subject: [PATCH] XFixes: Add support for version 6 Add support for the sprite-specific cursor show and hide requests introduced in version 6. Signed-off-by: Daniel Stone --- configure.ac | 2 +- include/protocol-versions.h | 2 +- xfixes/cursor.c | 178 ++++++++++++++++++++++++++++++++---------- xfixes/xfixes.c | 7 ++ xfixes/xfixesint.h | 14 ++++ 5 files changed, 158 insertions(+), 45 deletions(-) diff --git a/configure.ac b/configure.ac index 9038c67..7000316 100644 --- a/configure.ac +++ b/configure.ac @@ -803,7 +803,7 @@ dnl specific modules against it PKG_CHECK_MODULES(PIXMAN, $LIBPIXMAN) REQUIRED_LIBS="$REQUIRED_LIBS $LIBPIXMAN $LIBXFONT xau" -REQUIRED_MODULES="[fixesproto >= 5.0] [damageproto >= 1.1] [xcmiscproto >= 1.2.0] [xtrans >= 1.2.2] [bigreqsproto >= 1.1.0] $SDK_REQUIRED_MODULES" +REQUIRED_MODULES="[fixesproto >= 6.0] [damageproto >= 1.1] [xcmiscproto >= 1.2.0] [xtrans >= 1.2.2] [bigreqsproto >= 1.1.0] $SDK_REQUIRED_MODULES" if test "x$CONFIG_UDEV" = xyes && { test "x$CONFIG_DBUS_API" = xyes || test "x$CONFIG_HAL" = xyes; }; then diff --git a/include/protocol-versions.h b/include/protocol-versions.h index 832bcf7..1c03f94 100644 --- a/include/protocol-versions.h +++ b/include/protocol-versions.h @@ -122,7 +122,7 @@ #define SERVER_XF86VIDMODE_MINOR_VERSION 2 /* Fixes */ -#define SERVER_XFIXES_MAJOR_VERSION 5 +#define SERVER_XFIXES_MAJOR_VERSION 6 #define SERVER_XFIXES_MINOR_VERSION 0 /* X Input */ diff --git a/xfixes/cursor.c b/xfixes/cursor.c index 2950e45..156c2a5 100644 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -46,6 +46,7 @@ #include #endif +#include #include "xfixesint.h" #include "scrnintstr.h" #include "cursorstr.h" @@ -107,7 +108,7 @@ typedef struct _CursorHideCountRec { CursorHideCountPtr pNext; ClientPtr pClient; ScreenPtr pScreen; - int hideCount; + int hideCount[EMASKSIZE]; XID resource; } CursorHideCountRec; @@ -149,7 +150,9 @@ CursorDisplayCursor (DeviceIntPtr pDev, { CursorScreenPtr cs = GetCursorScreen(pScreen); Bool ret; + Bool hidden = FALSE; DisplayCursorProcPtr backupProc; + CursorHideCountPtr chc; Unwrap (cs, pScreen, DisplayCursor, backupProc); @@ -160,7 +163,19 @@ CursorDisplayCursor (DeviceIntPtr pDev, if (ConnectionInfo) CursorVisible = EnableCursor; - if (cs->pCursorHideCounts != NULL || !CursorVisible) { + if (!CursorVisible) + hidden = TRUE; + if (cs->pCursorHideCounts) { + for (chc = cs->pCursorHideCounts; chc; chc = chc->pNext) { + if (chc->hideCount[pDev->id] || chc->hideCount[XIAllDevices] || + chc->hideCount[XIAllMasterDevices]) { + hidden = TRUE; + break; + } + } + } + + if (hidden) { ret = (*pScreen->DisplayCursor) (pDev, pScreen, NullCursor); } else { ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor); @@ -806,7 +821,6 @@ createCursorHideCount (ClientPtr pClient, ScreenPtr pScreen) } pChc->pClient = pClient; pChc->pScreen = pScreen; - pChc->hideCount = 1; pChc->resource = FakeClientID(pClient->index); pChc->pNext = cs->pCursorHideCounts; cs->pCursorHideCounts = pChc; @@ -869,20 +883,18 @@ deleteCursorHideCountsForScreen (ScreenPtr pScreen) cs->pCursorHideCounts = NULL; } -int -ProcXFixesHideCursor (ClientPtr client) +static int +HideDeviceCursor (ClientPtr client, xXFixesHideDeviceCursorReq *req) { WindowPtr pWin; CursorHideCountPtr pChc; - REQUEST(xXFixesHideCursorReq); + DeviceIntPtr dev; int ret; - REQUEST_SIZE_MATCH (xXFixesHideCursorReq); - - ret = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, + ret = dixLookupResourceByType((pointer *)&pWin, req->window, RT_WINDOW, client, DixGetAttrAccess); if (ret != Success) { - client->errorValue = stuff->window; + client->errorValue = req->window; return ret; } @@ -890,34 +902,49 @@ ProcXFixesHideCursor (ClientPtr client) * Has client hidden the cursor before on this screen? * If so, just increment the count. */ - pChc = findCursorHideCount(client, pWin->drawable.pScreen); - if (pChc != NULL) { - pChc->hideCount++; - return Success; + if (pChc == NULL) { + /* + * This is the first time this client has hid the cursor + * for this screen. + */ + ret = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen, + DixHideAccess); + if (ret != Success) + return ret; + ret = createCursorHideCount(client, pWin->drawable.pScreen); + if (ret != Success) + return ret; + pChc = findCursorHideCount(client, pWin->drawable.pScreen); + if (pChc == NULL) + return BadAlloc; } + pChc->hideCount[req->device]++; - /* - * This is the first time this client has hid the cursor - * for this screen. - */ - ret = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen, - DixHideAccess); - if (ret != Success) - return ret; + for (dev = inputInfo.devices; dev; dev = dev->next) { + if (IsMaster(dev) && IsPointerDevice(dev) && + (dev->id == req->device || req->device == XIAllDevices || + req->device == XIAllMasterDevices)) { + CursorDisplayCursor(dev, pWin->drawable.pScreen, + CursorCurrent[dev->id]); + } + } - ret = createCursorHideCount(client, pWin->drawable.pScreen); + return Success; +} - if (ret == Success) { - DeviceIntPtr dev; - for (dev = inputInfo.devices; dev; dev = dev->next) - { - if (IsMaster(dev) && IsPointerDevice(dev)) - CursorDisplayCursor(dev, pWin->drawable.pScreen, CursorCurrent[dev->id]); - } - } +int +ProcXFixesHideCursor (ClientPtr client) +{ + REQUEST(xXFixesHideCursorReq); + xXFixesHideDeviceCursorReq dev; - return ret; + REQUEST_SIZE_MATCH(xXFixesHideCursorReq); + memcpy(&dev, stuff, sizeof(*stuff)); + dev.device = XIAllDevices; + dev.pad = 0; + + return HideDeviceCursor(client, &dev); } int @@ -931,25 +958,45 @@ SProcXFixesHideCursor (ClientPtr client) return (*ProcXFixesVector[stuff->xfixesReqType]) (client); } -int -ProcXFixesShowCursor (ClientPtr client) +int +ProcXFixesHideDeviceCursor (ClientPtr client) +{ + REQUEST(xXFixesHideDeviceCursorReq); + + REQUEST_SIZE_MATCH(xXFixesHideDeviceCursorReq); + + return HideDeviceCursor(client, stuff); +} + +int SProcXFixesHideDeviceCursor (ClientPtr client) +{ + REQUEST(xXFixesHideDeviceCursorReq); + + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xXFixesHideDeviceCursorReq); + swapl(&stuff->window); + swaps(&stuff->device); + + return (*ProcXFixesVector[stuff->xfixesReqType]) (client); +} + +static int +ShowDeviceCursor (ClientPtr client, xXFixesShowDeviceCursorReq *req) { + DeviceIntPtr dev; WindowPtr pWin; CursorHideCountPtr pChc; int rc; - REQUEST(xXFixesShowCursorReq); - REQUEST_SIZE_MATCH (xXFixesShowCursorReq); - - rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, + rc = dixLookupResourceByType((pointer *)&pWin, req->window, RT_WINDOW, client, DixGetAttrAccess); if (rc != Success) { - client->errorValue = stuff->window; + client->errorValue = req->window; return rc; } /* - * Has client hidden the cursor on this screen? + * Has client hidden any cursor on this screen? * If not, generate an error. */ pChc = findCursorHideCount(client, pWin->drawable.pScreen); @@ -962,14 +1009,37 @@ ProcXFixesShowCursor (ClientPtr client) if (rc != Success) return rc; - pChc->hideCount--; - if (pChc->hideCount <= 0) { - FreeResource(pChc->resource, 0); + if (pChc->hideCount[req->device] <= 0) + return BadMatch; + + pChc->hideCount[req->device]--; + + for (dev = inputInfo.devices; dev; dev = dev->next) { + if (IsMaster(dev) && IsPointerDevice(dev) && + (dev->id == req->device || req->device == XIAllDevices || + req->device == XIAllMasterDevices)) { + CursorDisplayCursor(dev, pWin->drawable.pScreen, + CursorCurrent[dev->id]); + } } return Success; } +int +ProcXFixesShowCursor (ClientPtr client) +{ + REQUEST(xXFixesShowCursorReq); + xXFixesShowDeviceCursorReq dev; + + REQUEST_SIZE_MATCH(xXFixesShowCursorReq); + memcpy(&dev, stuff, sizeof(*stuff)); + dev.device = XIAllDevices; + dev.pad = 0; + + return ShowDeviceCursor(client, &dev); +} + int SProcXFixesShowCursor (ClientPtr client) { @@ -981,6 +1051,28 @@ SProcXFixesShowCursor (ClientPtr client) return (*ProcXFixesVector[stuff->xfixesReqType]) (client); } +int +ProcXFixesShowDeviceCursor (ClientPtr client) +{ + REQUEST(xXFixesShowDeviceCursorReq); + + REQUEST_SIZE_MATCH(xXFixesShowDeviceCursorReq); + + return ShowDeviceCursor(client, stuff); +} + +int SProcXFixesShowDeviceCursor (ClientPtr client) +{ + REQUEST(xXFixesShowDeviceCursorReq); + + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xXFixesShowDeviceCursorReq); + swapl(&stuff->window); + swaps(&stuff->device); + + return (*ProcXFixesVector[stuff->xfixesReqType]) (client); +} + static int CursorFreeClient (pointer data, XID id) { diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c index 6d36d5f..afd764d 100644 --- a/xfixes/xfixes.c +++ b/xfixes/xfixes.c @@ -99,6 +99,7 @@ static const int version_requests[] = { X_XFixesExpandRegion, /* Version 3 */ X_XFixesShowCursor, /* Version 4 */ X_XFixesDestroyPointerBarrier, /* Version 5 */ + X_XFixesShowDeviceCursor, /* Version 6 */ }; #define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0])) @@ -142,6 +143,9 @@ int (*ProcXFixesVector[XFixesNumberRequests])(ClientPtr) = { /*************** Version 5 ****************/ ProcXFixesCreatePointerBarrier, ProcXFixesDestroyPointerBarrier, +/*************** Version 6 ****************/ + ProcXFixesHideDeviceCursor, + ProcXFixesShowDeviceCursor, }; static int @@ -207,6 +211,9 @@ static int (*SProcXFixesVector[XFixesNumberRequests])(ClientPtr) = { /*************** Version 5 ****************/ SProcXFixesCreatePointerBarrier, SProcXFixesDestroyPointerBarrier, +/*************** Version 6 ****************/ + SProcXFixesHideDeviceCursor, + SProcXFixesShowDeviceCursor, }; static int diff --git a/xfixes/xfixesint.h b/xfixes/xfixesint.h index 6ba276e..f1187ad 100644 --- a/xfixes/xfixesint.h +++ b/xfixes/xfixesint.h @@ -293,6 +293,20 @@ ProcXFixesDestroyPointerBarrier (ClientPtr client); int SProcXFixesDestroyPointerBarrier (ClientPtr client); +/* Version 6 */ + +int +ProcXFixesHideDeviceCursor (ClientPtr client); + +int +SProcXFixesHideDeviceCursor (ClientPtr client); + +int +ProcXFixesShowDeviceCursor (ClientPtr client); + +int +SProcXFixesShowDeviceCursor (ClientPtr client); + /* Xinerama */ extern int (*PanoramiXSaveXFixesVector[XFixesNumberRequests])(ClientPtr); void PanoramiXFixesInit (void); -- 1.7.7