Alexandros Frantzis (@afrantzis) commented about dlls/winewayland.drv/wayland_pointer.c:
goto unlock;
if (!(surface = data->wayland_surface))
{
wayland_win_data_release(data);
goto unlock;
}
wayland_surface_coords_from_window(surface,
cursor_pos.x - surface->window.rect.left,
cursor_pos.y - surface->window.rect.top,
&warp_x, &warp_y);
wayland_win_data_release(data);
zwp_locked_pointer_v1_set_cursor_position_hint(
pointer->zwp_locked_pointer_v1,
wl_fixed_from_int(warp_x),
wl_fixed_from_int(warp_y));
wl_surface_commit(wl_surface);
Complex surface state changes can be performed by arbitrary threads (notably GL/Vulkan threads), and we want to ensure that such changes are only committed "atomically" when complete. To ensure this we perform such changes and commits only while holding the win_data for the corresponding window. In this case it's good enough to just guard the commit itself, since the cursor position hint itself doesn't interact with other state. Going back to the previous point, we would prefer not to acquire the win_data lock while holding the pointer lock, so this needs to be done outside the `wayland_pointer_update_constraint` function.
Actually, I noticed that we also do a `set_region` (which is also double-buffered state) in this function without any corresponding commit. I guess this tends to work because we eventually perform some commit for other reasons (e.g., redraws), but in any case it's better to have an explicit commit.
Again, we can ignore the case of `wayland_pointer_clear_constraint` since this is only called on surface destruction.