X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fmenuframe.c;h=62a68ae9fbdf43fdd99cdb5644ac2677e80d05c3;hb=e6a8595fc1d1a8f207875c5f1495c5eec56bbe0c;hp=1362d9632182d967bf1f0bd7b112291ba94bfc2a;hpb=9609c7f5ecadc488c450433925921ee2de44f033;p=chaz%2Fopenbox diff --git a/openbox/menuframe.c b/openbox/menuframe.c index 1362d963..62a68ae9 100644 --- a/openbox/menuframe.c +++ b/openbox/menuframe.c @@ -23,6 +23,7 @@ #include "screen.h" #include "grab.h" #include "openbox.h" +#include "mainloop.h" #include "config.h" #include "render/theme.h" @@ -43,6 +44,7 @@ static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry, static void menu_entry_frame_free(ObMenuEntryFrame *self); static void menu_frame_render(ObMenuFrame *self); static void menu_frame_update(ObMenuFrame *self); +static gboolean menu_entry_frame_submenu_timeout(gpointer data); static Window createWindow(Window parent, gulong mask, XSetWindowAttributes *attrib) @@ -65,8 +67,9 @@ ObMenuFrame* menu_frame_new(ObMenu *menu, ObClient *client) self->client = client; attr.event_mask = FRAME_EVENTMASK; + attr.save_under = True; self->window = createWindow(RootWindow(ob_display, ob_screen), - CWEventMask, &attr); + CWEventMask | CWSaveUnder, &attr); attr.event_mask = TITLE_EVENTMASK; self->title = createWindow(self->window, CWEventMask, &attr); self->items = createWindow(self->window, 0, NULL); @@ -187,7 +190,6 @@ void menu_frame_move(ObMenuFrame *self, gint x, gint y) void menu_frame_move_on_screen(ObMenuFrame *self) { Rect *a = NULL; - guint i; gint dx = 0, dy = 0; gint pos, half; @@ -626,6 +628,16 @@ gboolean menu_frame_show(ObMenuFrame *self, ObMenuFrame *parent) menu_frame_update(self); menu_frame_visible = g_list_prepend(menu_frame_visible, self); + + if (config_menu_middle) { + if (self->parent) + menu_frame_move(self, self->area.x, self->area.y + - self->area.height/2 + + self->item_h/2); + else if (self->show_title) + menu_frame_move(self, self->area.x - self->area.width/2, + self->area.y - self->title_h*3/4); + } menu_frame_move_on_screen(self); @@ -663,6 +675,11 @@ void menu_frame_hide(ObMenuFrame *self) void menu_frame_hide_all() { + if (config_submenu_show_delay) { + /* remove any submenu open requests */ + ob_main_loop_timeout_remove(ob_main_loop, + menu_entry_frame_submenu_timeout); + } GList *it = g_list_last(menu_frame_visible); if (it) menu_frame_hide(it->data); @@ -717,6 +734,12 @@ ObMenuEntryFrame* menu_entry_frame_under(gint x, gint y) return ret; } +static gboolean menu_entry_frame_submenu_timeout(gpointer data) +{ + menu_entry_frame_show_submenu((ObMenuEntryFrame*)data); + return FALSE; +} + void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry) { ObMenuEntryFrame *old = self->selected; @@ -726,6 +749,12 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry) entry = old; if (old == entry) return; + + if (config_submenu_show_delay) { + /* remove any submenu open requests */ + ob_main_loop_timeout_remove(ob_main_loop, + menu_entry_frame_submenu_timeout); + } self->selected = entry; @@ -737,8 +766,18 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry) if (self->selected) { menu_entry_frame_render(self->selected); - if (self->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) - menu_entry_frame_show_submenu(self->selected); + if (self->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) { + if (config_submenu_show_delay) { + /* 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, + NULL); + } else { + menu_entry_frame_show_submenu(self->selected); + } + } } } @@ -751,10 +790,14 @@ void menu_entry_frame_show_submenu(ObMenuEntryFrame *self) f = menu_frame_new(self->entry->data.submenu.submenu, self->frame->client); menu_frame_move(f, - self->frame->area.x + self->frame->area.width - - ob_rr_theme->menu_overlap - ob_rr_theme->bwidth, - self->frame->area.y + self->frame->title_h + - self->area.y + ob_rr_theme->menu_overlap); + self->frame->area.x + + self->frame->area.width + - ob_rr_theme->menu_overlap + - ob_rr_theme->bwidth, + self->frame->area.y + + self->frame->title_h + + self->area.y + + (config_menu_middle ? 1 : ob_rr_theme->menu_overlap)); menu_frame_show(f, self->frame); }