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>
(cherry picked from commit e4004a7c4f
)
This commit is contained in:
parent
3715012588
commit
4b622fbda8
3 changed files with 5 additions and 9 deletions
|
@ -356,7 +356,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;
|
||||
|
@ -365,7 +364,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);
|
||||
}
|
||||
|
||||
|
@ -393,7 +392,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;
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
struct _MetaWaylandTabletTool
|
||||
{
|
||||
MetaWaylandTabletSeat *seat;
|
||||
ClutterInputDevice *device;
|
||||
ClutterInputDeviceTool *device_tool;
|
||||
struct wl_list resource_list;
|
||||
struct wl_list focus_resource_list;
|
||||
|
@ -424,7 +423,6 @@ tool_cursor_prepare_at (MetaCursorSpriteXcursor *sprite_xcursor,
|
|||
|
||||
MetaWaylandTabletTool *
|
||||
meta_wayland_tablet_tool_new (MetaWaylandTabletSeat *seat,
|
||||
ClutterInputDevice *device,
|
||||
ClutterInputDeviceTool *device_tool)
|
||||
{
|
||||
MetaWaylandCompositor *compositor =
|
||||
|
@ -436,7 +434,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);
|
||||
|
@ -635,7 +632,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
|
||||
|
@ -1003,7 +1001,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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue