diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2007-03-07 18:19:20 +1030 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2007-03-07 18:19:20 +1030 |
commit | 537bc2ead4d154552cbdc3a19e335f82af63792c (patch) | |
tree | 444dcf6acb5e72c45b352fef9b6c17d794f66f1e | |
parent | 39aa79177196e21bcdbaf8e44adead9ef91e6ee5 (diff) |
Xi: Don't deactivate core grabs from non-core button/key releases.
dix: set coreGrab flag for grabs caused by GrabPointer and button presses.
remove virtual core devices from device list, only real devices are in
the list now.
Auto-pair each keyboard with a real pointer if one is available,
provides multiple keyboards automatically after startup if devices
are configured.
fix GuessFreePointerDevice() to do what it's supposed to do.
mi: fix: call miPointerMove from miPointerWarpCursor.
fix: remove unused id field from miCursorInfoRec
don't update sprite for virtual core pointer.
-rw-r--r-- | Xi/exevents.c | 18 | ||||
-rw-r--r-- | dix/cursor.c | 32 | ||||
-rw-r--r-- | dix/devices.c | 50 | ||||
-rw-r--r-- | dix/events.c | 15 | ||||
-rw-r--r-- | include/input.h | 2 | ||||
-rw-r--r-- | mi/mipointer.c | 8 | ||||
-rw-r--r-- | mi/mispritest.h | 1 |
7 files changed, 94 insertions, 32 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index 7e80926e4..5dbb0e226 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -104,12 +104,12 @@ RegisterOtherDevice(DeviceIntPtr device) } /*ARGSUSED*/ void -ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) +ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count) { - register BYTE *kptr; - register int i; - register CARD16 modifiers; - register CARD16 mask; + BYTE *kptr; + int i; + CARD16 modifiers; + CARD16 mask; GrabPtr grab = other->grab; Bool deactivateDeviceGrab = FALSE; int key = 0, bit = 0, rootX, rootY; @@ -229,7 +229,9 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) } } - if (other->fromPassiveGrab && (key == other->activatingKey)) + if (other->fromPassiveGrab && + !other->grab->coreGrab && + (key == other->activatingKey)) deactivateDeviceGrab = TRUE; } else if (xE->u.u.type == DeviceButtonPress) { if (!b) @@ -267,7 +269,9 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) if (xE->u.u.detail <= 5) b->state &= ~((Button1Mask >> 1) << xE->u.u.detail); SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify); - if (!b->state && other->fromPassiveGrab) + if (!b->state + && other->fromPassiveGrab + && !other->grab->coreGrab) deactivateDeviceGrab = TRUE; } else if (xE->u.u.type == ProximityIn) other->valuator->mode &= ~OutOfProximity; diff --git a/dix/cursor.c b/dix/cursor.c index cf515c11a..e44a5efb0 100644 --- a/dix/cursor.c +++ b/dix/cursor.c @@ -440,6 +440,33 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, for (nscr = 0; nscr < screenInfo.numScreens; nscr++) { pscr = screenInfo.screens[nscr]; + + if (!(*pscr->RealizeCursor)(inputInfo.pointer, pscr, pCurs)) + { + DeviceIntPtr pDevIt = inputInfo.devices; /*dev iterator*/ + /* Realize for core pointer failed. Unrealize everything from + * previous screens. + */ + while (--nscr >= 0) + { + pscr = screenInfo.screens[nscr]; + /* now unrealize all devices on previous screens */ + ( *pscr->UnrealizeCursor)(inputInfo.pointer, pscr, pCurs); + + pDevIt = inputInfo.devices; + while (pDevIt) + { + if (DevHasCursor(pDevIt)) + ( *pscr->UnrealizeCursor)(pDevIt, pscr, pCurs); + pDevIt = pDevIt->next; + } + ( *pscr->UnrealizeCursor)(pDev, pscr, pCurs); + } + FreeCursorBits(bits); + xfree(pCurs); + return BadAlloc; + } + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { if (DevHasCursor(pDev)) @@ -459,10 +486,15 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, ( *pscr->UnrealizeCursor)(pDevIt, pscr, pCurs); pDevIt = pDevIt->next; } + + (*pscr->UnrealizeCursor)(inputInfo.pointer, pscr, pCurs); + while (--nscr >= 0) { pscr = screenInfo.screens[nscr]; /* now unrealize all devices on previous screens */ + ( *pscr->UnrealizeCursor)(inputInfo.pointer, pscr, pCurs); + pDevIt = inputInfo.devices; while (pDevIt) { diff --git a/dix/devices.c b/dix/devices.c index 919558658..9e0879450 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -347,7 +347,15 @@ InitCoreDevices() FatalError("Couldn't allocate keyboard devPrivates\n"); dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL; (void)ActivateDevice(dev); + + /* Enable device, and then remove it from the device list. Virtual + * devices are kept separate, not in the standard device list. + */ + if (dev->inited && dev->startup) + EnableDevice(dev); + inputInfo.off_devices = inputInfo.devices = NULL; inputInfo.keyboard = dev; + inputInfo.keyboard->next = NULL; } if (!inputInfo.pointer) { @@ -372,7 +380,17 @@ InitCoreDevices() dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL; InitializeSprite(dev, NullWindow); (void)ActivateDevice(dev); + + /* Enable device, and then remove it from the device list. Virtual + * devices are kept separate, not in the standard device list. + */ + if (dev->inited && dev->startup) + EnableDevice(dev); + inputInfo.off_devices = inputInfo.devices = NULL; inputInfo.pointer = dev; + inputInfo.pointer->next = NULL; + + /* the core keyboard is initialised by now. set the keyboard's sprite * to the core pointer's sprite. */ PairDevices(pairingClient, inputInfo.pointer, inputInfo.keyboard); @@ -382,7 +400,7 @@ InitCoreDevices() int InitAndStartDevices() { - register DeviceIntPtr dev, next; + DeviceIntPtr dev, next; for (dev = inputInfo.off_devices; dev; dev = dev->next) { DebugF("(dix) initialising device %d\n", dev->id); @@ -395,21 +413,25 @@ InitAndStartDevices() if (dev->inited && dev->startup) (void)EnableDevice(dev); } - for (dev = inputInfo.devices; - dev && (dev != inputInfo.keyboard); - dev = dev->next) - if (!dev || (dev != inputInfo.keyboard)) { + + if (!inputInfo.keyboard) { ErrorF("No core keyboard\n"); return BadImplementation; } - for (dev = inputInfo.devices; - dev && (dev != inputInfo.pointer); - dev = dev->next) - ; - if (!dev || (dev != inputInfo.pointer)) { + if (!inputInfo.pointer) { ErrorF("No core pointer\n"); return BadImplementation; } + + /* All of the devices are started up now. Try to pair each keyboard with a + * real pointer, if possible. */ + for (dev = inputInfo.devices; dev; dev = dev->next) + { + if (!DevHasCursor(dev)) + PairDevices(NULL, GuessFreePointerDevice(), dev); + } + + return Success; } @@ -2043,7 +2065,7 @@ GuessFreePointerDevice() while(it) { /* found device with a sprite? */ - if (it != inputInfo.pointer && it->spriteOwner) + if (it->spriteOwner) { lastRealPtr = it; @@ -2057,11 +2079,9 @@ GuessFreePointerDevice() it2 = it2->next; } - if (it2) - break; - /* woohoo! no pairing set up for 'it' yet */ - return it; + if (!it2) + return it; } it = it->next; } diff --git a/dix/events.c b/dix/events.c index 5be923a27..23d5f22fc 100644 --- a/dix/events.c +++ b/dix/events.c @@ -247,7 +247,7 @@ static int spriteTraceGood; _X_EXPORT Bool DevHasCursor(DeviceIntPtr pDev) { - return pDev->spriteOwner; + return (pDev != inputInfo.pointer && pDev->spriteOwner); } #ifdef XEVIE @@ -1663,6 +1663,8 @@ DeliverEventsToWindow(DeviceIntPtr pDev, register WindowPtr pWin, xEvent this mask is the mask of the grab. */ int type = pEvents->u.u.type; + /* if a is denied, we return 0. This could cause the caller to + * traverse the parent. May be bad! (whot) */ if (!ACDeviceAllowed(pWin, pDev)) return 0; @@ -1727,6 +1729,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, register WindowPtr pWin, xEvent tempGrab.pointerMode = GrabModeAsync; tempGrab.confineTo = NullWindow; tempGrab.cursor = NullCursor; + tempGrab.coreGrab = True; (*inputInfo.pointer->ActivateGrab)(pDev, &tempGrab, currentTime, TRUE); } @@ -1868,8 +1871,8 @@ FixUpEventFromWindow( } int -DeliverDeviceEvents(register WindowPtr pWin, register xEvent *xE, GrabPtr grab, - register WindowPtr stopAt, DeviceIntPtr dev, int count) +DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab, + WindowPtr stopAt, DeviceIntPtr dev, int count) { Window child = None; int type = xE->u.u.type; @@ -1878,7 +1881,7 @@ DeliverDeviceEvents(register WindowPtr pWin, register xEvent *xE, GrabPtr grab, if (type & EXTENSION_EVENT_BASE) { - register OtherInputMasks *inputMasks; + OtherInputMasks *inputMasks; int mskidx = dev->id; inputMasks = wOtherInputMasks(pWin); @@ -2199,6 +2202,8 @@ DefineInitialRootWindow(register WindowPtr win) #endif ROOT = win; + InitializeSprite(inputInfo.pointer, win); + while (pDev) { if (DevHasCursor(pDev)) @@ -2274,7 +2279,6 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin) REGION_NULL(pScreen, &pSprite->Reg2); } #endif - } /* @@ -3943,6 +3947,7 @@ ProcGrabPointer(ClientPtr client) tempGrab.keyboardMode = stuff->keyboardMode; tempGrab.pointerMode = stuff->pointerMode; tempGrab.device = device; + tempGrab.coreGrab = True; (*device->ActivateGrab)(device, &tempGrab, time, FALSE); if (oldCursor) FreeCursor (oldCursor, (Cursor)0); diff --git a/include/input.h b/include/input.h index 433cc9419..ca81b1af6 100644 --- a/include/input.h +++ b/include/input.h @@ -455,6 +455,8 @@ extern DeviceIntPtr GetPairedPointer(DeviceIntPtr kbd); extern Bool RegisterPairingClient(ClientPtr client); extern Bool UnregisterPairingClient(ClientPtr client); +extern DeviceIntPtr GuessFreePointerDevice(); + /* Window/device based access control */ extern Bool ACRegisterClient(ClientPtr client); extern Bool ACUnregisterClient(ClientPtr client); diff --git a/mi/mipointer.c b/mi/mipointer.c index 5df7a0ab6..edb5c5fec 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -302,7 +302,7 @@ miPointerWarpCursor (pDev, pScreen, x, y) if (GenerateEvent) { - miPointerMoved (pDev, pScreen, x, y, GetTimeInMillis()); + miPointerMove (pDev, pScreen, x, y, GetTimeInMillis()); } else { @@ -346,8 +346,8 @@ miPointerUpdateSprite (DeviceIntPtr pDev) int x, y, devx, devy; miPointerPtr pPointer; - if (!pDev || - !(pDev->coreEvents || pDev == inputInfo.pointer || pDev->isMPDev)) + if (!pDev || pDev == inputInfo.pointer || + !(pDev->coreEvents || pDev->isMPDev)) return; pPointer = MIPOINTER(pDev); @@ -540,7 +540,7 @@ miPointerMove (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, unsigned long int i, nevents; int valuators[2]; - miPointerMoved(inputInfo.pointer, pScreen, x, y, time); + miPointerMoved(pDev, pScreen, x, y, time); /* generate motion notify */ valuators[0] = x; diff --git a/mi/mispritest.h b/mi/mispritest.h index 8c8cd5314..8cc206420 100644 --- a/mi/mispritest.h +++ b/mi/mispritest.h @@ -44,7 +44,6 @@ in this Software without prior written authorization from The Open Group. # include "damage.h" typedef struct { - int id; /* id, corresponds with device id */ CursorPtr pCursor; int x; /* cursor hotspot */ int y; |