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.
This commit is contained in:
Peter Hutterer 2007-03-07 18:19:20 +10:30
parent 39aa791771
commit 537bc2ead4
7 changed files with 94 additions and 32 deletions

View File

@ -104,12 +104,12 @@ RegisterOtherDevice(DeviceIntPtr device)
} }
/*ARGSUSED*/ void /*ARGSUSED*/ void
ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count)
{ {
register BYTE *kptr; BYTE *kptr;
register int i; int i;
register CARD16 modifiers; CARD16 modifiers;
register CARD16 mask; CARD16 mask;
GrabPtr grab = other->grab; GrabPtr grab = other->grab;
Bool deactivateDeviceGrab = FALSE; Bool deactivateDeviceGrab = FALSE;
int key = 0, bit = 0, rootX, rootY; 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; deactivateDeviceGrab = TRUE;
} else if (xE->u.u.type == DeviceButtonPress) { } else if (xE->u.u.type == DeviceButtonPress) {
if (!b) if (!b)
@ -267,7 +269,9 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
if (xE->u.u.detail <= 5) if (xE->u.u.detail <= 5)
b->state &= ~((Button1Mask >> 1) << xE->u.u.detail); b->state &= ~((Button1Mask >> 1) << xE->u.u.detail);
SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify); SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify);
if (!b->state && other->fromPassiveGrab) if (!b->state
&& other->fromPassiveGrab
&& !other->grab->coreGrab)
deactivateDeviceGrab = TRUE; deactivateDeviceGrab = TRUE;
} else if (xE->u.u.type == ProximityIn) } else if (xE->u.u.type == ProximityIn)
other->valuator->mode &= ~OutOfProximity; other->valuator->mode &= ~OutOfProximity;

View File

@ -440,6 +440,33 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
for (nscr = 0; nscr < screenInfo.numScreens; nscr++) for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
{ {
pscr = screenInfo.screens[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) for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
{ {
if (DevHasCursor(pDev)) if (DevHasCursor(pDev))
@ -459,10 +486,15 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
( *pscr->UnrealizeCursor)(pDevIt, pscr, pCurs); ( *pscr->UnrealizeCursor)(pDevIt, pscr, pCurs);
pDevIt = pDevIt->next; pDevIt = pDevIt->next;
} }
(*pscr->UnrealizeCursor)(inputInfo.pointer, pscr, pCurs);
while (--nscr >= 0) while (--nscr >= 0)
{ {
pscr = screenInfo.screens[nscr]; pscr = screenInfo.screens[nscr];
/* now unrealize all devices on previous screens */ /* now unrealize all devices on previous screens */
( *pscr->UnrealizeCursor)(inputInfo.pointer, pscr, pCurs);
pDevIt = inputInfo.devices; pDevIt = inputInfo.devices;
while (pDevIt) while (pDevIt)
{ {

View File

@ -347,7 +347,15 @@ InitCoreDevices()
FatalError("Couldn't allocate keyboard devPrivates\n"); FatalError("Couldn't allocate keyboard devPrivates\n");
dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL; dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
(void)ActivateDevice(dev); (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 = dev;
inputInfo.keyboard->next = NULL;
} }
if (!inputInfo.pointer) { if (!inputInfo.pointer) {
@ -372,7 +380,17 @@ InitCoreDevices()
dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL; dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
InitializeSprite(dev, NullWindow); InitializeSprite(dev, NullWindow);
(void)ActivateDevice(dev); (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 = dev;
inputInfo.pointer->next = NULL;
/* the core keyboard is initialised by now. set the keyboard's sprite /* the core keyboard is initialised by now. set the keyboard's sprite
* to the core pointer's sprite. */ * to the core pointer's sprite. */
PairDevices(pairingClient, inputInfo.pointer, inputInfo.keyboard); PairDevices(pairingClient, inputInfo.pointer, inputInfo.keyboard);
@ -382,7 +400,7 @@ InitCoreDevices()
int int
InitAndStartDevices() InitAndStartDevices()
{ {
register DeviceIntPtr dev, next; DeviceIntPtr dev, next;
for (dev = inputInfo.off_devices; dev; dev = dev->next) { for (dev = inputInfo.off_devices; dev; dev = dev->next) {
DebugF("(dix) initialising device %d\n", dev->id); DebugF("(dix) initialising device %d\n", dev->id);
@ -395,21 +413,25 @@ InitAndStartDevices()
if (dev->inited && dev->startup) if (dev->inited && dev->startup)
(void)EnableDevice(dev); (void)EnableDevice(dev);
} }
for (dev = inputInfo.devices;
dev && (dev != inputInfo.keyboard); if (!inputInfo.keyboard) {
dev = dev->next)
if (!dev || (dev != inputInfo.keyboard)) {
ErrorF("No core keyboard\n"); ErrorF("No core keyboard\n");
return BadImplementation; return BadImplementation;
} }
for (dev = inputInfo.devices; if (!inputInfo.pointer) {
dev && (dev != inputInfo.pointer);
dev = dev->next)
;
if (!dev || (dev != inputInfo.pointer)) {
ErrorF("No core pointer\n"); ErrorF("No core pointer\n");
return BadImplementation; 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; return Success;
} }
@ -2043,7 +2065,7 @@ GuessFreePointerDevice()
while(it) while(it)
{ {
/* found device with a sprite? */ /* found device with a sprite? */
if (it != inputInfo.pointer && it->spriteOwner) if (it->spriteOwner)
{ {
lastRealPtr = it; lastRealPtr = it;
@ -2057,11 +2079,9 @@ GuessFreePointerDevice()
it2 = it2->next; it2 = it2->next;
} }
if (it2)
break;
/* woohoo! no pairing set up for 'it' yet */ /* woohoo! no pairing set up for 'it' yet */
return it; if (!it2)
return it;
} }
it = it->next; it = it->next;
} }

View File

@ -247,7 +247,7 @@ static int spriteTraceGood;
_X_EXPORT Bool _X_EXPORT Bool
DevHasCursor(DeviceIntPtr pDev) DevHasCursor(DeviceIntPtr pDev)
{ {
return pDev->spriteOwner; return (pDev != inputInfo.pointer && pDev->spriteOwner);
} }
#ifdef XEVIE #ifdef XEVIE
@ -1663,6 +1663,8 @@ DeliverEventsToWindow(DeviceIntPtr pDev, register WindowPtr pWin, xEvent
this mask is the mask of the grab. */ this mask is the mask of the grab. */
int type = pEvents->u.u.type; 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)) if (!ACDeviceAllowed(pWin, pDev))
return 0; return 0;
@ -1727,6 +1729,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, register WindowPtr pWin, xEvent
tempGrab.pointerMode = GrabModeAsync; tempGrab.pointerMode = GrabModeAsync;
tempGrab.confineTo = NullWindow; tempGrab.confineTo = NullWindow;
tempGrab.cursor = NullCursor; tempGrab.cursor = NullCursor;
tempGrab.coreGrab = True;
(*inputInfo.pointer->ActivateGrab)(pDev, &tempGrab, (*inputInfo.pointer->ActivateGrab)(pDev, &tempGrab,
currentTime, TRUE); currentTime, TRUE);
} }
@ -1868,8 +1871,8 @@ FixUpEventFromWindow(
} }
int int
DeliverDeviceEvents(register WindowPtr pWin, register xEvent *xE, GrabPtr grab, DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab,
register WindowPtr stopAt, DeviceIntPtr dev, int count) WindowPtr stopAt, DeviceIntPtr dev, int count)
{ {
Window child = None; Window child = None;
int type = xE->u.u.type; int type = xE->u.u.type;
@ -1878,7 +1881,7 @@ DeliverDeviceEvents(register WindowPtr pWin, register xEvent *xE, GrabPtr grab,
if (type & EXTENSION_EVENT_BASE) if (type & EXTENSION_EVENT_BASE)
{ {
register OtherInputMasks *inputMasks; OtherInputMasks *inputMasks;
int mskidx = dev->id; int mskidx = dev->id;
inputMasks = wOtherInputMasks(pWin); inputMasks = wOtherInputMasks(pWin);
@ -2199,6 +2202,8 @@ DefineInitialRootWindow(register WindowPtr win)
#endif #endif
ROOT = win; ROOT = win;
InitializeSprite(inputInfo.pointer, win);
while (pDev) while (pDev)
{ {
if (DevHasCursor(pDev)) if (DevHasCursor(pDev))
@ -2274,7 +2279,6 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
REGION_NULL(pScreen, &pSprite->Reg2); REGION_NULL(pScreen, &pSprite->Reg2);
} }
#endif #endif
} }
/* /*
@ -3943,6 +3947,7 @@ ProcGrabPointer(ClientPtr client)
tempGrab.keyboardMode = stuff->keyboardMode; tempGrab.keyboardMode = stuff->keyboardMode;
tempGrab.pointerMode = stuff->pointerMode; tempGrab.pointerMode = stuff->pointerMode;
tempGrab.device = device; tempGrab.device = device;
tempGrab.coreGrab = True;
(*device->ActivateGrab)(device, &tempGrab, time, FALSE); (*device->ActivateGrab)(device, &tempGrab, time, FALSE);
if (oldCursor) if (oldCursor)
FreeCursor (oldCursor, (Cursor)0); FreeCursor (oldCursor, (Cursor)0);

View File

@ -455,6 +455,8 @@ extern DeviceIntPtr GetPairedPointer(DeviceIntPtr kbd);
extern Bool RegisterPairingClient(ClientPtr client); extern Bool RegisterPairingClient(ClientPtr client);
extern Bool UnregisterPairingClient(ClientPtr client); extern Bool UnregisterPairingClient(ClientPtr client);
extern DeviceIntPtr GuessFreePointerDevice();
/* Window/device based access control */ /* Window/device based access control */
extern Bool ACRegisterClient(ClientPtr client); extern Bool ACRegisterClient(ClientPtr client);
extern Bool ACUnregisterClient(ClientPtr client); extern Bool ACUnregisterClient(ClientPtr client);

View File

@ -302,7 +302,7 @@ miPointerWarpCursor (pDev, pScreen, x, y)
if (GenerateEvent) if (GenerateEvent)
{ {
miPointerMoved (pDev, pScreen, x, y, GetTimeInMillis()); miPointerMove (pDev, pScreen, x, y, GetTimeInMillis());
} }
else else
{ {
@ -346,8 +346,8 @@ miPointerUpdateSprite (DeviceIntPtr pDev)
int x, y, devx, devy; int x, y, devx, devy;
miPointerPtr pPointer; miPointerPtr pPointer;
if (!pDev || if (!pDev || pDev == inputInfo.pointer ||
!(pDev->coreEvents || pDev == inputInfo.pointer || pDev->isMPDev)) !(pDev->coreEvents || pDev->isMPDev))
return; return;
pPointer = MIPOINTER(pDev); pPointer = MIPOINTER(pDev);
@ -540,7 +540,7 @@ miPointerMove (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, unsigned long
int i, nevents; int i, nevents;
int valuators[2]; int valuators[2];
miPointerMoved(inputInfo.pointer, pScreen, x, y, time); miPointerMoved(pDev, pScreen, x, y, time);
/* generate motion notify */ /* generate motion notify */
valuators[0] = x; valuators[0] = x;

View File

@ -44,7 +44,6 @@ in this Software without prior written authorization from The Open Group.
# include "damage.h" # include "damage.h"
typedef struct { typedef struct {
int id; /* id, corresponds with device id */
CursorPtr pCursor; CursorPtr pCursor;
int x; /* cursor hotspot */ int x; /* cursor hotspot */
int y; int y;