mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
gdk: add a sanity check for events
Before delivering events to GTK, make sure they're sane. For now, this means making sure the surface and device are from the same display.
This commit is contained in:
parent
6f0b47681b
commit
134e159bc9
@ -146,15 +146,48 @@ gdk_event_class_init (GdkEventClass *klass)
|
||||
g_object_class_install_properties (object_class, N_PROPS, event_props);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_event_emit (GdkEvent *event)
|
||||
gboolean
|
||||
check_event_sanity (GdkEvent *event)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkSurface *surface;
|
||||
GdkDevice *device;
|
||||
|
||||
display = gdk_event_get_display (event);
|
||||
surface = gdk_event_get_surface (event);
|
||||
device = gdk_event_get_device (event);
|
||||
|
||||
if (gdk_event_get_event_type (event) == GDK_NOTHING)
|
||||
{
|
||||
g_warning ("Ignoring GDK_NOTHING events; they're good for nothing");
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (surface && display != gdk_surface_get_display (surface))
|
||||
{
|
||||
char *type = g_enum_to_string (GDK_TYPE_EVENT_TYPE, event->any.type);
|
||||
g_warning ("Event of type %s with mismatched surface display", type);
|
||||
g_free (type);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (device && display != gdk_device_get_display (device))
|
||||
{
|
||||
char *type = g_enum_to_string (GDK_TYPE_EVENT_TYPE, event->any.type);
|
||||
g_warning ("Event of type %s with mismatched device display", type);
|
||||
g_free (type);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_event_emit (GdkEvent *event)
|
||||
{
|
||||
if (!check_event_sanity (event))
|
||||
return;
|
||||
|
||||
if (gdk_drag_handle_source_event (event))
|
||||
return;
|
||||
|
||||
|
@ -645,5 +645,7 @@ void gdk_event_set_related_target (GdkEvent *event,
|
||||
GObject *user_data);
|
||||
GObject * gdk_event_get_related_target (const GdkEvent *event);
|
||||
|
||||
gboolean check_event_sanity (GdkEvent *event);
|
||||
|
||||
|
||||
#endif /* __GDK_EVENTS_PRIVATE_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user