all repos — openbox @ 574dd66b326bb3c5893b6bf6bfe7307229def653

openbox fork - make it a bit more like ryudo

More menu changes to facilitate plugins.
Scott Moynes smoynes@nexus.carleton.ca
commit

574dd66b326bb3c5893b6bf6bfe7307229def653

parent

6a237b91bcbc2c25f2bf8d368535430ba6a1bf26

3 files changed, 52 insertions(+), 19 deletions(-)

jump to
M openbox/menu.copenbox/menu.c

@@ -12,6 +12,8 @@ #define TITLE_EVENTMASK (ButtonPressMask | ButtonMotionMask)

#define ENTRY_EVENTMASK (EnterWindowMask | LeaveWindowMask | \ ButtonPressMask | ButtonReleaseMask) +void menu_control_show(Menu *self, int x, int y, Client *client); + void menu_destroy_hash_key(gpointer data) { g_free(data);

@@ -91,7 +93,8 @@ mask, attrib);

} -Menu *menu_new(char *label, char *name, Menu *parent) +Menu *menu_new_full(char *label, char *name, Menu *parent, + menu_controller_show show, menu_controller_update update) { XSetWindowAttributes attrib; Menu *self;

@@ -105,6 +108,12 @@ self->entries = NULL;

self->shown = FALSE; self->invalid = FALSE; /* default controllers? */ + + self->show = show; + self->hide = NULL; + self->update = update; + self->mouseover = NULL; + self->selected = NULL; attrib.override_redirect = TRUE; attrib.event_mask = FRAME_EVENTMASK;

@@ -195,20 +204,21 @@ g_warning("Attempted to show menu '%s' but it does not exist.",

name); return; } - - if(self->invalid) { - menu_render(self); - } - XMoveWindow(ob_display, self->frame, x, y); - + if (self->invalid) { + if (self->update) { + self->update(self); + } else { + menu_render(self); + } + } + self->client = client; - if (!self->shown) { - stacking_raise_internal(self->frame); - XMapWindow(ob_display, self->frame); -/* grab_pointer_window(TRUE, None, self->frame);*/ - self->shown = TRUE; + if (self->show) { + self->show(self, x, y, client); + } else { + menu_control_show(self, x, y, client); } }

@@ -268,3 +278,17 @@ while (m->parent) m = m->parent;

menu_hide(m); } } + +/* + Default menu controller action for showing. +*/ + +void menu_control_show(Menu *self, int x, int y, Client *client) { + XMoveWindow(ob_display, self->frame, x, y); + + if (!self->shown) { + stacking_raise_internal(self->frame); + XMapWindow(ob_display, self->frame); + self->shown = TRUE; + } +}
M openbox/menu.hopenbox/menu.h

@@ -8,23 +8,28 @@ #include <glib.h>

extern GHashTable *menu_map; +struct Menu; + +typedef void(*menu_controller_show)(struct Menu *self, int x, int y, Client *); +typedef void(*menu_controller_update)(struct Menu *self); + typedef struct Menu { char *label; char *name; GList *entries; - /* GList *tail; */ - /* ? */ gboolean shown; gboolean invalid; struct Menu *parent; - /* waste o' pointers */ - void (*show)( /* some bummu */); + /* place a menu on screen */ + menu_controller_show show; void (*hide)( /* some bummu */); - void (*update)( /* some bummu */); + + /* render a menu */ + menu_controller_update update; void (*mouseover)( /* some bummu */); void (*selected)( /* some bummu */);

@@ -76,7 +81,11 @@

void menu_startup(); void menu_shutdown(); -Menu *menu_new(char *label, char *name, Menu *parent); +#define menu_new(l, n, p) \ + menu_new_full(l, n, p, NULL, NULL) + +Menu *menu_new_full(char *label, char *name, Menu *parent, + menu_controller_show show, menu_controller_update update); void menu_free(char *name); void menu_show(char *name, int x, int y, Client *client);
M openbox/menu_render.copenbox/menu_render.c

@@ -1,4 +1,4 @@

-// Functions for default rendering of menus. Might become pluginnable +/* Functions for default rendering of menus. Might become pluginnable */ #include "menu.h" #include "openbox.h"