[PATCH v3 0/2] MR4676: server: Only update the global cursor if the pointer is inside the thread's windows.
We are preferring the thread input cursor over the global desktop cursor, but if the thread input has no cursor yet, for instance when thread is attached to another thread without a message queue yet, it will end up being invisible. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55961 -- v3: server: Change desktop cursor only when inside the thread's windows. server: Introduce a new get_desktop_cursor_thread_input helper. https://gitlab.winehq.org/wine/wine/-/merge_requests/4676
From: Rémi Bernon <rbernon(a)codeweavers.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55961 --- server/queue.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/server/queue.c b/server/queue.c index d3ca1172d91..ebce3ff1b5a 100644 --- a/server/queue.c +++ b/server/queue.c @@ -429,26 +429,34 @@ static void queue_cursor_message( struct desktop *desktop, user_handle_t win, un queue_hardware_message( desktop, msg, 1 ); } +static struct thread_input *get_desktop_cursor_thread_input( struct desktop *desktop ) +{ + struct thread_input *input = NULL; + struct thread *thread; + + if ((thread = get_window_thread( desktop->cursor.win ))) + { + if (thread->queue) input = thread->queue->input; + release_object( thread ); + } + + return input; +} + static int update_desktop_cursor_window( struct desktop *desktop, user_handle_t win ) { int updated = win != desktop->cursor.win; - user_handle_t handle = desktop->cursor.handle; + struct thread_input *input; desktop->cursor.win = win; - if (updated) - { - struct thread *thread; - - if ((thread = get_window_thread( win ))) - { - struct thread_input *input = thread->queue->input; - if (input) handle = input->cursor_count < 0 ? 0 : input->cursor; - release_object( thread ); - } + if (updated && (input = get_desktop_cursor_thread_input( desktop ))) + { + user_handle_t handle = input->cursor_count < 0 ? 0 : input->cursor; /* when clipping send the message to the foreground window as well, as some driver have an artificial overlay window */ if (is_cursor_clipped( desktop )) queue_cursor_message( desktop, 0, WM_WINE_SETCURSOR, win, handle ); queue_cursor_message( desktop, win, WM_WINE_SETCURSOR, win, handle ); } + return updated; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4676
From: Rémi Bernon <rbernon(a)codeweavers.com> Getting rid of the desktop cursor handle at the same time. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55961 --- server/queue.c | 13 ++++--------- server/user.h | 1 - 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/server/queue.c b/server/queue.c index ebce3ff1b5a..ea816021fc0 100644 --- a/server/queue.c +++ b/server/queue.c @@ -478,13 +478,11 @@ static int update_desktop_cursor_pos( struct desktop *desktop, user_handle_t win return updated; } -static void update_desktop_cursor_handle( struct desktop *desktop, user_handle_t handle ) +static void update_desktop_cursor_handle( struct desktop *desktop, struct thread_input *input ) { - int updated = desktop->cursor.handle != handle; - user_handle_t win = desktop->cursor.win; - desktop->cursor.handle = handle; - if (updated) + if (input == get_desktop_cursor_thread_input( desktop )) { + user_handle_t handle = input->cursor_count < 0 ? 0 : input->cursor, win = desktop->cursor.win; /* when clipping send the message to the foreground window as well, as some driver have an artificial overlay window */ if (is_cursor_clipped( desktop )) queue_cursor_message( desktop, 0, WM_WINE_SETCURSOR, win, handle ); queue_cursor_message( desktop, win, WM_WINE_SETCURSOR, win, handle ); @@ -3408,10 +3406,7 @@ DECL_HANDLER(set_cursor) if (req->flags & SET_CURSOR_NOCLIP) set_clip_rectangle( desktop, NULL, SET_CURSOR_NOCLIP, 0 ); if (req->flags & (SET_CURSOR_HANDLE | SET_CURSOR_COUNT)) - { - if (input->cursor_count < 0) update_desktop_cursor_handle( desktop, 0 ); - else update_desktop_cursor_handle( desktop, input->cursor ); - } + update_desktop_cursor_handle( desktop, input ); reply->new_x = desktop->cursor.x; reply->new_y = desktop->cursor.y; diff --git a/server/user.h b/server/user.h index b6f47bcac1c..8fa55e09b0f 100644 --- a/server/user.h +++ b/server/user.h @@ -59,7 +59,6 @@ struct global_cursor rectangle_t clip; /* cursor clip rectangle */ unsigned int last_change; /* time of last position change */ user_handle_t win; /* window that contains the cursor */ - user_handle_t handle; /* last set cursor handle */ }; struct desktop -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4676
Another try again. This gets rid of the artificial desktop cursor handle, and should also fix the regression. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4676#note_56355
participants (1)
-
Rémi Bernon