gdk: Keep a reference on the last source device

This device may go away, which means we have a pointer to a possibly
stale object. Keep a reference here, and let future events bring this
accounting up-to-date when the mouse pointer is next updated via other
device.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/855
This commit is contained in:
Carlos Garnacho 2020-08-31 15:41:07 +02:00
parent d2dd065b95
commit a98001978c
2 changed files with 2 additions and 1 deletions

View File

@ -278,6 +278,7 @@ free_pointer_info (GdkPointerWindowInfo *info)
{ {
if (info->toplevel_under_pointer) if (info->toplevel_under_pointer)
g_object_unref (info->toplevel_under_pointer); g_object_unref (info->toplevel_under_pointer);
g_clear_object (&info->last_slave);
g_slice_free (GdkPointerWindowInfo, info); g_slice_free (GdkPointerWindowInfo, info);
} }

View File

@ -9931,7 +9931,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
if (source_device != pointer_info->last_slave && if (source_device != pointer_info->last_slave &&
gdk_device_get_device_type (source_device) == GDK_DEVICE_TYPE_SLAVE) gdk_device_get_device_type (source_device) == GDK_DEVICE_TYPE_SLAVE)
pointer_info->last_slave = source_device; g_set_object (&pointer_info->last_slave, source_device);
else if (pointer_info->last_slave) else if (pointer_info->last_slave)
source_device = pointer_info->last_slave; source_device = pointer_info->last_slave;
} }