mi: added DevToSprite() conversion function

fixed miSpriteRealize to use passed pDev argument instead of looping.

dix:    changed sprite dependency and added MPX functionality to parts of
        events.c (XineramaChangeToCursor, XineramaCheckPhysLimits,
        XineramaConstrainCursor)

Xi:	fix: accessing other->buttons for keyboard segfaulted the server
This commit is contained in:
Peter Hutterer 2006-11-22 15:27:16 +10:30 committed by Peter Hutterer
parent efd4f3c6ff
commit 70383105de
5 changed files with 115 additions and 43 deletions

View File

@ -1,4 +1,22 @@
MPX Changelog file
== 22.11.06 ==
mi: added DevToSprite() conversion function
fixed miSpriteRealize to use passed pDev argument instead of looping.
dix: changed sprite dependency and added MPX functionality to parts of
events.c (XineramaChangeToCursor, XineramaCheckPhysLimits,
XineramaConstrainCursor)
Xi: fix: accessing other->buttons for keyboard segfaulted the server
Files:
mi/misprite.c
mi/mipointer.c
dix/events.c
Xi/exevents.c
== 21.11.06 ==
mi: added MPX to miSpriteReportDamage
added id field to miCursorInfoPtr, required to pass through to miDC

View File

@ -125,11 +125,7 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
key = xE->u.u.detail;
NoticeEventTime(xE);
xE->u.keyButtonPointer.state = inputInfo.keyboard->key->state |
#ifdef MPX
other->button->state;
#else
inputInfo.pointer->button->state;
#endif
inputInfo.pointer->button->state; /* FIXME: change for MPX */
bit = 1 << (key & 7);
}
if (DeviceEventCallback) {

View File

@ -388,10 +388,19 @@ XineramaSetCursorPosition(
static void
XineramaConstrainCursor(void)
XineramaConstrainCursor(DeviceIntPtr pDev)
{
ScreenPtr pScreen = sprite->screen;
BoxRec newBox = sprite->physLimits;
SpritePtr pSprite = sprite;
ScreenPtr pScreen;
BoxRec newBox;
#ifdef MPX
if (IsMPDev(pDev))
pSprite = &mpsprites[pDev->id];
#endif
pScreen = pSprite->screen;
newBox = pSprite->physLimits;
/* Translate the constraining box to the screen
the sprite is actually on */
@ -400,40 +409,46 @@ XineramaConstrainCursor(void)
newBox.y1 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
newBox.y2 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
(* pScreen->ConstrainCursor)(inputInfo.pointer, pScreen, &newBox);
(* pScreen->ConstrainCursor)(pDev, pScreen, &newBox);
}
static void
XineramaCheckPhysLimits(
DeviceIntPtr pDev,
CursorPtr cursor,
Bool generateEvents
){
HotSpot new;
SpritePtr pSprite = sprite;
if (!cursor)
return;
#ifdef MPX
if (IsMPDev(pDev))
pSprite = &mpsprites[pDev->id];
#endif
new = sprite->hotPhys;
new = pSprite->hotPhys;
/* I don't care what the DDX has to say about it */
sprite->physLimits = sprite->hotLimits;
pSprite->physLimits = pSprite->hotLimits;
/* constrain the pointer to those limits */
if (new.x < sprite->physLimits.x1)
new.x = sprite->physLimits.x1;
if (new.x < pSprite->physLimits.x1)
new.x = pSprite->physLimits.x1;
else
if (new.x >= sprite->physLimits.x2)
new.x = sprite->physLimits.x2 - 1;
if (new.y < sprite->physLimits.y1)
new.y = sprite->physLimits.y1;
if (new.x >= pSprite->physLimits.x2)
new.x = pSprite->physLimits.x2 - 1;
if (new.y < pSprite->physLimits.y1)
new.y = pSprite->physLimits.y1;
else
if (new.y >= sprite->physLimits.y2)
new.y = sprite->physLimits.y2 - 1;
if (new.y >= pSprite->physLimits.y2)
new.y = pSprite->physLimits.y2 - 1;
if (sprite->hotShape) /* more work if the shape is a mess */
ConfineToShape(inputInfo.pointer, sprite->hotShape, &new.x, &new.y);
if (pSprite->hotShape) /* more work if the shape is a mess */
ConfineToShape(pDev, pSprite->hotShape, &new.x, &new.y);
if((new.x != sprite->hotPhys.x) || (new.y != sprite->hotPhys.y))
if((new.x != pSprite->hotPhys.x) || (new.y != pSprite->hotPhys.y))
{
XineramaSetCursorPosition (new.x, new.y, generateEvents);
if (!generateEvents)
@ -441,7 +456,7 @@ XineramaCheckPhysLimits(
}
/* Tell DDX what the limits are */
XineramaConstrainCursor();
XineramaConstrainCursor(pDev);
}
@ -655,7 +670,8 @@ XineramaConfineCursorToWindow(WindowPtr pWin, Bool generateEvents)
sprite->confined = FALSE;
sprite->confineWin = (pWin == WindowTable[0]) ? NullWindow : pWin;
XineramaCheckPhysLimits(sprite->current, generateEvents);
XineramaCheckPhysLimits(inputInfo.pointer, sprite->current,
generateEvents);
}
}
@ -663,15 +679,22 @@ XineramaConfineCursorToWindow(WindowPtr pWin, Bool generateEvents)
static void
XineramaChangeToCursor(DeviceIntPtr pDev, CursorPtr cursor)
{
if (cursor != sprite->current)
SpritePtr pSprite = sprite;
#ifdef MPX
if (IsMPDev(pDev))
pSprite = &mpsprites[pDev->id];
#endif
if (cursor != pSprite->current)
{
if ((sprite->current->bits->xhot != cursor->bits->xhot) ||
(sprite->current->bits->yhot != cursor->bits->yhot))
XineramaCheckPhysLimits(cursor, FALSE);
(*sprite->screen->DisplayCursor)(sprite->screen, cursor);
FreeCursor(sprite->current, (Cursor)0);
sprite->current = cursor;
sprite->current->refcnt++;
if ((pSprite->current->bits->xhot != cursor->bits->xhot) ||
(pSprite->current->bits->yhot != cursor->bits->yhot))
XineramaCheckPhysLimits(pDev, cursor, FALSE);
(*pSprite->screen->DisplayCursor)(pSprite->screen, cursor);
FreeCursor(pSprite->current, (Cursor)0);
pSprite->current = cursor;
pSprite->current->refcnt++;
}
}

View File

@ -227,8 +227,18 @@ miPointerRealizeCursor (pScreen, pCursor)
DeviceIntPtr pDev = inputInfo.pointer;
SetupScreen(pScreen);
#ifdef MPX
pDev = inputInfo.devices;
while(pDev)
{
if (pDev != inputInfo.keyboard)
(*pScreenPriv->spriteFuncs->RealizeCursor) (pDev, pScreen, pCursor);
pDev = pDev->next;
}
return TRUE;
#else
return (*pScreenPriv->spriteFuncs->RealizeCursor) (pDev, pScreen, pCursor);
#endif
}
static Bool
@ -239,7 +249,18 @@ miPointerUnrealizeCursor (pScreen, pCursor)
DeviceIntPtr pDev = inputInfo.pointer;
SetupScreen(pScreen);
#ifdef MPX
pDev = inputInfo.devices;
while(pDev)
{
if (pDev != inputInfo.keyboard)
(*pScreenPriv->spriteFuncs->UnrealizeCursor) (pDev, pScreen, pCursor);
pDev = pDev->next;
}
return TRUE;
#else
return (*pScreenPriv->spriteFuncs->UnrealizeCursor) (pDev, pScreen, pCursor);
#endif
}
static Bool

View File

@ -67,8 +67,11 @@ in this Software without prior written authorization from The Open Group.
#ifdef MPX
# include "inputstr.h" /* for MAX_DEVICES */
static miCursorInfoPtr DevToSprite(DeviceIntPtr pDev, ScreenPtr pScreen);
#endif
#define SPRITE_DEBUG_ENABLE 1
#if SPRITE_DEBUG_ENABLE
#define SPRITE_DEBUG(x) ErrorF x
@ -907,16 +910,9 @@ miSpriteRealizeCursor (pDev, pScreen, pCursor)
pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
#ifdef MPX
{
int mpCursorIdx = 0;
while (mpCursorIdx < MAX_DEVICES)
{
miCursorInfoPtr pMPCursor = &pScreenPriv->mpCursors[mpCursorIdx];
if (pCursor == pMPCursor->pCursor)
pMPCursor->checkPixels = TRUE;
mpCursorIdx++;
}
miCursorInfoPtr pMPCursor = DevToSprite(pDev, pScreen);
if (pCursor == pMPCursor->pCursor)
pMPCursor->checkPixels = TRUE;
}
#else
if (pCursor == pScreenPriv->cp->pCursor)
@ -1174,3 +1170,21 @@ miSpriteComputeSaved (pDevCursor, pScreen)
pDevCursor->saved.x2 = pDevCursor->saved.x1 + w + wpad * 2;
pDevCursor->saved.y2 = pDevCursor->saved.y1 + h + hpad * 2;
}
#ifdef MPX
static miCursorInfoPtr DevToSprite(DeviceIntPtr pDev, ScreenPtr pScreen)
{
miSpriteScreenPtr pScreenPriv;
pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
int mpCursorIdx = 0;
while(mpCursorIdx < MAX_DEVICES)
{
miCursorInfoPtr pMPCursor = &pScreenPriv->mpCursors[mpCursorIdx];
if (pMPCursor->id == pDev->id)
return pMPCursor;
mpCursorIdx++;
}
return pScreenPriv->cp;
}
#endif