forked from AuroraMiddleware/gtk
Merge branch 'inspector-menu-fix' into 'master'
Inspector menu fix See merge request GNOME/gtk!804
This commit is contained in:
commit
78d254370c
@ -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__ */
|
||||
|
@ -293,6 +293,7 @@ gdk_seat_grab (GdkSeat *seat,
|
||||
|
||||
g_return_val_if_fail (GDK_IS_SEAT (seat), GDK_GRAB_FAILED);
|
||||
g_return_val_if_fail (GDK_IS_SURFACE (surface), GDK_GRAB_FAILED);
|
||||
g_return_val_if_fail (gdk_surface_get_display (surface) == gdk_seat_get_display (seat), GDK_GRAB_FAILED);
|
||||
|
||||
capabilities &= GDK_SEAT_CAPABILITY_ALL;
|
||||
g_return_val_if_fail (capabilities != GDK_SEAT_CAPABILITY_NONE, GDK_GRAB_FAILED);
|
||||
|
@ -151,6 +151,9 @@ _gdk_wayland_display_deliver_event (GdkDisplay *display,
|
||||
{
|
||||
GList *node;
|
||||
|
||||
if (!check_event_sanity (event))
|
||||
g_warning ("Snap! delivering insane events\n");
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
_gdk_windowing_got_event (display, node, event,
|
||||
_gdk_display_get_next_serial (display));
|
||||
|
@ -1053,6 +1053,15 @@ attach_widget_display_changed (GtkWidget *attach_widget,
|
||||
menu_change_display (menu, gtk_widget_get_display (attach_widget));
|
||||
}
|
||||
|
||||
static void
|
||||
attach_widget_root_changed (GObject *attach_widget,
|
||||
GParamSpec *pspec,
|
||||
gpointer menu)
|
||||
{
|
||||
if (!g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-display"))
|
||||
menu_change_display (menu, gtk_widget_get_display (GTK_WIDGET (attach_widget)));
|
||||
}
|
||||
|
||||
static void
|
||||
menu_toplevel_attached_to (GtkWindow *toplevel, GParamSpec *pspec, GtkMenu *menu)
|
||||
{
|
||||
@ -1108,6 +1117,8 @@ gtk_menu_attach_to_widget (GtkMenu *menu,
|
||||
|
||||
g_signal_connect (attach_widget, "display-changed",
|
||||
G_CALLBACK (attach_widget_display_changed), menu);
|
||||
g_signal_connect (attach_widget, "notify::root",
|
||||
G_CALLBACK (attach_widget_root_changed), menu);
|
||||
attach_widget_display_changed (attach_widget, NULL, menu);
|
||||
|
||||
data->detacher = detacher;
|
||||
@ -1190,6 +1201,9 @@ gtk_menu_detach (GtkMenu *menu)
|
||||
g_signal_handlers_disconnect_by_func (data->attach_widget,
|
||||
(gpointer) attach_widget_display_changed,
|
||||
menu);
|
||||
g_signal_handlers_disconnect_by_func (data->attach_widget,
|
||||
(gpointer) attach_widget_root_changed,
|
||||
menu);
|
||||
|
||||
if (data->detacher)
|
||||
data->detacher (data->attach_widget, menu);
|
||||
@ -1265,6 +1279,8 @@ popup_grab_on_surface (GdkSurface *surface,
|
||||
GdkGrabStatus status;
|
||||
GdkSeat *seat;
|
||||
|
||||
g_return_val_if_fail (gdk_surface_get_display (surface) == gdk_device_get_display (pointer), FALSE);
|
||||
|
||||
seat = gdk_device_get_seat (pointer);
|
||||
status = gdk_seat_grab (seat, surface,
|
||||
GDK_SEAT_CAPABILITY_ALL, TRUE,
|
||||
@ -1320,7 +1336,11 @@ gtk_menu_popup_internal (GtkMenu *menu,
|
||||
device = NULL;
|
||||
|
||||
if (device == NULL)
|
||||
device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
|
||||
{
|
||||
device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
|
||||
g_return_if_fail (gdk_device_get_display (device) == display);
|
||||
}
|
||||
|
||||
|
||||
widget = GTK_WIDGET (menu);
|
||||
menu_shell = GTK_MENU_SHELL (menu);
|
||||
@ -1330,6 +1350,8 @@ gtk_menu_popup_internal (GtkMenu *menu,
|
||||
else
|
||||
pointer = device;
|
||||
|
||||
g_return_if_fail (gdk_device_get_display (pointer) == display);
|
||||
|
||||
menu_shell->priv->parent_menu_shell = parent_menu_shell;
|
||||
|
||||
/* Find the last viewable ancestor, and make an X grab on it
|
||||
|
Loading…
Reference in New Issue
Block a user