forked from AuroraMiddleware/gtk
menus: Fix menus on non-default displays
Currently, we sometimes emit display-changed when the display changed, and sometimes we don't since the display is changed via gtk_widget_root. Listen for notify::root as well and update our display. This is a temporary fix - all display changes should go through gtk_widget_root, eventually.
This commit is contained in:
parent
737400ddbc
commit
377ec33069
@ -1054,6 +1054,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)
|
||||
{
|
||||
@ -1109,6 +1118,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;
|
||||
@ -1191,6 +1202,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);
|
||||
@ -1266,6 +1280,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,
|
||||
@ -1321,7 +1337,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);
|
||||
@ -1331,6 +1351,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