]> Dogcows Code - chaz/openbox/blobdiff - openbox/menuframe.c
Move the main loop out into the libobt
[chaz/openbox] / openbox / menuframe.c
index fdb24afbad7b388ab6b89a279f20c6ef4092b12b..18f1a1b7e3e6c72366ae190205647b43d9a7bc41 100644 (file)
@@ -21,9 +21,9 @@
 #include "client.h"
 #include "menu.h"
 #include "screen.h"
+#include "actions.h"
 #include "grab.h"
 #include "openbox.h"
-#include "mainloop.h"
 #include "config.h"
 #include "render/theme.h"
 
@@ -400,6 +400,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
         text_a->texture[0].data.text.string = self->entry->data.normal.label;
         if (self->entry->data.normal.shortcut &&
             (self->frame->menu->show_all_shortcuts ||
+             self->entry->data.normal.shortcut_always_show ||
              self->entry->data.normal.shortcut_position > 0))
         {
             text_a->texture[0].data.text.shortcut = TRUE;
@@ -415,6 +416,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
         sub = self->entry->data.submenu.submenu;
         text_a->texture[0].data.text.string = sub ? sub->title : "";
         if (sub->shortcut && (self->frame->menu->show_all_shortcuts ||
+                              sub->shortcut_always_show ||
                               sub->shortcut_position > 0))
         {
             text_a->texture[0].data.text.shortcut = TRUE;
@@ -602,7 +604,7 @@ static gint menu_entry_frame_get_height(ObMenuEntryFrame *self,
         if (self->entry->data.separator.label != NULL) {
             h += ob_rr_theme->menu_title_height +
                 (ob_rr_theme->mbwidth - PADDING) * 2;
+
             /* if the first entry is a labeled separator, then make its border
                overlap with the menu's outside border */
             if (first_entry)
@@ -634,9 +636,9 @@ void menu_frame_render(ObMenuFrame *self)
     STRUT_SET(self->item_margin, 0, 0, 0, 0);
 
     if (self->entries) {
-        ObMenuEntryFrame *e = self->entries->data;
         gint l, t, r, b;
 
+        e = self->entries->data;
         e->a_text_normal->texture[0].data.text.string = "";
         tw = RrMinWidth(e->a_text_normal);
         tw += 2*PADDING;
@@ -691,7 +693,8 @@ void menu_frame_render(ObMenuFrame *self)
         }
 
         RECT_SET_POINT(e->area, 0, h+e->border);
-        XMoveWindow(ob_display, e->window, e->area.x-e->border, e->area.y-e->border);
+        XMoveWindow(ob_display, e->window,
+                    e->area.x-e->border, e->area.y-e->border);
         XSetWindowBorderWidth(ob_display, e->window, e->border);
         XSetWindowBorder(ob_display, e->window,
                          RrColorPixel(ob_rr_theme->menu_border_color));
@@ -884,7 +887,7 @@ static void menu_frame_update(ObMenuFrame *self)
             more_frame = menu_entry_frame_new(more_entry, self);
             /* make it get deleted when the menu frame goes away */
             menu_entry_unref(more_entry);
-                                       
+
             /* add our More... entry to the frame */
             self->entries = g_list_append(self->entries, more_frame);
         }
@@ -940,7 +943,7 @@ static gboolean menu_frame_show(ObMenuFrame *self)
 }
 
 gboolean menu_frame_show_topmenu(ObMenuFrame *self, gint x, gint y,
-                                 gint button)
+                                 gboolean mouse)
 {
     gint px, py;
     guint i;
@@ -962,7 +965,7 @@ gboolean menu_frame_show_topmenu(ObMenuFrame *self, gint x, gint y,
     }
 
     if (self->menu->place_func)
-        self->menu->place_func(self, &x, &y, button, self->menu->data);
+        self->menu->place_func(self, &x, &y, mouse, self->menu->data);
     else
         menu_frame_place_topmenu(self, &x, &y);
 
@@ -1053,14 +1056,14 @@ static void menu_frame_hide(ObMenuFrame *self)
     menu_frame_free(self);
 }
 
-void menu_frame_hide_all()
+void menu_frame_hide_all(void)
 {
     GList *it;
 
     if (config_submenu_show_delay) {
         /* remove any submenu open requests */
-        ob_main_loop_timeout_remove(ob_main_loop,
-                                    menu_entry_frame_submenu_timeout);
+        obt_main_loop_timeout_remove(ob_main_loop,
+                                     menu_entry_frame_submenu_timeout);
     }
     if ((it = g_list_last(menu_frame_visible)))
         menu_frame_hide(it->data);
@@ -1071,8 +1074,14 @@ 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 (f->client == client) {
+            if (config_submenu_show_delay) {
+                /* remove any submenu open requests */
+                obt_main_loop_timeout_remove(ob_main_loop,
+                                             menu_entry_frame_submenu_timeout);
+            }
             menu_frame_hide(f);
+        }
     }
 }
 
@@ -1117,6 +1126,7 @@ ObMenuEntryFrame* menu_entry_frame_under(gint x, gint y)
 
 static gboolean menu_entry_frame_submenu_timeout(gpointer data)
 {
+    g_assert(menu_frame_visible);
     menu_entry_frame_show_submenu((ObMenuEntryFrame*)data);
     return FALSE;
 }
@@ -1131,11 +1141,11 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry,
         entry = old;
 
     if (old == entry) return;
-   
-    if (config_submenu_show_delay) { 
+
+    if (config_submenu_show_delay) {
         /* remove any submenu open requests */
-        ob_main_loop_timeout_remove(ob_main_loop,
-                                    menu_entry_frame_submenu_timeout);
+        obt_main_loop_timeout_remove(ob_main_loop,
+                                     menu_entry_frame_submenu_timeout);
     }
 
     self->selected = entry;
@@ -1151,11 +1161,11 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry,
         if (self->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) {
             if (config_submenu_show_delay && !immediate) {
                 /* initiate a new submenu open request */
-                ob_main_loop_timeout_add(ob_main_loop,
-                                         config_submenu_show_delay * 1000,
-                                         menu_entry_frame_submenu_timeout,
-                                         self->selected, g_direct_equal,
-                                         NULL);
+                obt_main_loop_timeout_add(ob_main_loop,
+                                          config_submenu_show_delay * 1000,
+                                          menu_entry_frame_submenu_timeout,
+                                          self->selected, g_direct_equal,
+                                          NULL);
             } else {
                 menu_entry_frame_show_submenu(self->selected);
             }
@@ -1178,7 +1188,7 @@ void menu_entry_frame_show_submenu(ObMenuEntryFrame *self)
     menu_frame_show_submenu(f, self->frame, self);
 }
 
-void menu_entry_frame_execute(ObMenuEntryFrame *self, guint state, Time time)
+void menu_entry_frame_execute(ObMenuEntryFrame *self, guint state)
 {
     if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
         self->entry->data.normal.enabled)
@@ -1199,9 +1209,10 @@ void menu_entry_frame_execute(ObMenuEntryFrame *self, guint state, Time time)
         }
 
         if (func)
-            func(entry, frame, client, state, data, time);
+            func(entry, frame, client, state, data);
         else
-            action_run(acts, client, state, time);
+            actions_run_acts(acts, OB_USER_ACTION_MENU_SELECTION,
+                             state, -1, -1, 0, OB_FRAME_CONTEXT_NONE, client);
     }
 }
 
This page took 0.025113 seconds and 4 git commands to generate.