Alexandre Julliard : winex11: Always forward SetCursor to the driver, and limit the frequency of updates on the driver side.
Alexandre Julliard
julliard at winehq.org
Tue Apr 5 11:23:31 CDT 2011
Module: wine
Branch: master
Commit: 886ae4c3484bcf2cda549d8be39e2f901e0394fc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=886ae4c3484bcf2cda549d8be39e2f901e0394fc
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Apr 4 15:06:59 2011 +0200
winex11: Always forward SetCursor to the driver, and limit the frequency of updates on the driver side.
---
dlls/user32/cursoricon.c | 4 +---
dlls/winex11.drv/mouse.c | 26 +++++++++++++++++---------
dlls/winex11.drv/window.c | 6 +++++-
dlls/winex11.drv/x11drv.h | 2 +-
4 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index 476aa51..ba06e96 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -1651,9 +1651,7 @@ HCURSOR WINAPI DECLSPEC_HOTPATCH SetCursor( HCURSOR hCursor /* [in] Handle of cu
SERVER_END_REQ;
if (!ret) return 0;
-
- /* Change the cursor shape only if it is visible */
- if (show_count >= 0 && hOldCursor != hCursor) USER_Driver->pSetCursor( hCursor );
+ USER_Driver->pSetCursor( show_count >= 0 ? hCursor : 0 );
if (!(obj = get_icon_ptr( hOldCursor ))) return 0;
release_icon_ptr( hOldCursor, obj );
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index fe9f716..63773ce 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -93,7 +93,8 @@ static const UINT button_up_flags[NB_BUTTONS] =
};
static HWND cursor_window;
-static DWORD last_time_modified;
+static HCURSOR last_cursor;
+static DWORD last_cursor_change;
static XContext cursor_context;
static RECT clip_rect;
static Cursor create_cursor( HANDLE handle );
@@ -157,7 +158,7 @@ static Cursor get_empty_cursor(void)
/***********************************************************************
* set_window_cursor
*/
-void set_window_cursor( struct x11drv_win_data *data, HCURSOR handle )
+void set_window_cursor( Window window, HCURSOR handle )
{
Cursor cursor, prev;
@@ -184,10 +185,9 @@ void set_window_cursor( struct x11drv_win_data *data, HCURSOR handle )
}
}
- XDefineCursor( gdi_display, data->whole_window, cursor );
+ XDefineCursor( gdi_display, window, cursor );
/* make the change take effect immediately */
XFlush( gdi_display );
- data->cursor = handle;
wine_tsx11_unlock();
}
@@ -206,7 +206,11 @@ void sync_window_cursor( struct x11drv_win_data *data )
}
SERVER_END_REQ;
- if (data->cursor != cursor) set_window_cursor( data, cursor );
+ if (data->cursor != cursor)
+ {
+ data->cursor = cursor;
+ set_window_cursor( data->whole_window, cursor );
+ }
}
/***********************************************************************
@@ -247,12 +251,11 @@ static void send_mouse_input( HWND hwnd, UINT flags, Window window, int x, int y
MapWindowPoints( hwnd, 0, &pt, 1 );
if (InterlockedExchangePointer( (void **)&cursor_window, hwnd ) != hwnd ||
- GetTickCount() - last_time_modified > 100)
+ GetTickCount() - last_cursor_change > 100)
{
- cursor_window = hwnd;
sync_window_cursor( data );
+ last_cursor_change = GetTickCount();
}
- last_time_modified = GetTickCount();
if (hwnd != GetDesktopWindow()) hwnd = GetAncestor( hwnd, GA_ROOT );
@@ -877,7 +880,12 @@ void CDECL X11DRV_DestroyCursorIcon( HCURSOR handle )
*/
void CDECL X11DRV_SetCursor( HCURSOR handle )
{
- if (cursor_window) SendNotifyMessageW( cursor_window, WM_X11DRV_SET_CURSOR, 0, (LPARAM)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 );
+ }
}
/***********************************************************************
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 1fcadb5..21c8352 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -2699,7 +2699,11 @@ LRESULT CDECL X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
X11DRV_resize_desktop( LOWORD(lp), HIWORD(lp) );
return 0;
case WM_X11DRV_SET_CURSOR:
- if ((data = X11DRV_get_win_data( hwnd ))) set_window_cursor( data, (HCURSOR)lp );
+ if ((data = X11DRV_get_win_data( hwnd )) && data->whole_window)
+ {
+ data->cursor = (HCURSOR)lp;
+ set_window_cursor( data->whole_window, data->cursor );
+ }
return 0;
default:
FIXME( "got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, wp, lp );
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 0a1e3d9..26375fd 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -820,7 +820,7 @@ extern int CDECL X11DRV_AcquireClipboard(HWND hWndClipWindow);
extern void X11DRV_Clipboard_Cleanup(void);
extern void X11DRV_ResetSelectionOwner(void);
extern void CDECL X11DRV_SetFocus( HWND hwnd );
-extern void set_window_cursor( struct x11drv_win_data *data, HCURSOR handle );
+extern void set_window_cursor( Window window, HCURSOR handle );
extern void sync_window_cursor( struct x11drv_win_data *data );
extern BOOL CDECL X11DRV_ClipCursor( LPCRECT clip );
extern void X11DRV_InitKeyboard( Display *display );
More information about the wine-cvs
mailing list