Commit 6551553f authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Make the cursor window global instead of per-thread, and send it a…

winex11: Make the cursor window global instead of per-thread, and send it a message when the cursor changes.
parent ce3c1dfc
......@@ -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);
......
......@@ -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 );
}
/***********************************************************************
......
......@@ -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;
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment