From 9fc94edfe3df4c4a84ad70714c0a4ef8bbf57fc9 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 16 May 2008 16:59:34 +0930 Subject: [PATCH 1/6] Xext: fix typo in condition. Fall-out from dc3aba8a559d4304844ee1cc306c577a63b82762. We must free the event if it is NOT an extension event. --- Xext/xtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xext/xtest.c b/Xext/xtest.c index 791f6a24d..a42faa791 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -500,7 +500,7 @@ ProcXTestFakeInput(client) xfree(master_event); } else (*dev->public.processInputProc)(ev, dev, nev); - if (extension) + if (!extension) xfree(ev); return client->noClientException; } From 5af90025fee6a92e7d94642978feed21f902d0cb Mon Sep 17 00:00:00 2001 From: Tiago Vignatti Date: Wed, 14 May 2008 02:45:49 -0300 Subject: [PATCH 2/6] Remove redundancy. The only function that cat set SWCursor before xf86DeviceCursorInitialize() is xf86InitCursor() when VCP and is created. Signed-off-by: Tiago Vignatti Signed-off-by: Peter Hutterer --- hw/xfree86/ramdac/xf86Cursor.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c index 4d64f6218..2d69074c8 100644 --- a/hw/xfree86/ramdac/xf86Cursor.c +++ b/hw/xfree86/ramdac/xf86Cursor.c @@ -464,11 +464,8 @@ xf86DeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) if (pDev != inputInfo.pointer) { - if (!ScreenPriv->SWCursor) - { ScreenPriv->spriteFuncs->SetCursor(inputInfo.pointer, pScreen, ScreenPriv->CurrentCursor, ScreenPriv->x, ScreenPriv->y); - } ScreenPriv->SWCursor = TRUE | XF86_FORCE_SW_CURSOR; } From 622d7c1d899a6146773a2ebd1d632a805f24025e Mon Sep 17 00:00:00 2001 From: Tiago Vignatti Date: Wed, 14 May 2008 14:49:09 -0300 Subject: [PATCH 3/6] Restructure and organize the code. It was removed and simplified some conditionals. We don't need test for pDev->isMaster inside xf86CursorSetCursor() because only MD enters there. In the last chunk, ScreenPriv fields were being assigned without need, so that code was wrapped inside the conditional to avoid it. I also tried to make the identation more sane in some parts that I touched. Signed-off-by: Tiago Vignatti Minor modification, part of the original patch led to cursors not being updated properly when controlled through XTest. Signed-off-by: Peter Hutterer --- hw/xfree86/ramdac/xf86Cursor.c | 59 +++++++++++++++------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c index 2d69074c8..50f8fb70d 100644 --- a/hw/xfree86/ramdac/xf86Cursor.c +++ b/hw/xfree86/ramdac/xf86Cursor.c @@ -299,43 +299,36 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs, xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( &pScreen->devPrivates, xf86CursorScreenKey); xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; - miPointerScreenPtr PointPriv; + miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, miPointerScreenKey); + + + if (pCurs == NullCursor) { /* means we're supposed to remove the cursor */ + if (ScreenPriv->SWCursor) + (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, NullCursor, + x, y); + else if (ScreenPriv->isUp) { + xf86SetCursor(pScreen, NullCursor, x, y); + ScreenPriv->isUp = FALSE; + } + return; + } /* only update for VCP, otherwise we get cursor jumps when removing a sprite. The second cursor is never HW rendered anyway. */ - if (pDev == inputInfo.pointer || - (!pDev->isMaster && pDev->u.master == inputInfo.pointer)) + if (pDev == inputInfo.pointer) { ScreenPriv->CurrentCursor = pCurs; ScreenPriv->x = x; ScreenPriv->y = y; ScreenPriv->CursorToRestore = NULL; + ScreenPriv->HotX = pCurs->bits->xhot; + ScreenPriv->HotY = pCurs->bits->yhot; } if (!infoPtr->pScrn->vtSema) ScreenPriv->SavedCursor = pCurs; - if (pCurs == NullCursor) { /* means we're supposed to remove the cursor */ - if (ScreenPriv->SWCursor) - (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, NullCursor, - x, y); - else if - (ScreenPriv->isUp) { - xf86SetCursor(pScreen, NullCursor, x, y); - ScreenPriv->isUp = FALSE; - } - return; - } - - if (pDev == inputInfo.pointer || - (!pDev->isMaster && pDev->u.master == inputInfo.pointer)) - { - ScreenPriv->HotX = pCurs->bits->xhot; - ScreenPriv->HotY = pCurs->bits->yhot; - } - - PointPriv = (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, - miPointerScreenKey); if (!(ScreenPriv->SWCursor & XF86_FORCE_SW_CURSOR)) { if (infoPtr->pScrn->vtSema && (ScreenPriv->ForceHWCursorCount || (( @@ -346,18 +339,18 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs, #endif (pCurs->bits->height <= infoPtr->MaxHeight) && (pCurs->bits->width <= infoPtr->MaxWidth) && - (!infoPtr->UseHWCursor || (*infoPtr->UseHWCursor)(pScreen, pCurs)))))) + (!infoPtr->UseHWCursor || (*infoPtr->UseHWCursor)(pScreen, pCurs)))))) { - if (ScreenPriv->SWCursor) /* remove the SW cursor */ - (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, NullCursor, x, y); + if (ScreenPriv->SWCursor) /* remove the SW cursor */ + (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, NullCursor, x, y); - xf86SetCursor(pScreen, pCurs, x, y); - ScreenPriv->SWCursor = FALSE; - ScreenPriv->isUp = TRUE; - PointPriv->waitForUpdate = !infoPtr->pScrn->silkenMouse; - return; - } + xf86SetCursor(pScreen, pCurs, x, y); + ScreenPriv->SWCursor = FALSE; + ScreenPriv->isUp = TRUE; + PointPriv->waitForUpdate = !infoPtr->pScrn->silkenMouse; + return; + } } From 48ba58feacedf9781db81c82adbb37197d9a5cd1 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 16 May 2008 19:22:32 +0930 Subject: [PATCH 4/6] mi: remove miPointerUpdate() -> replaced by miPointerUpdateSprite(). In the xnest and vfb DDX we don't need the call anyway, it's performed by mieqProcessInputEvent. --- hw/vfb/InitInput.c | 1 - hw/xnest/Events.c | 1 - mi/mipointer.c | 8 +------- mi/mipointer.h | 5 ----- 4 files changed, 1 insertion(+), 14 deletions(-) diff --git a/hw/vfb/InitInput.c b/hw/vfb/InitInput.c index 393698f35..3b001eea7 100644 --- a/hw/vfb/InitInput.c +++ b/hw/vfb/InitInput.c @@ -52,7 +52,6 @@ void ProcessInputEvents() { mieqProcessInputEvents(); - miPointerUpdate(); } void DDXRingBell(int volume, int pitch, int duration) diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c index 02ff27bdf..f7a551c17 100644 --- a/hw/xnest/Events.c +++ b/hw/xnest/Events.c @@ -49,7 +49,6 @@ void ProcessInputEvents() { mieqProcessInputEvents(); - miPointerUpdate(); } int diff --git a/mi/mipointer.c b/mi/mipointer.c index 2c226dc71..484947da9 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -374,17 +374,11 @@ miPointerWarpCursor (pDev, pScreen, x, y) */ /* - * miPointerUpdate + * miPointerUpdateSprite * * Syncronize the sprite with the cursor - called from ProcessInputEvents */ -void -miPointerUpdate () -{ - miPointerUpdateSprite(inputInfo.pointer); -} - void miPointerUpdateSprite (DeviceIntPtr pDev) { diff --git a/mi/mipointer.h b/mi/mipointer.h index 5cbf5270d..fccbfa04a 100644 --- a/mi/mipointer.h +++ b/mi/mipointer.h @@ -122,11 +122,6 @@ extern int miPointerGetMotionEvents( ScreenPtr /*pScreen*/ ); -/* Deprecated in favour of miPointerUpdateSprite. */ -extern void miPointerUpdate( - void -) _X_DEPRECATED; - /* Deprecated in favour of miSetPointerPosition. */ extern void miPointerDeltaCursor( int /*dx*/, From f611719edce2ae51dca8e53947a3938b53c20b00 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 16 May 2008 19:49:29 +0930 Subject: [PATCH 5/6] xfree86: always render first cursor in HW, all others in SW. --- hw/xfree86/ramdac/xf86Cursor.c | 85 ++++++++++++---------------------- 1 file changed, 30 insertions(+), 55 deletions(-) diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c index 50f8fb70d..7695962b6 100644 --- a/hw/xfree86/ramdac/xf86Cursor.c +++ b/hw/xfree86/ramdac/xf86Cursor.c @@ -20,8 +20,6 @@ extern InputInfo inputInfo; DevPrivateKey xf86CursorScreenKey = &xf86CursorScreenKey; -#define XF86_FORCE_SW_CURSOR (1 << 7) - /* sprite functions */ static Bool xf86CursorRealizeCursor(DeviceIntPtr, ScreenPtr, CursorPtr); @@ -304,14 +302,14 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs, if (pCurs == NullCursor) { /* means we're supposed to remove the cursor */ - if (ScreenPriv->SWCursor) + if (ScreenPriv->SWCursor || pDev != inputInfo.pointer) (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, NullCursor, x, y); else if (ScreenPriv->isUp) { xf86SetCursor(pScreen, NullCursor, x, y); ScreenPriv->isUp = FALSE; - } - return; + } + return; } /* only update for VCP, otherwise we get cursor jumps when removing a @@ -324,13 +322,10 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs, ScreenPriv->CursorToRestore = NULL; ScreenPriv->HotX = pCurs->bits->xhot; ScreenPriv->HotY = pCurs->bits->yhot; - } - if (!infoPtr->pScrn->vtSema) - ScreenPriv->SavedCursor = pCurs; + if (!infoPtr->pScrn->vtSema) + ScreenPriv->SavedCursor = pCurs; - if (!(ScreenPriv->SWCursor & XF86_FORCE_SW_CURSOR)) - { if (infoPtr->pScrn->vtSema && (ScreenPriv->ForceHWCursorCount || (( #ifdef ARGB_CURSOR pCurs->bits->argb && infoPtr->UseHWCursorARGB && @@ -352,23 +347,23 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs, return; } + PointPriv->waitForUpdate = TRUE; + + if (ScreenPriv->isUp) { + /* Remove the HW cursor, or make it transparent */ + if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT) { + xf86SetTransparentCursor(pScreen); + } else { + xf86SetCursor(pScreen, NullCursor, x, y); + ScreenPriv->isUp = FALSE; + } + } + + if (!ScreenPriv->SWCursor) + ScreenPriv->SWCursor = TRUE; + } - PointPriv->waitForUpdate = TRUE; - - if (ScreenPriv->isUp) { - /* Remove the HW cursor, or make it transparent */ - if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT) { - xf86SetTransparentCursor(pScreen); - } else { - xf86SetCursor(pScreen, NullCursor, x, y); - ScreenPriv->isUp = FALSE; - } - } - - if (!ScreenPriv->SWCursor) - ScreenPriv->SWCursor = TRUE; - if (pCurs->bits->emptyMask && !ScreenPriv->showTransparent) pCurs = NullCursor; @@ -384,18 +379,19 @@ xf86CursorMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) /* only update coordinate state for first sprite, otherwise we get jumps when removing a sprite. The second sprite is never HW rendered anyway */ if (pDev == inputInfo.pointer || - (!pDev->isMaster && pDev->u.master == inputInfo.pointer)) + !pDev->isMaster && pDev->u.master == inputInfo.pointer) { ScreenPriv->x = x; ScreenPriv->y = y; - } - if (ScreenPriv->CursorToRestore) - xf86CursorSetCursor(pDev, pScreen, ScreenPriv->CursorToRestore, x, y); - else if (ScreenPriv->SWCursor) - (*ScreenPriv->spriteFuncs->MoveCursor)(pDev, pScreen, x, y); - else if (ScreenPriv->isUp) - xf86MoveCursor(pScreen, x, y); + if (ScreenPriv->CursorToRestore) + xf86CursorSetCursor(pDev, pScreen, ScreenPriv->CursorToRestore, x, y); + else if (ScreenPriv->SWCursor) + (*ScreenPriv->spriteFuncs->MoveCursor)(pDev, pScreen, x, y); + else if (ScreenPriv->isUp) + xf86MoveCursor(pScreen, x, y); + } else + (*ScreenPriv->spriteFuncs->MoveCursor)(pDev, pScreen, x, y); } void @@ -455,13 +451,6 @@ xf86DeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) /* Init SW cursor */ ret = (*ScreenPriv->spriteFuncs->DeviceCursorInitialize)(pDev, pScreen); - if (pDev != inputInfo.pointer) - { - ScreenPriv->spriteFuncs->SetCursor(inputInfo.pointer, pScreen, - ScreenPriv->CurrentCursor, ScreenPriv->x, ScreenPriv->y); - ScreenPriv->SWCursor = TRUE | XF86_FORCE_SW_CURSOR; - } - return ret; } @@ -475,21 +464,7 @@ xf86DeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( &pScreen->devPrivates, xf86CursorScreenKey); - for (it = inputInfo.devices; it; it = it->next) - { - if (it->isMaster && it != inputInfo.pointer && it != - inputInfo.keyboard) - break; - } - - if (!it) /* no other sprites except VCP. restore HW rendering */ - { - ScreenPriv->SWCursor = TRUE; - xf86CursorSetCursor(inputInfo.pointer, pScreen, - ScreenPriv->CurrentCursor, ScreenPriv->x, ScreenPriv->y); - } - - /* Clean up SW cursor */ + /* Clean up SW cursor */ (*ScreenPriv->spriteFuncs->DeviceCursorCleanup)(pDev, pScreen); } From dfb7de6571345061d1cd88ab915064fc376529fd Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 16 May 2008 20:56:04 +0930 Subject: [PATCH 6/6] mi: don't call from miPointerMoved into the spriteFuncs for anything but VCP. Calling ->MoveCursor for anything but the HW-rendered VCP causes the SW-rendered cursor routines to be started, including mallocs, etc. Since miPointerMoved is called during SIGIO, this is a bad idea. --- mi/mipointer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mi/mipointer.c b/mi/mipointer.c index 484947da9..6f39bcb5c 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -530,7 +530,11 @@ miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, pPointer = MIPOINTER(pDev); - if (pDev && pDev->coreEvents + /* Hack: We mustn't call into ->MoveCursor for anything but the + * VCP, as this may cause a non-HW rendered cursor to be rendered during + * SIGIO. This again leads to allocs during SIGIO which leads to SIGABRT. + */ + if ((pDev == inputInfo.pointer || (!pDev->isMaster && pDev->u.master == inputInfo.pointer)) && !pScreenPriv->waitForUpdate && pScreen == pPointer->pSpriteScreen) { pPointer->devx = x;