Skip to content

Commit

Permalink
winex11.drv: Make last_cursor per-thread.
Browse files Browse the repository at this point in the history
CW-Bug-Id: #21078
  • Loading branch information
gofman authored and ivyl committed Aug 5, 2022
1 parent 28e9df4 commit fe517aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions dlls/winex11.drv/mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ static const UINT button_up_data[NB_BUTTONS] =
XContext cursor_context = 0;

static HWND cursor_window;
static HCURSOR last_cursor;
static DWORD last_cursor_change;
static RECT clip_rect;
static Cursor create_cursor( HANDLE handle );
Expand Down Expand Up @@ -1527,11 +1526,13 @@ void CDECL X11DRV_DestroyCursorIcon( HCURSOR handle )
*/
void CDECL X11DRV_SetCursor( HCURSOR handle )
{
if (InterlockedExchangePointer( (void **)&last_cursor, handle ) != handle ||
GetTickCount() - last_cursor_change > 100)
struct x11drv_thread_data *thread_data = x11drv_init_thread_data();

if (thread_data->last_cursor != handle || GetTickCount() - last_cursor_change > 100)
{
last_cursor_change = GetTickCount();
if (cursor_window) SendNotifyMessageW( cursor_window, WM_X11DRV_SET_CURSOR, 0, (LPARAM)handle );
thread_data->last_cursor = handle;
if (cursor_window) SendNotifyMessageW( cursor_window, WM_X11DRV_SET_CURSOR, 0, 0 );
}
}

Expand Down
4 changes: 2 additions & 2 deletions dlls/winex11.drv/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -3411,10 +3411,10 @@ LRESULT CDECL X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
Window win = data->whole_window;
release_win_data( data );
if (win) set_window_cursor( win, (HCURSOR)lp );
if (win) set_window_cursor( win, x11drv_thread_data()->last_cursor );
}
else if (hwnd == x11drv_thread_data()->clip_hwnd)
set_window_cursor( x11drv_thread_data()->clip_window, (HCURSOR)lp );
set_window_cursor( x11drv_thread_data()->clip_window, x11drv_thread_data()->last_cursor );
return 0;
case WM_X11DRV_CLIP_CURSOR_NOTIFY:
return clip_cursor_notify( hwnd, (HWND)wp, (HWND)lp );
Expand Down
1 change: 1 addition & 0 deletions dlls/winex11.drv/x11drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ struct x11drv_thread_data
Window clip_window; /* window used for cursor clipping */
HWND clip_hwnd; /* message window stored in desktop while clipping is active */
DWORD clip_reset; /* time when clipping was last reset */
HCURSOR last_cursor; /* last cursor set */
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
XIValuatorClassInfo x_valuator;
XIValuatorClassInfo y_valuator;
Expand Down

0 comments on commit fe517aa

Please sign in to comment.