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 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 == == 21.11.06 ==
mi: added MPX to miSpriteReportDamage mi: added MPX to miSpriteReportDamage
added id field to miCursorInfoPtr, required to pass through to miDC 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; key = xE->u.u.detail;
NoticeEventTime(xE); NoticeEventTime(xE);
xE->u.keyButtonPointer.state = inputInfo.keyboard->key->state | xE->u.keyButtonPointer.state = inputInfo.keyboard->key->state |
#ifdef MPX inputInfo.pointer->button->state; /* FIXME: change for MPX */
other->button->state;
#else
inputInfo.pointer->button->state;
#endif
bit = 1 << (key & 7); bit = 1 << (key & 7);
} }
if (DeviceEventCallback) { if (DeviceEventCallback) {

View File

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

View File

@ -227,8 +227,18 @@ miPointerRealizeCursor (pScreen, pCursor)
DeviceIntPtr pDev = inputInfo.pointer; DeviceIntPtr pDev = inputInfo.pointer;
SetupScreen(pScreen); 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); return (*pScreenPriv->spriteFuncs->RealizeCursor) (pDev, pScreen, pCursor);
#endif
} }
static Bool static Bool
@ -239,7 +249,18 @@ miPointerUnrealizeCursor (pScreen, pCursor)
DeviceIntPtr pDev = inputInfo.pointer; DeviceIntPtr pDev = inputInfo.pointer;
SetupScreen(pScreen); 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); return (*pScreenPriv->spriteFuncs->UnrealizeCursor) (pDev, pScreen, pCursor);
#endif
} }
static Bool static Bool

View File

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