From ec72c4af3c7bf55d91e7483ac3792d3e8d70f345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Mon, 25 Jan 2021 15:48:00 +0100 Subject: [PATCH] winex11.drv: Use desktop cursor notification message. Instead of manually synchronizing the cursor. --- dlls/winex11.drv/mouse.c | 63 +++++-------------------------- dlls/winex11.drv/window.c | 14 ++++++- dlls/winex11.drv/winex11.drv.spec | 1 - dlls/winex11.drv/x11drv.h | 2 +- 4 files changed, 23 insertions(+), 57 deletions(-) diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 06a5e64599f..e0b98bbf605 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -124,9 +124,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 ); @@ -237,24 +234,6 @@ void set_window_cursor( Window window, HCURSOR handle ) XFlush( gdi_display ); } -/*********************************************************************** - * sync_window_cursor - */ -void sync_window_cursor( Window window ) -{ - HCURSOR cursor; - - SERVER_START_REQ( set_cursor ) - { - req->flags = 0; - wine_server_call( req ); - cursor = reply->prev_count >= 0 ? wine_server_ptr_handle( reply->prev_handle ) : 0; - } - SERVER_END_REQ; - - set_window_cursor( window, cursor ); -} - struct mouse_button_mapping { int deviceid; @@ -458,6 +437,7 @@ static BOOL grab_clipping_window( const RECT *clip ) { static const WCHAR messageW[] = {'M','e','s','s','a','g','e',0}; struct x11drv_thread_data *data = x11drv_thread_data(); + HCURSOR cursor; Window clip_window; HWND msg_hwnd = 0; POINT pos; @@ -514,6 +494,15 @@ static BOOL grab_clipping_window( const RECT *clip ) GrabModeAsync, GrabModeAsync, clip_window, None, CurrentTime )) clipping_cursor = TRUE; + SERVER_START_REQ( set_cursor ) + { + req->flags = 0; + wine_server_call( req ); + cursor = reply->prev_count >= 0 ? wine_server_ptr_handle( reply->prev_handle ) : 0; + } + SERVER_END_REQ; + set_window_cursor( clip_window, cursor ); + if (!clipping_cursor) { X11DRV_XInput2_Disable(); @@ -521,8 +510,6 @@ static BOOL grab_clipping_window( const RECT *clip ) return FALSE; } clip_rect = *clip; - if (!data->clip_hwnd) sync_window_cursor( clip_window ); - InterlockedExchangePointer( (void **)&cursor_window, msg_hwnd ); data->clip_hwnd = msg_hwnd; SendNotifyMessageW( GetDesktopWindow(), WM_X11DRV_CLIP_CURSOR_NOTIFY, 0, (LPARAM)msg_hwnd ); return TRUE; @@ -707,8 +694,6 @@ static POINT map_event_coords(const XButtonEvent *event, HWND hwnd) */ static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPUT *input ) { - struct x11drv_win_data *data; - input->type = INPUT_MOUSE; if (!hwnd) @@ -719,12 +704,6 @@ static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPU if (!clip_hwnd) return; if (thread_data->clip_window != window) return; - if (InterlockedExchangePointer( (void **)&cursor_window, clip_hwnd ) != clip_hwnd || - input->u.mi.time - last_cursor_change > 100) - { - sync_window_cursor( window ); - last_cursor_change = input->u.mi.time; - } pt.x = clip_rect.left; pt.y = clip_rect.top; @@ -741,15 +720,6 @@ static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPU return; } - if ((InterlockedExchangePointer( (void **)&cursor_window, hwnd ) != hwnd || - input->u.mi.time - last_cursor_change > 100) && - (data = get_win_data( hwnd ))) - { - sync_window_cursor( data->whole_window ); - last_cursor_change = input->u.mi.time; - release_win_data( data ); - } - if (hwnd != GetDesktopWindow()) { hwnd = GetAncestor( hwnd, GA_ROOT ); @@ -1544,19 +1514,6 @@ void CDECL X11DRV_DestroyCursorIcon( HCURSOR handle ) } } -/*********************************************************************** - * SetCursor (X11DRV.@) - */ -void CDECL X11DRV_SetCursor( HCURSOR handle ) -{ - if (InterlockedExchangePointer( (void **)&last_cursor, handle ) != handle || - GetTickCount() - last_cursor_change > 100) - { - last_cursor_change = GetTickCount(); - if (cursor_window) SendNotifyMessageW( cursor_window, WM_X11DRV_SET_CURSOR, 0, (LPARAM)handle ); - } -} - /*********************************************************************** * SetCursorPos (X11DRV.@) */ diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index e0f323c76f6..9d410d07bfa 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1891,8 +1891,6 @@ static void create_whole_window( struct x11drv_win_data *data ) XFlush( data->display ); /* make sure the window exists before we start painting to it */ - sync_window_cursor( data->whole_window ); - done: if (win_rgn) DeleteObject( win_rgn ); } @@ -2098,6 +2096,15 @@ BOOL CDECL X11DRV_CreateDesktopWindow( HWND hwnd ) detect_wm( gdi_display ); + SERVER_START_REQ( set_cursor ) + { + req->flags = SET_CURSOR_HANDLE; + req->handle = 0; + req->change_msg = WM_X11DRV_DESKTOP_SET_WINDOW_CURSOR; + wine_server_call( req ); + } + SERVER_END_REQ; + /* retrieve the real size of the desktop */ SERVER_START_REQ( get_window_rectangles ) { @@ -3147,6 +3154,9 @@ LRESULT CDECL X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) } if (clipping_cursor) set_window_cursor( x11drv_thread_data()->clip_window, (HCURSOR)lp ); return 0; + case WM_X11DRV_DESKTOP_SET_WINDOW_CURSOR: + SendNotifyMessageW( (HWND)wp, WM_X11DRV_SET_CURSOR, 0, lp ); + return 0; case WM_X11DRV_CLIP_CURSOR_NOTIFY: return clip_cursor_notify( hwnd, (HWND)wp, (HWND)lp ); case WM_X11DRV_CLIP_CURSOR_REQUEST: diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec index c0e24d8fe82..8674de054ac 100644 --- a/dlls/winex11.drv/winex11.drv.spec +++ b/dlls/winex11.drv/winex11.drv.spec @@ -15,7 +15,6 @@ @ cdecl UnloadKeyboardLayout(long) X11DRV_UnloadKeyboardLayout @ cdecl VkKeyScanEx(long long) X11DRV_VkKeyScanEx @ cdecl DestroyCursorIcon(long) X11DRV_DestroyCursorIcon -@ cdecl SetCursor(long) X11DRV_SetCursor @ cdecl GetCursorPos(ptr) X11DRV_GetCursorPos @ cdecl SetCursorPos(long long) X11DRV_SetCursorPos @ cdecl ClipCursor(ptr) X11DRV_ClipCursor diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 052749d8e37..1e16c9f3fa0 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -547,6 +547,7 @@ enum x11drv_window_messages WM_X11DRV_SET_WIN_REGION, WM_X11DRV_RESIZE_DESKTOP, WM_X11DRV_SET_CURSOR, + WM_X11DRV_DESKTOP_SET_WINDOW_CURSOR, WM_X11DRV_CLIP_CURSOR_NOTIFY, WM_X11DRV_CLIP_CURSOR_REQUEST, WM_X11DRV_RELEASE_CURSOR @@ -665,7 +666,6 @@ extern XContext cursor_context DECLSPEC_HIDDEN; extern void X11DRV_InitClipboard(void) DECLSPEC_HIDDEN; extern void CDECL X11DRV_SetFocus( HWND hwnd ) DECLSPEC_HIDDEN; extern void set_window_cursor( Window window, HCURSOR handle ) DECLSPEC_HIDDEN; -extern void sync_window_cursor( Window window ) DECLSPEC_HIDDEN; extern LRESULT clip_cursor_notify( HWND hwnd, HWND prev_clip_hwnd, HWND new_clip_hwnd ) DECLSPEC_HIDDEN; extern LRESULT clip_cursor_request( HWND hwnd, BOOL fullscreen, BOOL reset ) DECLSPEC_HIDDEN; extern void ungrab_clipping_window(void) DECLSPEC_HIDDEN;