[gtk+] menu: Deactivate the menu if the GdkWindow is withdrawn
- From: Rob Bradford <rbradford src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] menu: Deactivate the menu if the GdkWindow is withdrawn
- Date: Wed, 29 Feb 2012 12:19:07 +0000 (UTC)
commit 7cc3eb04ec5c77f01f25f21ef88723e00a96620e
Author: Rob Bradford <rob linux intel com>
Date: Mon Feb 27 12:35:25 2012 +0000
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
gtk/gtkmenu.c | 9 +++++++++
gtk/gtkmenushell.c | 3 ++-
2 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index dada329..92618c2 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -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;
}
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index da7c8ca..b74f424 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]