From effec94613aec6570e1797dbea533ec3643262be Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 28 Oct 2002 05:35:30 +0000 Subject: [PATCH] store the window menu on the display and blow it away when a window 2002-10-28 Havoc Pennington * src/window.c, src/display.c: store the window menu on the display and blow it away when a window closes, so we don't get funny stuck menus. Patch from Martin Garton #87514 --- ChangeLog | 6 ++++++ src/display.c | 5 ++++- src/display.h | 3 +++ src/window.c | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6b637944e..21aa33013 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-10-28 Havoc Pennington + + * src/window.c, src/display.c: store the window menu on the + display and blow it away when a window closes, so we don't + get funny stuck menus. Patch from Martin Garton #87514 + 2002-10-27 Anders Carlsson * configure.in: Make XRandr detection work better. diff --git a/src/display.c b/src/display.c index 033c8101e..033d67e9a 100644 --- a/src/display.c +++ b/src/display.c @@ -394,8 +394,11 @@ meta_display_open (const char *name) display->groups_by_leader = NULL; + display->window_with_menu = NULL; + display->window_menu = NULL; + display->screens = NULL; - + #ifdef HAVE_STARTUP_NOTIFICATION display->sn_display = sn_display_new (display->xdisplay, sn_error_trap_push, diff --git a/src/display.h b/src/display.h index faba61e34..b748a1adf 100644 --- a/src/display.h +++ b/src/display.h @@ -259,6 +259,9 @@ struct _MetaDisplay /* Managed by group.c */ GHashTable *groups_by_leader; + /* currently-active window menu if any */ + MetaWindowMenu *window_menu; + MetaWindow *window_with_menu; #ifdef HAVE_STARTUP_NOTIFICATION /* This is at the end in case someone doesn't include config.h before this file diff --git a/src/window.c b/src/window.c index 0c042e461..cddfbdd6f 100644 --- a/src/window.c +++ b/src/window.c @@ -820,6 +820,13 @@ meta_window_free (MetaWindow *window) meta_verbose ("Unmanaging 0x%lx\n", window->xwindow); + if (window->display->window_with_menu == window) + { + meta_ui_window_menu_free (window->display->window_menu); + window->display->window_menu = NULL; + window->display->window_with_menu = NULL; + } + if (destroying_windows_disallowed > 0) meta_bug ("Tried to destroy window %s while destruction was not allowed\n", window->desc); @@ -5884,6 +5891,12 @@ menu_callback (MetaWindowMenu *menu, { meta_verbose ("Menu callback on nonexistent window\n"); } + + if (display->window_menu == menu) + { + display->window_menu = NULL; + display->window_with_menu = NULL; + } meta_ui_window_menu_free (menu); } @@ -5950,7 +5963,11 @@ meta_window_show_menu (MetaWindow *window, menu_callback, NULL); + window->display->window_menu = menu; + window->display->window_with_menu = window; + meta_verbose ("Popping up window menu for %s\n", window->desc); + meta_ui_window_menu_popup (menu, root_x, root_y, button, timestamp); }