Module: wine Branch: master Commit: 6551553fe6393f02787c73e7e1c35c45bd6aafba URL: http://source.winehq.org/git/wine.git/?a=commit;h=6551553fe6393f02787c73e7e1...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Apr 28 19:23:05 2010 -0500
winex11: Make the cursor window global instead of per-thread, and send it a message when the cursor changes.
---
dlls/user32/tests/cursoricon.c | 15 +++++-------- dlls/winex11.drv/mouse.c | 42 +++++++++++++++++++++++---------------- dlls/winex11.drv/window.c | 3 ++ dlls/winex11.drv/x11drv.h | 5 ++- 4 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index c1da70d..2a4100e 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -1639,13 +1639,12 @@ static void test_DestroyCursor(void) * ERROR_INVALID_CURSOR_HANDLE. This happens because we called * DestroyCursor() 2+ times after calling SetCursor(). The calls to * GetCursor() and SetCursor(NULL) in between make no difference. */ + SetLastError(0xdeadbeef); ret = DestroyCursor(cursor); - todo_wine { - ok(!ret, "DestroyCursor succeeded.\n"); - error = GetLastError(); - ok(error == ERROR_INVALID_CURSOR_HANDLE || error == 0xdeadbeef, /* vista */ - "Last error: 0x%08x\n", error); - } + todo_wine ok(!ret, "DestroyCursor succeeded.\n"); + error = GetLastError(); + ok(error == ERROR_INVALID_CURSOR_HANDLE || error == 0xdeadbeef, /* vista */ + "Last error: 0x%08x\n", error); }
DeleteObject(cursorInfo.hbmMask); @@ -1664,9 +1663,7 @@ static void test_DestroyCursor(void) SetLastError(0xdeadbeef); SetCursor(cursor); error = GetLastError(); - todo_wine { - ok(error == 0xdeadbeef, "Last error: 0x%08x\n", error); - } + ok(error == 0xdeadbeef, "Last error: 0x%08x\n", error);
/* Check if LoadCursor() returns the same handle with the same icon. */ cursor2 = LoadCursor(NULL, IDC_ARROW); diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index e0e6bb1..5a1a09f 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -86,6 +86,7 @@ static const UINT button_up_flags[NB_BUTTONS] = };
POINT cursor_pos; +static HWND cursor_window; static DWORD last_time_modified; static RECT cursor_clip; /* Cursor clipping rect */ static XContext cursor_context; @@ -206,6 +207,28 @@ Cursor get_x11_cursor( HCURSOR handle ) }
/*********************************************************************** + * set_window_cursor + */ +void set_window_cursor( HWND hwnd, HCURSOR handle ) +{ + struct x11drv_win_data *data; + Cursor cursor; + + if (!(data = X11DRV_get_win_data( hwnd ))) return; + + wine_tsx11_lock(); + if ((cursor = get_x11_cursor( handle ))) + { + TRACE( "%p xid %lx\n", handle, cursor ); + XDefineCursor( gdi_display, data->whole_window, cursor ); + /* Make the change take effect immediately */ + XFlush( gdi_display ); + data->cursor = handle; + } + wine_tsx11_unlock(); +} + +/*********************************************************************** * update_mouse_state * * Update the various window states on a mouse event. @@ -216,7 +239,7 @@ static void update_mouse_state( HWND hwnd, Window window, int x, int y, unsigned
get_coords( hwnd, window, x, y, pt );
- data->cursor_window = hwnd; + cursor_window = hwnd;
/* update the wine server Z-order */
@@ -1012,22 +1035,7 @@ void CDECL X11DRV_DestroyCursorIcon( HCURSOR handle ) */ void CDECL X11DRV_SetCursor( HCURSOR handle ) { - struct x11drv_thread_data *thread_data = x11drv_init_thread_data(); - struct x11drv_win_data *data; - Cursor cursor; - - if (!(data = X11DRV_get_win_data( thread_data->cursor_window ))) return; - - wine_tsx11_lock(); - if ((cursor = get_x11_cursor( handle ))) - { - TRACE( "%p xid %lx\n", handle, cursor ); - XDefineCursor( gdi_display, data->whole_window, cursor ); - /* Make the change take effect immediately */ - XFlush( gdi_display ); - data->cursor = handle; - } - wine_tsx11_unlock(); + 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 831b7c9..8cd3bf3 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2493,6 +2493,9 @@ LRESULT CDECL X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) case WM_X11DRV_RESIZE_DESKTOP: X11DRV_resize_desktop( LOWORD(lp), HIWORD(lp) ); return 0; + case WM_X11DRV_SET_CURSOR: + set_window_cursor( hwnd, (HCURSOR)lp ); + return 0; default: FIXME( "got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, wp, lp ); return 0; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 4a3f8b7..13afe78 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -546,7 +546,6 @@ struct x11drv_thread_data { Display *display; XEvent *current_event; /* event currently being processed */ - HWND cursor_window; /* current window that contains the cursor */ Window grab_window; /* window that currently grabs the mouse */ HWND last_focus; /* last window that had focus */ XIM xim; /* input method */ @@ -714,7 +713,8 @@ enum x11drv_window_messages WM_X11DRV_ACQUIRE_SELECTION = 0x80001000, WM_X11DRV_SET_WIN_FORMAT, WM_X11DRV_SET_WIN_REGION, - WM_X11DRV_RESIZE_DESKTOP + WM_X11DRV_RESIZE_DESKTOP, + WM_X11DRV_SET_CURSOR };
/* _NET_WM_STATE properties that we keep track of */ @@ -782,6 +782,7 @@ extern void X11DRV_Clipboard_Cleanup(void); extern void X11DRV_ResetSelectionOwner(void); extern void CDECL X11DRV_SetFocus( HWND hwnd ); extern Cursor get_x11_cursor( HCURSOR handle ); +extern void set_window_cursor( HWND hwnd, HCURSOR handle ); extern BOOL CDECL X11DRV_ClipCursor( LPCRECT clip ); extern void X11DRV_InitKeyboard( Display *display ); extern void X11DRV_send_keyboard_input( WORD wVk, WORD wScan, DWORD dwFlags, DWORD time,