]> Dogcows Code - chaz/openbox/blobdiff - openbox/menuframe.c
add a notifier for clients changing desktops. use it to update the send-to menu if...
[chaz/openbox] / openbox / menuframe.c
index b04fda55a746579a7f75fbf1047fdcf2b63890ce..768176abcb218cae14fa026f4cce42675b3e197f 100644 (file)
@@ -824,13 +824,18 @@ static void menu_frame_update(ObMenuFrame *self)
         fit = n;
     }
 
-    menu_frame_render(self);
-
-    /* make the menu fit on the screen. at most we call render twice, at least
-       not like n times or sometime */
+    /* * make the menu fit on the screen */
+
+    /* calculate the height of the menu */
+    h = 0;
+    for (fit = self->entries; fit; fit = g_list_next(fit))
+        h += menu_entry_frame_get_height(fit->data,
+                                         fit == self->entries,
+                                         g_list_next(fit) == NULL);
+    /* add the border at the top and bottom */
+    h += ob_rr_theme->mbwidth * 2;
 
     a = screen_physical_area_monitor(self->monitor);
-    h = self->area.height;
 
     if (h > a->height) {
         GList *flast, *tmp;
@@ -854,8 +859,6 @@ static void menu_frame_update(ObMenuFrame *self)
             menu_entry_frame_free(tmp->data);
             self->entries = g_list_delete_link(self->entries, tmp);
 
-            menu_frame_render(self);
-
             /* only the first one that we see is the last entry in the menu */
             last_entry = FALSE;
         };
@@ -881,10 +884,9 @@ static void menu_frame_update(ObMenuFrame *self)
             /* add our More... entry to the frame */
             self->entries = g_list_append(self->entries, more_frame);
         }
-
-        /* render again */
-        menu_frame_render(self);
     }
+
+    menu_frame_render(self);
 }
 
 static gboolean menu_frame_is_visible(ObMenuFrame *self)
@@ -922,6 +924,9 @@ static gboolean menu_frame_show(ObMenuFrame *self)
 
     menu_frame_visible = g_list_prepend(menu_frame_visible, self);
 
+    if (self->menu->show_func)
+        self->menu->show_func(self, self->menu->data);
+
     return TRUE;
 }
 
@@ -1004,6 +1009,9 @@ void menu_frame_hide(ObMenuFrame *self)
     if (!it)
         return;
 
+    if (self->menu->hide_func)
+        self->menu->hide_func(self, self->menu->data);
+
     if (self->child)
         menu_frame_hide(self->child);
 
This page took 0.025051 seconds and 4 git commands to generate.