From 3bc3740a9e49ddb9b7a4ada9ba496b93509d24fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 17 Sep 2024 13:29:03 +0200 Subject: [PATCH] wayland/tablet-tool: Fix grabbing tablet devices The NULL check was inverted, meaning we'd grab with no leader device. That meant updates coming from the what-should-have-been leader device getting lost because incorrectly being classified as non-leader of the grab. Fix this by only allowing to grab if we have a device, and always mark the current tool device as the grab leader. Fixes: e4004a7c4f ("wayland: Use the tool's current_tablet device instead of caching it") Part-of: --- src/wayland/meta-wayland-tablet-tool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c index ca0cd59b9..c8ba66fc1 100644 --- a/src/wayland/meta-wayland-tablet-tool.c +++ b/src/wayland/meta-wayland-tablet-tool.c @@ -983,6 +983,9 @@ meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool, MetaWaylandSurface *surface, uint32_t serial) { + if (!tool->current_tablet || !tool->current_tablet->device) + return FALSE; + return ((tool->down_serial == serial || tool->button_serial == serial) && tablet_tool_can_grab_surface (tool, surface)); } @@ -1000,7 +1003,7 @@ meta_wayland_tablet_tool_get_grab_info (MetaWaylandTabletTool *tool, meta_wayland_tablet_tool_can_grab_surface (tool, surface, serial)) { if (device_out) - *device_out = tool->current_tablet ? NULL : tool->current_tablet->device; + *device_out = tool->current_tablet->device; if (x) *x = tool->grab_x;