1
0
Fork 0

wayland: Use the tool's current_tablet device instead of caching it

The tablet tool is initialized with a device but if that device is later
removed we never update tool->device. This eventually causes a crash
when we're passing that device into
meta_wayland_input_invalidate_focus().

The tool keeps track of the current tablet anyway so instead of caching
this pointer in the tool, use the current tablet's device.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3642
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3959>
This commit is contained in:
Peter Hutterer 2024-08-20 12:38:52 +10:00 committed by Marge Bot
parent 2d64965a55
commit e4004a7c4f
3 changed files with 5 additions and 9 deletions

View file

@ -362,7 +362,6 @@ meta_wayland_tablet_seat_lookup_pad (MetaWaylandTabletSeat *tablet_seat,
static MetaWaylandTabletTool *
meta_wayland_tablet_seat_ensure_tool (MetaWaylandTabletSeat *tablet_seat,
ClutterInputDevice *device,
ClutterInputDeviceTool *device_tool)
{
MetaWaylandTabletTool *tool;
@ -371,7 +370,7 @@ meta_wayland_tablet_seat_ensure_tool (MetaWaylandTabletSeat *tablet_seat,
if (!tool)
{
tool = meta_wayland_tablet_tool_new (tablet_seat, device, device_tool);
tool = meta_wayland_tablet_tool_new (tablet_seat, device_tool);
g_hash_table_insert (tablet_seat->tools, device_tool, tool);
}
@ -399,7 +398,7 @@ meta_wayland_tablet_seat_update (MetaWaylandTabletSeat *tablet_seat,
device_tool = clutter_event_get_device_tool (event);
if (device && device_tool)
tool = meta_wayland_tablet_seat_ensure_tool (tablet_seat, device, device_tool);
tool = meta_wayland_tablet_seat_ensure_tool (tablet_seat, device_tool);
if (!tool)
return;

View file

@ -41,7 +41,6 @@
struct _MetaWaylandTabletTool
{
MetaWaylandTabletSeat *seat;
ClutterInputDevice *device;
ClutterInputDeviceTool *device_tool;
struct wl_list resource_list;
struct wl_list focus_resource_list;
@ -423,7 +422,6 @@ tool_cursor_prepare_at (MetaCursorSpriteXcursor *sprite_xcursor,
MetaWaylandTabletTool *
meta_wayland_tablet_tool_new (MetaWaylandTabletSeat *seat,
ClutterInputDevice *device,
ClutterInputDeviceTool *device_tool)
{
MetaWaylandCompositor *compositor =
@ -435,7 +433,6 @@ meta_wayland_tablet_tool_new (MetaWaylandTabletSeat *seat,
tool = g_new0 (MetaWaylandTabletTool, 1);
tool->seat = seat;
tool->device = device;
tool->device_tool = device_tool;
wl_list_init (&tool->resource_list);
wl_list_init (&tool->focus_resource_list);
@ -634,7 +631,8 @@ meta_wayland_tablet_tool_set_current_surface (MetaWaylandTabletTool *tool,
tablet_seat = tool->seat;
input = meta_wayland_seat_get_input (tablet_seat->seat);
meta_wayland_input_invalidate_focus (input, tool->device, NULL);
if (tool->current_tablet)
meta_wayland_input_invalidate_focus (input, tool->current_tablet->device, NULL);
}
static void
@ -1002,7 +1000,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->device;
*device_out = tool->current_tablet ? NULL : tool->current_tablet->device;
if (x)
*x = tool->grab_x;

View file

@ -29,7 +29,6 @@
#include "wayland/meta-wayland-types.h"
MetaWaylandTabletTool * meta_wayland_tablet_tool_new (MetaWaylandTabletSeat *seat,
ClutterInputDevice *device,
ClutterInputDeviceTool *device_tool);
void meta_wayland_tablet_tool_free (MetaWaylandTabletTool *tool);