Add a hook to unset the client in the open menu frame instead of closing it
authorMikael Magnusson <mikachu@gmail.com>
Mon, 18 Jan 2010 15:48:00 +0000 (16:48 +0100)
committerDana Jansens <danakj@orodu.net>
Mon, 8 Feb 2010 18:41:46 +0000 (13:41 -0500)
Also nukes menu_frame_hide_all_client() as it is now unused.

openbox/client_menu.c
openbox/menu.c
openbox/menuframe.c

index 6c3147a..3876521 100644 (file)
@@ -118,7 +118,8 @@ static void client_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
     gint x, y;
     gulong ignore_start;
 
     gint x, y;
     gulong ignore_start;
 
-    g_assert(c);
+    if (!c)
+        return;
 
     if (!config_focus_under_mouse)
         ignore_start = event_start_ignore_all_enters();
 
     if (!config_focus_under_mouse)
         ignore_start = event_start_ignore_all_enters();
index bc11e55..22c1046 100644 (file)
@@ -62,13 +62,6 @@ static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut,
                                gchar **strippedlabel, guint *position,
                                gboolean *always_show);
 
                                gchar **strippedlabel, guint *position,
                                gboolean *always_show);
 
-static void client_dest(ObClient *client, gpointer data)
-{
-    /* menus can be associated with a client, so close any that are since
-       we are disappearing now */
-    menu_frame_hide_all_client(client);
-}
-
 void menu_startup(gboolean reconfig)
 {
     xmlDocPtr doc;
 void menu_startup(gboolean reconfig)
 {
     xmlDocPtr doc;
@@ -112,16 +105,10 @@ void menu_startup(gboolean reconfig)
     }
 
     g_assert(menu_parse_state.parent == NULL);
     }
 
     g_assert(menu_parse_state.parent == NULL);
-
-    if (!reconfig)
-        client_add_destroy_notify(client_dest, NULL);
 }
 
 void menu_shutdown(gboolean reconfig)
 {
 }
 
 void menu_shutdown(gboolean reconfig)
 {
-    if (!reconfig)
-        client_remove_destroy_notify(client_dest);
-
     parse_shutdown(menu_parse_inst);
     menu_parse_inst = NULL;
 
     parse_shutdown(menu_parse_inst);
     menu_parse_inst = NULL;
 
index a3c3634..36fdc5f 100644 (file)
@@ -62,6 +62,19 @@ static Window createWindow(Window parent, gulong mask,
                          RrVisual(ob_rr_inst), mask, attrib);
 }
 
                          RrVisual(ob_rr_inst), mask, attrib);
 }
 
+static void client_dest(ObClient *client, gpointer data)
+{
+    GList *it;
+
+    /* menus can be associated with a client, so null those refs since
+       we are disappearing now */
+    for (it = menu_frame_visible; it; it = g_list_next(it)) {
+        ObMenuFrame *f = it->data;
+        if (f->client == client)
+            f->client = NULL;
+    }
+}
+
 void menu_frame_startup(gboolean reconfig)
 {
     gint i;
 void menu_frame_startup(gboolean reconfig)
 {
     gint i;
@@ -76,6 +89,7 @@ void menu_frame_startup(gboolean reconfig)
 
     if (reconfig) return;
 
 
     if (reconfig) return;
 
+    client_add_destroy_notify(client_dest, NULL);
     menu_frame_map = g_hash_table_new(g_int_hash, g_int_equal);
 }
 
     menu_frame_map = g_hash_table_new(g_int_hash, g_int_equal);
 }
 
@@ -85,6 +99,7 @@ void menu_frame_shutdown(gboolean reconfig)
 
     if (reconfig) return;
 
 
     if (reconfig) return;
 
+    client_remove_destroy_notify(client_dest);
     g_hash_table_destroy(menu_frame_map);
 }
 
     g_hash_table_destroy(menu_frame_map);
 }
 
@@ -1079,22 +1094,6 @@ void menu_frame_hide_all(void)
         menu_frame_hide(it->data);
 }
 
         menu_frame_hide(it->data);
 }
 
-void menu_frame_hide_all_client(ObClient *client)
-{
-    GList *it = g_list_last(menu_frame_visible);
-    if (it) {
-        ObMenuFrame *f = it->data;
-        if (f->client == client) {
-            if (config_submenu_show_delay) {
-                /* remove any submenu open requests */
-                ob_main_loop_timeout_remove(ob_main_loop,
-                                            submenu_show_timeout);
-            }
-            menu_frame_hide(f);
-        }
-    }
-}
-
 ObMenuFrame* menu_frame_under(gint x, gint y)
 {
     ObMenuFrame *ret = NULL;
 ObMenuFrame* menu_frame_under(gint x, gint y)
 {
     ObMenuFrame *ret = NULL;