dix: Fix wrong cursor refcount.
Calloc cursor struct to ensure devPrivates are zeroed out and don't increase the refcnt for devices automatically when allocating a new cursor. Use new DeviceIsPointerType() to detect if device is a pointer _before_ device has been activated and can thus be identified and set up grab functions accordingly. This way we can increase the refcnt when we get a pointer grab.
This commit is contained in:
parent
20e4314b17
commit
63d8f01819
|
@ -101,7 +101,7 @@ RegisterOtherDevice(DeviceIntPtr device)
|
||||||
device->public.realInputProc = ProcessOtherEvent;
|
device->public.realInputProc = ProcessOtherEvent;
|
||||||
(device)->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
|
(device)->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
|
||||||
(device)->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
|
(device)->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
|
||||||
if (IsPointerDevice(device))
|
if (DeviceIsPointerType(device))
|
||||||
{
|
{
|
||||||
(device)->coreGrab.ActivateGrab = ActivatePointerGrab;
|
(device)->coreGrab.ActivateGrab = ActivatePointerGrab;
|
||||||
(device)->coreGrab.DeactivateGrab = DeactivatePointerGrab;
|
(device)->coreGrab.DeactivateGrab = DeactivatePointerGrab;
|
||||||
|
|
16
Xi/extinit.c
16
Xi/extinit.c
|
@ -983,6 +983,22 @@ IResetProc(ExtensionEntry * unused)
|
||||||
RestoreExtensionEvents();
|
RestoreExtensionEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************
|
||||||
|
*
|
||||||
|
* Returns TRUE if the device has some sort of pointer type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
Bool
|
||||||
|
DeviceIsPointerType(DeviceIntPtr dev)
|
||||||
|
{
|
||||||
|
if (dev_type[1].type == dev->type)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
*
|
*
|
||||||
* Assign an id and type to an input device.
|
* Assign an id and type to an input device.
|
||||||
|
|
47
dix/cursor.c
47
dix/cursor.c
|
@ -179,7 +179,7 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb,
|
||||||
ScreenPtr pscr;
|
ScreenPtr pscr;
|
||||||
DeviceIntPtr pDev;
|
DeviceIntPtr pDev;
|
||||||
|
|
||||||
pCurs = (CursorPtr)xalloc(sizeof(CursorRec) + sizeof(CursorBits));
|
pCurs = (CursorPtr)xcalloc(sizeof(CursorRec) + sizeof(CursorBits), 1);
|
||||||
if (!pCurs)
|
if (!pCurs)
|
||||||
{
|
{
|
||||||
xfree(psrcbits);
|
xfree(psrcbits);
|
||||||
|
@ -196,7 +196,7 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb,
|
||||||
bits->height = cm->height;
|
bits->height = cm->height;
|
||||||
bits->xhot = cm->xhot;
|
bits->xhot = cm->xhot;
|
||||||
bits->yhot = cm->yhot;
|
bits->yhot = cm->yhot;
|
||||||
pCurs->refcnt = 0;
|
pCurs->refcnt = 1;
|
||||||
CheckForEmptyMask(bits);
|
CheckForEmptyMask(bits);
|
||||||
|
|
||||||
pCurs->bits = bits;
|
pCurs->bits = bits;
|
||||||
|
@ -215,6 +215,8 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* realize the cursor for every screen
|
* realize the cursor for every screen
|
||||||
|
* Do not change the refcnt, this will be changed when ChangeToCursor
|
||||||
|
* actually changes the sprite.
|
||||||
*/
|
*/
|
||||||
for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
|
for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
|
||||||
{
|
{
|
||||||
|
@ -223,7 +225,6 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb,
|
||||||
{
|
{
|
||||||
if (DevHasCursor(pDev))
|
if (DevHasCursor(pDev))
|
||||||
{
|
{
|
||||||
pCurs->refcnt++;
|
|
||||||
if (!( *pscr->RealizeCursor)(pDev, pscr, pCurs))
|
if (!( *pscr->RealizeCursor)(pDev, pscr, pCurs))
|
||||||
{
|
{
|
||||||
/* Realize failed for device pDev on screen pscr.
|
/* Realize failed for device pDev on screen pscr.
|
||||||
|
@ -325,7 +326,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
|
||||||
}
|
}
|
||||||
if (pShare)
|
if (pShare)
|
||||||
{
|
{
|
||||||
pCurs = (CursorPtr)xalloc(sizeof(CursorRec));
|
pCurs = (CursorPtr)xcalloc(sizeof(CursorRec), 1);
|
||||||
if (!pCurs)
|
if (!pCurs)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
bits = pShare->bits;
|
bits = pShare->bits;
|
||||||
|
@ -367,7 +368,8 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
|
||||||
}
|
}
|
||||||
if (sourcefont != maskfont)
|
if (sourcefont != maskfont)
|
||||||
{
|
{
|
||||||
pCurs = (CursorPtr)xalloc(sizeof(CursorRec) + sizeof(CursorBits));
|
pCurs =
|
||||||
|
(CursorPtr)xcalloc(sizeof(CursorRec) + sizeof(CursorBits), 1);
|
||||||
if (pCurs)
|
if (pCurs)
|
||||||
bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec));
|
bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec));
|
||||||
else
|
else
|
||||||
|
@ -375,9 +377,9 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pCurs = (CursorPtr)xalloc(sizeof(CursorRec));
|
pCurs = (CursorPtr)xcalloc(sizeof(CursorRec), 1);
|
||||||
if (pCurs)
|
if (pCurs)
|
||||||
bits = (CursorBitsPtr)xalloc(sizeof(CursorBits));
|
bits = (CursorBitsPtr)xcalloc(sizeof(CursorBits), 1);
|
||||||
else
|
else
|
||||||
bits = (CursorBitsPtr)NULL;
|
bits = (CursorBitsPtr)NULL;
|
||||||
}
|
}
|
||||||
|
@ -417,9 +419,10 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
|
||||||
sharedGlyphs = pShare;
|
sharedGlyphs = pShare;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckForEmptyMask(bits);
|
CheckForEmptyMask(bits);
|
||||||
pCurs->bits = bits;
|
pCurs->bits = bits;
|
||||||
pCurs->refcnt = 0;
|
pCurs->refcnt = 1;
|
||||||
#ifdef XFIXES
|
#ifdef XFIXES
|
||||||
pCurs->serialNumber = ++cursorSerial;
|
pCurs->serialNumber = ++cursorSerial;
|
||||||
pCurs->name = None;
|
pCurs->name = None;
|
||||||
|
@ -440,38 +443,10 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
|
||||||
{
|
{
|
||||||
pscr = screenInfo.screens[nscr];
|
pscr = screenInfo.screens[nscr];
|
||||||
|
|
||||||
pCurs->refcnt++;
|
|
||||||
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))
|
||||||
{
|
{
|
||||||
pCurs->refcnt++;
|
|
||||||
if (!( *pscr->RealizeCursor)(pDev, pscr, pCurs))
|
if (!( *pscr->RealizeCursor)(pDev, pscr, pCurs))
|
||||||
{
|
{
|
||||||
/* Realize failed for device pDev on screen pscr.
|
/* Realize failed for device pDev on screen pscr.
|
||||||
|
|
|
@ -4024,7 +4024,6 @@ ProcGrabPointer(ClientPtr client)
|
||||||
oldCursor = grab->cursor;
|
oldCursor = grab->cursor;
|
||||||
}
|
}
|
||||||
tempGrab.cursor = cursor;
|
tempGrab.cursor = cursor;
|
||||||
/* FIXME: refcnt?? */
|
|
||||||
tempGrab.resource = client->clientAsMask;
|
tempGrab.resource = client->clientAsMask;
|
||||||
tempGrab.ownerEvents = stuff->ownerEvents;
|
tempGrab.ownerEvents = stuff->ownerEvents;
|
||||||
tempGrab.eventMask = stuff->eventMask;
|
tempGrab.eventMask = stuff->eventMask;
|
||||||
|
|
|
@ -174,7 +174,7 @@ xf86ActivateDevice(LocalDevicePtr local)
|
||||||
dev->spriteInfo->spriteOwner = !(local->flags & XI86_SHARED_POINTER);
|
dev->spriteInfo->spriteOwner = !(local->flags & XI86_SHARED_POINTER);
|
||||||
|
|
||||||
#ifdef XKB
|
#ifdef XKB
|
||||||
if (!IsPointerDevice(dev))
|
if (!DeviceIsPointerType(dev))
|
||||||
{
|
{
|
||||||
/* FIXME: that's not the nice way to do it. XKB wraps the previously
|
/* FIXME: that's not the nice way to do it. XKB wraps the previously
|
||||||
* set procs, so if we don't have them here, our event will disappear
|
* set procs, so if we don't have them here, our event will disappear
|
||||||
|
|
|
@ -142,6 +142,11 @@ IResetProc(
|
||||||
ExtensionEntry * /* unused */
|
ExtensionEntry * /* unused */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Bool
|
||||||
|
DeviceIsPointerType(
|
||||||
|
DeviceIntPtr dev
|
||||||
|
);
|
||||||
|
|
||||||
void
|
void
|
||||||
AssignTypeAndName (
|
AssignTypeAndName (
|
||||||
DeviceIntPtr /* dev */,
|
DeviceIntPtr /* dev */,
|
||||||
|
|
Loading…
Reference in New Issue