Store the current cursor in the thread queue instead of globally.

This commit is contained in:
Alexandre Julliard 2002-06-14 00:07:05 +00:00
parent e4a33c0660
commit c0d1ff5967
2 changed files with 24 additions and 21 deletions

View file

@ -62,6 +62,9 @@ typedef struct tagMESSAGEQUEUE
DWORD GetMessagePosVal; /* Value for GetMessagePos */ DWORD GetMessagePosVal; /* Value for GetMessagePos */
DWORD GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */ DWORD GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */
HCURSOR cursor; /* current cursor */
INT cursor_count; /* cursor show count */
HANDLE16 hCurHook; /* Current hook */ HANDLE16 hCurHook; /* Current hook */
HANDLE16 hooks[WH_NB_HOOKS]; /* Task hooks list */ HANDLE16 hooks[WH_NB_HOOKS]; /* Task hooks list */

View file

@ -56,6 +56,7 @@
#include "module.h" #include "module.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "user.h" #include "user.h"
#include "queue.h"
#include "input.h" #include "input.h"
#include "message.h" #include "message.h"
#include "winerror.h" #include "winerror.h"
@ -65,8 +66,6 @@ WINE_DECLARE_DEBUG_CHANNEL(cursor);
WINE_DECLARE_DEBUG_CHANNEL(icon); WINE_DECLARE_DEBUG_CHANNEL(icon);
WINE_DECLARE_DEBUG_CHANNEL(resource); WINE_DECLARE_DEBUG_CHANNEL(resource);
static HCURSOR hActiveCursor = 0; /* Active cursor */
static INT CURSOR_ShowCount = 0; /* Cursor display count */
static RECT CURSOR_ClipRect; /* Cursor clipping rect */ static RECT CURSOR_ClipRect; /* Cursor clipping rect */
static HDC screen_dc; static HDC screen_dc;
@ -1220,7 +1219,7 @@ WORD WINAPI DestroyIcon32( HGLOBAL16 handle, UINT16 flags )
/* Check whether destroying active cursor */ /* Check whether destroying active cursor */
if ( hActiveCursor == handle ) if ( QUEUE_Current()->cursor == handle )
{ {
WARN_(cursor)("Destroying active cursor!\n" ); WARN_(cursor)("Destroying active cursor!\n" );
SetCursor( 0 ); SetCursor( 0 );
@ -1368,20 +1367,20 @@ HCURSOR16 WINAPI SetCursor16( HCURSOR16 hCursor )
* RETURNS: * RETURNS:
* A handle to the previous cursor shape. * A handle to the previous cursor shape.
*/ */
HCURSOR WINAPI SetCursor( HCURSOR WINAPI SetCursor( HCURSOR hCursor /* [in] Handle of cursor to show */ )
HCURSOR hCursor /* [in] Handle of cursor to show */ {
) { MESSAGEQUEUE *queue = QUEUE_Current();
HCURSOR hOldCursor; HCURSOR hOldCursor;
if (hCursor == hActiveCursor) return hActiveCursor; /* No change */ if (hCursor == queue->cursor) return hCursor; /* No change */
TRACE_(cursor)("%04x\n", hCursor ); TRACE_(cursor)("%04x\n", hCursor );
hOldCursor = hActiveCursor; hOldCursor = queue->cursor;
hActiveCursor = hCursor; queue->cursor = hCursor;
/* Change the cursor shape only if it is visible */ /* Change the cursor shape only if it is visible */
if (CURSOR_ShowCount >= 0) if (queue->cursor_count >= 0)
{ {
USER_Driver.pSetCursor( (CURSORICONINFO*)GlobalLock16( hActiveCursor ) ); USER_Driver.pSetCursor( (CURSORICONINFO*)GlobalLock16( hCursor ) );
GlobalUnlock16( hActiveCursor ); GlobalUnlock16( hCursor );
} }
return hOldCursor; return hOldCursor;
} }
@ -1401,23 +1400,24 @@ INT16 WINAPI ShowCursor16( BOOL16 bShow )
*/ */
INT WINAPI ShowCursor( BOOL bShow ) INT WINAPI ShowCursor( BOOL bShow )
{ {
TRACE_(cursor)("%d, count=%d\n", MESSAGEQUEUE *queue = QUEUE_Current();
bShow, CURSOR_ShowCount );
TRACE_(cursor)("%d, count=%d\n", bShow, queue->cursor_count );
if (bShow) if (bShow)
{ {
if (++CURSOR_ShowCount == 0) /* Show it */ if (++queue->cursor_count == 0) /* Show it */
{ {
USER_Driver.pSetCursor( (CURSORICONINFO*)GlobalLock16( hActiveCursor ) ); USER_Driver.pSetCursor( (CURSORICONINFO*)GlobalLock16( queue->cursor ) );
GlobalUnlock16( hActiveCursor ); GlobalUnlock16( queue->cursor );
} }
} }
else else
{ {
if (--CURSOR_ShowCount == -1) /* Hide it */ if (--queue->cursor_count == -1) /* Hide it */
USER_Driver.pSetCursor( NULL ); USER_Driver.pSetCursor( NULL );
} }
return CURSOR_ShowCount; return queue->cursor_count;
} }
@ -1426,7 +1426,7 @@ INT WINAPI ShowCursor( BOOL bShow )
*/ */
HCURSOR16 WINAPI GetCursor16(void) HCURSOR16 WINAPI GetCursor16(void)
{ {
return hActiveCursor; return GetCursor();
} }
@ -1435,7 +1435,7 @@ HCURSOR16 WINAPI GetCursor16(void)
*/ */
HCURSOR WINAPI GetCursor(void) HCURSOR WINAPI GetCursor(void)
{ {
return hActiveCursor; return QUEUE_Current()->cursor;
} }