- Simplify IntSetCursor

- Make NtUserSetCursor hide Cursor on hCursor = NULL
- Don't set the cursor pos if the cursor is hidden in IntMouseInput
- remove 2 useless ASSERTs
- Dereference old cursor- Make the screensaver lib hide the cursor directly after creating it (the window never recieves a WM_SETCURSOR)
partly fixes bug 2965
See issue #2965 for more details.

svn path=/trunk/; revision=32676
This commit is contained in:
Timo Kreuzer 2008-03-14 00:05:58 +00:00
parent 0d99c97ab4
commit 9457b015d6
3 changed files with 58 additions and 43 deletions

View file

@ -189,6 +189,7 @@ static int LaunchScreenSaver(HWND hParent)
if (hMainWindow)
{
ShowWindow(hMainWindow, SW_SHOW);
SetCursor(NULL);
while (GetMessage(&msg, NULL, 0, 0))
DispatchMessage(&msg);

View file

@ -125,59 +125,54 @@ IntSetCursor(PWINSTATION_OBJECT WinSta, PCURICON_OBJECT NewCursor,
{
return Ret;
}
else
if(!(Screen = IntGetScreenDC()))
{
if(!(Screen = IntGetScreenDC()))
{
return (HCURSOR)0;
}
/* FIXME use the desktop's HDC instead of using ScreenDeviceContext */
dc = DC_LockDc(Screen);
if (!dc)
{
return Ret;
}
dcbmp = dc->w.hBitmap;
DevInfo = (PDEVINFO)&((GDIDEVICE *)dc->pPDev)->DevInfo;
DC_UnlockDc(dc);
BitmapObj = BITMAPOBJ_LockBitmap(dcbmp);
if ( !BitmapObj )
return (HCURSOR)0;
SurfObj = &BitmapObj->SurfObj;
ASSERT(SurfObj);
return (HCURSOR)0;
}
/* FIXME use the desktop's HDC instead of using ScreenDeviceContext */
dc = DC_LockDc(Screen);
if (!NewCursor && (CurInfo->CurrentCursorObject || ForceChange))
if (!dc)
{
if (NULL != CurInfo->CurrentCursorObject)
{
UserDereferenceObject(CurInfo->CurrentCursorObject);
if (CurInfo->ShowingCursor)
{
/* Remove the cursor if it was displayed */
IntEngMovePointer(SurfObj, -1, -1, &GDIDEV(SurfObj)->Pointer.Exclude);
}
}
GDIDEV(SurfObj)->Pointer.Status = SPS_ACCEPT_NOEXCLUDE;
CurInfo->CurrentCursorObject = NewCursor; /* i.e. CurrentCursorObject = NULL */
CurInfo->ShowingCursor = 0;
BITMAPOBJ_UnlockBitmap(BitmapObj);
return Ret;
}
dcbmp = dc->w.hBitmap;
DevInfo = (PDEVINFO)&((GDIDEVICE *)dc->pPDev)->DevInfo;
DC_UnlockDc(dc);
BitmapObj = BITMAPOBJ_LockBitmap(dcbmp);
if (!BitmapObj)
return (HCURSOR)0;
SurfObj = &BitmapObj->SurfObj;
if (!NewCursor)
{
if (CurInfo->CurrentCursorObject || ForceChange)
{
if (CurInfo->CurrentCursorObject)
{
UserDereferenceObject(CurInfo->CurrentCursorObject);
if (CurInfo->ShowingCursor)
{
DPRINT1("Removing pointer!\n");
/* Remove the cursor if it was displayed */
IntEngMovePointer(SurfObj, -1, -1, &GDIDEV(SurfObj)->Pointer.Exclude);
}
}
GDIDEV(SurfObj)->Pointer.Status = SPS_ACCEPT_NOEXCLUDE;
CurInfo->CurrentCursorObject = NewCursor; /* i.e. CurrentCursorObject = NULL */
CurInfo->ShowingCursor = 0;
}
BITMAPOBJ_UnlockBitmap(BitmapObj);
return Ret;
}
/* TODO: Fixme. Logic is screwed above */
ASSERT(NewCursor);
MaskBmpObj = BITMAPOBJ_LockBitmap(NewCursor->IconInfo.hbmMask);
if (MaskBmpObj)
{
@ -251,6 +246,12 @@ IntSetCursor(PWINSTATION_OBJECT WinSta, PCURICON_OBJECT NewCursor,
CurInfo->CurrentCursorObject = NULL;
}
/* OldCursor is not in use anymore */
if (OldCursor)
{
UserDereferenceObject(OldCursor);
}
if (GDIDEVFUNCS(SurfObj).SetPointerShape)
{
GDIDEV(SurfObj)->Pointer.Status =
@ -1107,15 +1108,25 @@ NtUserSetCursor(
RETURN(NULL);
}
if(!(CurIcon = UserGetCurIconObject(hCursor)))
if(hCursor)
{
ObDereferenceObject(WinSta);
RETURN(NULL);
if(!(CurIcon = UserGetCurIconObject(hCursor)))
{
ObDereferenceObject(WinSta);
RETURN(NULL);
}
}
else
{
CurIcon = NULL;
}
OldCursor = IntSetCursor(WinSta, CurIcon, FALSE);
UserDereferenceObject(CurIcon);
if(CurIcon)
{
UserDereferenceObject(CurIcon);
}
ObDereferenceObject(WinSta);
RETURN(OldCursor);

View file

@ -1096,7 +1096,10 @@ IntMouseInput(MOUSEINPUT *mi)
{
SurfObj = &BitmapObj->SurfObj;
IntEngMovePointer(SurfObj, MousePos.x, MousePos.y, &(GDIDEV(SurfObj)->Pointer.Exclude));
if (CurInfo->ShowingCursor)
{
IntEngMovePointer(SurfObj, MousePos.x, MousePos.y, &(GDIDEV(SurfObj)->Pointer.Exclude));
}
/* Only now, update the info in the GDIDEVICE, so EngMovePointer can
* use the old values to move the pointer image */
GDIDEV(SurfObj)->Pointer.Pos.x = MousePos.x;