all repos — openbox @ a116f2c6310db702e377e9cd1a95c9a980aba5ae

openbox fork - make it a bit more like ryudo

Menu data structures basically completed.
Need the engine support still, parser, and controllers.
Scott Moynes smoynes@nexus.carleton.ca
commit

a116f2c6310db702e377e9cd1a95c9a980aba5ae

parent

7f5514aeb7bb8d84c7b038a08a57ee2d55e310f1

5 files changed, 96 insertions(+), 19 deletions(-)

jump to
M openbox/Makefile.amopenbox/Makefile.am

@@ -27,11 +27,11 @@ openbox3_LDADD=@LIBINTL@ ../render/librender.a

openbox3_LDFLAGS=-export-dynamic openbox3_SOURCES=client.c event.c extensions.c focus.c frame.c openbox.c \ prop.c screen.c stacking.c xerror.c timer.c dispatch.c \ - engine.c plugin.c action.c grab.c lex.cparse.c config.c + engine.c plugin.c action.c grab.c lex.cparse.c config.c menu.c noinst_HEADERS=client.h event.h extensions.h focus.h frame.h geom.h gettext.h \ openbox.h prop.h screen.h stacking.h xerror.h dispatch.h \ - timer.h engine.h plugin.h action.h grab.h config.h + timer.h engine.h plugin.h action.h grab.h config.h menu.h lex.cparse.c: cparse.l $(FLEX) -Pcparse $^
M openbox/action.copenbox/action.c

@@ -155,6 +155,10 @@ a = action_new(action_restart);

} else if (!g_ascii_strcasecmp(name, "exit")) { a = action_new(action_exit); } + else if (!g_ascii_strcasecmp(name, "showmenu")) { + a = action_new(action_showmenu); + } + return a; }

@@ -623,10 +627,13 @@ int h = data->resize.y;

if (!c || !client_normal(c)) return; + /* XXX window snapping/struts */ + dispatch_resize(c, &w, &h, data->resize.corner); w -= c->frame->size.left + c->frame->size.right; h -= c->frame->size.top + c->frame->size.bottom; + client_configure(c, data->resize.corner, c->area.x, c->area.y, w, h, TRUE, data->resize.final); }

@@ -641,3 +648,8 @@ void action_exit(union ActionData *data)

{ ob_shutdown = TRUE; } + +void action_showmenu(union ActionData *data) +{ + g_message(__FUNCTION__); +}
M openbox/action.hopenbox/action.h

@@ -62,6 +62,11 @@ gboolean final;

Corner corner; }; +struct ShowMenu { + Client *c; + char * menuName; +}; + union ActionData { struct AnyAction any; struct Execute execute;

@@ -73,6 +78,7 @@ struct Desktop desktop;

struct NextPreviousDesktop nextprevdesktop; struct Move move; struct Resize resize; + struct ShowMenu showMenu; }; typedef struct {

@@ -185,5 +191,6 @@ /* Execute */

void action_restart(union ActionData *data); /* Any */ void action_exit(union ActionData *data); - +/* ShowMenu */ +void action_showmenu(union ActionData *data); #endif
M openbox/menu.copenbox/menu.c

@@ -1,28 +1,81 @@

#include <glib.h> #include "menu.h" +#include <assert.h> -Menu *menu_new(char *label, Menu *parent) +GHashTable *menu_hash = NULL; + +void menu_destroy_hash_key(const gpointer data) +{ + g_free(data); +} + +void menu_free_entries(const Menu *menu) +{ + GList *it; + + for (it = menu->entries; it; it = it->next) + menu_entry_free((MenuEntry *)it->data); + + g_list_free(menu->entries); +} + +void menu_destroy_hash_value(const gpointer data) +{ + const Menu *del_menu = (Menu *)data; + + g_free(del_menu->label); + g_free(del_menu->name); + + menu_free_entries(del_menu); +} + +void menu_entry_free(const MenuEntry *entry) +{ + g_free(entry->label); + g_free(entry->render_data); +} + +void menu_startup() { - Menu *new_menu = g_new(Menu, 1); - new_menu->label = g_strdup(lable); + menu_hash = g_hash_table_new_full(g_str_hash, g_str_equal, + menu_destroy_hash_key, + menu_destroy_hash_value); +} + +void menu_shutdown() +{ + g_hash_table_destroy(menu_hash); +} + +Menu *menu_new(const char *label, const char *name, Menu *parent) +{ + Menu *new_menu = g_new0(Menu, 1); + new_menu->label = g_strdup(label); + new_menu->name = g_strdup(name); new_menu->parent = parent; new_menu->entries = NULL; - new_menu->tail = NULL; new_menu->shown = FALSE; new_menu->invalid = FALSE; /* default controllers? */ + g_hash_table_insert(menu_hash, g_strdup(name), new_menu); return new_menu; } -MenuEntry *menu_entry_new_full(char *label, Action *action, - MenuEntryRenderType render_type, +void menu_free(const char *name) +{ + g_hash_table_remove(menu_hash, name); +} + +MenuEntry *menu_entry_new_full(const char *label, Action *action, + const MenuEntryRenderType render_type, gpointer render_data, gpointer submenu) { MenuEntry *menu_entry = g_new(MenuEntry, 1); menu_entry->label = g_strdup(label); + menu_entry->render_type = render_type; menu_entry->action.func = action->func; menu_entry->action.data = action->data; //watch out. copying Client * ptr
M openbox/menu.hopenbox/menu.h

@@ -6,6 +6,7 @@ #include <glib.h>

typedef struct Menu { char *label; + char *name; GList *entries; /* GList *tail; */

@@ -26,12 +27,12 @@ } Menu;

typedef enum MenuEntryRenderType { MenuEntryRenderType_None = 0, - MenuEntryRenderType_Submenu 1 << 0, - MenuEntryRenderType_Boolean 1 << 1, - MenuEntryRenderType_Separator 1 << 2, + MenuEntryRenderType_Submenu = 1 << 0, + MenuEntryRenderType_Boolean = 1 << 1, + MenuEntryRenderType_Separator = 1 << 2, - MenuEntryRenderType_Other 1 << 7 -} MenuEntryType; + MenuEntryRenderType_Other = 1 << 7 +} MenuEntryRenderType; typedef struct {

@@ -43,18 +44,22 @@

MenuEntryRenderType render_type; gboolean enabled; gboolean boolean_value; - gpointer render_data; + gpointer render_data; /* where the engine can store anything it likes */ Menu *submenu; } MenuEntry; -Menu *menu_new(char *label, Menu *parent); -MenuEntry *menu_entry_new_full(char *label, Action *action, - MenuEntryRenderType render_type, - gpointer render_data, gpointer submenu); +Menu *menu_new(const char *label, const char *name, Menu *parent); +void menu_free(const char *name); + +MenuEntry *menu_entry_new_full(const char *label, Action *action, + const MenuEntryRenderType render_type, + gpointer render_data, gpointer submenu); #define menu_entry_new(label, action) \ menu_entry_new(label, action, MenuEntryRenderType_None, NULL, NULL) + +void menu_entry_free(const MenuEntry *entry); void menu_entry_set_submenu(MenuEntry *entry, Menu *submenu);