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
This commit is contained in:
Rob Bradford 2012-02-27 12:35:25 +00:00
parent 5badf835e9
commit 7cc3eb04ec
2 changed files with 11 additions and 1 deletions

View File

@ -1018,6 +1018,15 @@ gtk_menu_window_event (GtkWidget *window,
case GDK_KEY_RELEASE:
handled = gtk_widget_event (menu, event);
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:
break;
}

View File

@ -612,7 +612,8 @@ gtk_menu_shell_deactivate (GtkMenuShell *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