Commit 7cc3eb04 authored by Rob Bradford's avatar Rob Bradford

menu: Deactivate the menu if the GdkWindow is withdrawn

If the display server or GDK hides the window - fire the "deactivate" signal
to ensure that the internal state is consistent.

This patch also ensures that the "deactivate" signal will not be fired for a
menu that is not active.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=670881
parent 5badf835
...@@ -1018,6 +1018,15 @@ gtk_menu_window_event (GtkWidget *window, ...@@ -1018,6 +1018,15 @@ gtk_menu_window_event (GtkWidget *window,
case GDK_KEY_RELEASE: case GDK_KEY_RELEASE:
handled = gtk_widget_event (menu, event); handled = gtk_widget_event (menu, event);
break; break;
case GDK_WINDOW_STATE:
/* Window for the menu has been closed by the display server or by GDK.
* Update the internal state as if the user had clicked outside the
* menu
*/
if (event->window_state.new_window_state & GDK_WINDOW_STATE_WITHDRAWN &&
event->window_state.changed_mask & GDK_WINDOW_STATE_WITHDRAWN)
gtk_menu_shell_deactivate (GTK_MENU_SHELL(menu));
break;
default: default:
break; break;
} }
......
...@@ -612,7 +612,8 @@ gtk_menu_shell_deactivate (GtkMenuShell *menu_shell) ...@@ -612,7 +612,8 @@ gtk_menu_shell_deactivate (GtkMenuShell *menu_shell)
{ {
g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell)); g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
g_signal_emit (menu_shell, menu_shell_signals[DEACTIVATE], 0); if (menu_shell->priv->active)
g_signal_emit (menu_shell, menu_shell_signals[DEACTIVATE], 0);
} }
static void static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment