winewayland.drv: Track and apply latest window cursor on pointer enter.

Keep track of the window cursor set for each surface and apply it when
the pointer enters the corresponding surface. This fixes a problem where
due to transient disagreements between win32 pointer focus and Wayland
pointer focus a cursor update may be lost. For example:

1. Assume existing cursor C1.
2. Window is created beneath cursor.
3. The SetCursor(hwnd, C2) driver callback is called, but because the
   wl_pointer hasn't entered the Wayland surface yet we don't update
   the wl_pointer cursor.
4. wl_pointer enters the surface, we apply the latest cursor we know
   about, which is C1.
5. Since no change in cursor window occurs, we don't get any
   further SetCursor(hwnd, C2) callbacks, so we get stuck with C1.

This commit fixes the problem by tracking the per-surface HCURSOR in
step 3, regardless of whether the cursor is actually applied. So, in
step 4 we can use that HCURSOR for the surface.

This change also fixes some cases of our mouselook heuristics not
kicking in properly due to missing a SetCursor(hwnd, NULL) in the
manner described above.
This commit is contained in:
Alexandros Frantzis 2024-01-26 09:45:14 +02:00 committed by Alexandre Julliard
parent 8169c4d040
commit fe1f3e277d
2 changed files with 4 additions and 0 deletions

View file

@ -670,6 +670,9 @@ static void wayland_set_cursor(HWND hwnd, HCURSOR hcursor, BOOL use_hcursor)
if ((surface = wayland_surface_lock_hwnd(hwnd)))
{
scale = surface->window.scale;
if (use_hcursor) surface->hcursor = hcursor;
else hcursor = surface->hcursor;
use_hcursor = TRUE;
pthread_mutex_unlock(&surface->mutex);
}
else

View file

@ -201,6 +201,7 @@ struct wayland_surface
struct wayland_window_config window;
struct wayland_client_surface *client;
int buffer_width, buffer_height;
HCURSOR hcursor;
};
struct wayland_shm_buffer