Author: tkreuzer
Date: Wed Jan 12 11:49:29 2011
New Revision: 50365
URL:
http://svn.reactos.org/svn/reactos?rev=50365&view=rev
Log:
[WIN32K]
- In UserSetCursor, return a pointer to the old cursor, not the handle
- really delete the pointer shape when NULL cursor is set, instead of just hiding it.
- Move reference handling completely to NtUserSetCursor
- In UserChangeDisplaySettings, set NULL cursor before change and restore old cursor after
change to make sure we have the right color format.
See issue #5722 for more details.
Modified:
trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c
trunk/reactos/subsystems/win32/win32k/ntuser/display.c
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] Wed Jan 12
11:49:29 2011
@@ -99,7 +99,7 @@
return CurIcon;
}
-HCURSOR
+PCURICON_OBJECT
FASTCALL
UserSetCursor(
PCURICON_OBJECT NewCursor,
@@ -107,22 +107,17 @@
{
PSYSTEM_CURSORINFO CurInfo;
PCURICON_OBJECT OldCursor;
- HCURSOR hOldCursor = (HCURSOR)0;
HDC hdcScreen;
CurInfo = IntGetSysCursorInfo();
OldCursor = CurInfo->CurrentCursorObject;
- if (OldCursor)
- {
- hOldCursor = (HCURSOR)OldCursor->Self;
- }
/* Is the new cursor the same as the old cursor? */
if (OldCursor == NewCursor)
{
/* Nothing to to do in this case */
- return hOldCursor;
+ return OldCursor;
}
/* Get the screen DC */
@@ -134,8 +129,6 @@
/* Do we have a new cursor? */
if (NewCursor)
{
- UserReferenceObject(NewCursor);
-
CurInfo->ShowingCursor = 1;
CurInfo->CurrentCursorObject = NewCursor;
@@ -147,8 +140,6 @@
NewCursor->IconInfo.yHotspot,
gpsi->ptCursor.x,
gpsi->ptCursor.y);
-
-
}
else
{
@@ -156,22 +147,19 @@
if (OldCursor && CurInfo->ShowingCursor)
{
/* Remove the cursor */
- GreMovePointer(hdcScreen, -1, -1);
+ //GreMovePointer(hdcScreen, -1, -1);
DPRINT("Removing pointer!\n");
}
CurInfo->CurrentCursorObject = NULL;
CurInfo->ShowingCursor = 0;
- }
-
- /* OldCursor is not in use anymore */
- if (OldCursor)
- {
- UserDereferenceObject(OldCursor);
- }
-
- /* Return handle of the old cursor */
- return hOldCursor;
+
+ /* Unset the bitmaps */
+ GreSetPointerShape(hdcScreen, NULL, NULL, 0, 0, 0, 0);
+ }
+
+ /* Return the old cursor */
+ return OldCursor;
}
BOOL UserSetCursorPos( INT x, INT y, BOOL SendMouseMoveMsg)
@@ -734,7 +722,7 @@
prcl = &rclLocal;
}
-
+
UserEnterExclusive();
/* Call the internal function */
@@ -873,38 +861,36 @@
NtUserSetCursor(
HCURSOR hCursor)
{
- PCURICON_OBJECT CurIcon;
- HICON OldCursor;
- DECLARE_RETURN(HCURSOR);
+ PCURICON_OBJECT pcurOld, pcurNew;
+ HCURSOR hOldCursor = NULL;
DPRINT("Enter NtUserSetCursor\n");
UserEnterExclusive();
if (hCursor)
{
- if (!(CurIcon = UserGetCurIconObject(hCursor)))
- {
- RETURN(NULL);
+ pcurNew = UserGetCurIconObject(hCursor);
+ if (!pcurNew)
+ {
+ EngSetLastError(ERROR_INVALID_HANDLE);
+ goto leave;
}
}
else
{
- CurIcon = NULL;
- }
-
- OldCursor = UserSetCursor(CurIcon, FALSE);
-
- if (CurIcon)
- {
- UserDereferenceObject(CurIcon);
- }
-
- RETURN(OldCursor);
-
-CLEANUP:
- DPRINT("Leave NtUserSetCursor, ret=%i\n",_ret_);
+ pcurNew = NULL;
+ }
+
+ pcurOld = UserSetCursor(pcurNew, FALSE);
+ if (pcurOld)
+ {
+ hOldCursor = (HCURSOR)pcurOld->Self;
+ UserDereferenceObject(pcurOld);
+ }
+
+leave:
UserLeave();
- END_CLEANUP;
+ return hOldCursor;
}
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/display.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] Wed Jan 12
11:49:29 2011
@@ -739,15 +739,16 @@
if (!(flags & CDS_NORESET))
{
ULONG ulResult;
+ PVOID pvOldCursor;
/* Remove mouse pointer */
- UserSetCursor(NULL, TRUE);
+ pvOldCursor = UserSetCursor(NULL, TRUE);
/* Do the mode switch */
ulResult = PDEVOBJ_bSwitchMode(ppdev, pdm);
/* Restore mouse pointer, no hooks called */
- UserSetCursorPos(gpsi->ptCursor.x, gpsi->ptCursor.y, FALSE);
+ UserSetCursor(pvOldCursor, TRUE);
/* Check for failure */
if (!ulResult)