Compare commits

...

4 Commits

Author SHA1 Message Date
Matthias Clasen
2bf8faf2a0 x11: Don't pass the same device twice when creating events
I did not expect XI2, where this slave device idea
originated, to do this. But it does.
2020-05-19 16:42:33 -04:00
Matthias Clasen
391472870f events: Enforce that source device must be a slave
We were allowing backends too much leeway to create
nonsense events. Enforce that the device is NULL or
a master device, and the source device is NULL or a
slave device.
2020-05-19 15:59:15 -04:00
Matthias Clasen
76666a4204 wayland: Don't generate events with master devices as source
When emulating crossing or focus events, don't pass the
same device as master and slave. It is only one, not the
other.
2020-05-19 15:58:01 -04:00
Matthias Clasen
5053c6fcec display: Don't pass a master device as source event
When generating grab-broken events, don't pass the same
device as master and slave. It is only one, not the other.
2020-05-19 15:57:18 -04:00
4 changed files with 14 additions and 6 deletions

View File

@@ -479,7 +479,7 @@ gdk_display_put_event (GdkDisplay *display,
static void
generate_grab_broken_event (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *surface,
GdkDevice *device,
gboolean implicit,
GdkSurface *grab_surface)
@@ -492,7 +492,7 @@ generate_grab_broken_event (GdkDisplay *display,
event = gdk_grab_broken_event_new (surface,
device,
device,
NULL,
grab_surface,
implicit);

View File

@@ -416,6 +416,11 @@ gdk_event_alloc (GdkEventType event_type,
g_assert (event_type >= GDK_DELETE && event_type < GDK_EVENT_LAST);
g_assert (gdk_event_types[event_type] != G_TYPE_INVALID);
g_assert (device == NULL ||
gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER);
g_assert (source_device == NULL ||
gdk_device_get_device_type (source_device) == GDK_DEVICE_TYPE_SLAVE);
GdkEvent *event = (GdkEvent *) g_type_create_instance (gdk_event_types[event_type]);
GDK_NOTE (EVENTS, {

View File

@@ -592,7 +592,7 @@ emulate_crossing (GdkSurface *surface,
event = gdk_crossing_event_new (type,
surface,
device,
device,
NULL,
time_,
state,
x, y,
@@ -633,7 +633,7 @@ emulate_focus (GdkSurface *surface,
gboolean focus_in,
guint32 time_)
{
GdkEvent *event = gdk_focus_event_new (surface, device, device, focus_in);
GdkEvent *event = gdk_focus_event_new (surface, device, NULL, focus_in);
_gdk_wayland_display_deliver_event (gdk_surface_get_display (surface), event);
}

View File

@@ -1936,8 +1936,11 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
device = g_hash_table_lookup (device_manager->id_table,
GINT_TO_POINTER (xev->deviceid));
source_device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->sourceid));
if (xev->sourceid != xev->deviceid)
source_device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->sourceid));
else
source_device = NULL;
_gdk_device_manager_xi2_handle_focus (surface,
xev->event,