all repos — openbox @ a95dc346fe7951dd48e41a41fcaafb6d872b0337

openbox fork - make it a bit more like ryudo

prefix and capitalize ObMenu ObMenuEntry and ObMenuEntryRenderType
make the ObMenuEntryRenderType a standard enum instead bitflags
Dana Jansens danakj@orodu.net
commit

a95dc346fe7951dd48e41a41fcaafb6d872b0337

parent

1ffc7fa9ec0ca76f8ffc23bba2c1f2d417732462

M openbox/client.copenbox/client.c

@@ -318,8 +318,8 @@

/* called by client_unmanage() to close any menus referencing this client */ void client_close_menus(gpointer key, gpointer value, gpointer self) { - if (((Menu *)value)->client == (ObClient *)self) - menu_hide((Menu *)value); + if (((ObMenu *)value)->client == (ObClient *)self) + menu_hide((ObMenu *)value); } void client_unmanage(ObClient *self)
M openbox/event.copenbox/event.c

@@ -449,7 +449,7 @@ Window window;

ObClient *client = NULL; ObDock *dock = NULL; ObDockApp *dockapp = NULL; - Menu *menu = NULL; + ObMenu *menu = NULL; ObWindow *obwin = NULL; window = event_get_window(e);

@@ -963,9 +963,9 @@ }

static void event_handle_menu(ObClient *client, XEvent *e) { - static MenuEntry *over = NULL; - MenuEntry *entry; - Menu *top; + static ObMenuEntry *over = NULL; + ObMenuEntry *entry; + ObMenu *top; GSList *it; top = g_slist_nth_data(menu_visible, 0);

@@ -999,7 +999,7 @@

g_message("BUTTON RELEASED"); for (it = menu_visible; it; it = g_slist_next(it)) { - Menu *m = it->data; + ObMenu *m = it->data; if (e->xbutton.x_root >= m->location.x - ob_rr_theme->bwidth && e->xbutton.y_root >= m->location.y - ob_rr_theme->bwidth && e->xbutton.x_root < m->location.x + m->size.width +

@@ -1046,7 +1046,7 @@ break;

case MotionNotify: g_message("motion"); for (it = menu_visible; it; it = g_slist_next(it)) { - Menu *m = it->data; + ObMenu *m = it->data; if ((entry = menu_find_entry_by_pos(it->data, e->xmotion.x_root - m->location.x,
M openbox/menu.copenbox/menu.c

@@ -21,7 +21,7 @@ {

Action *act; xmlNodePtr nact; gchar *id = NULL, *title = NULL, *label = NULL; - Menu *menu, *parent; + ObMenu *menu, *parent; if (!parse_attr_string("id", node->parent, &id)) goto parse_menu_fail;

@@ -30,9 +30,9 @@ goto parse_menu_fail;

g_message("menu label %s", title); - menu = menu_new(title, id, data ? *((Menu**)data) : NULL); + menu = menu_new(title, id, data ? *((ObMenu**)data) : NULL); if (data) - *((Menu**)data) = menu; + *((ObMenu**)data) = menu; while (node) { if (!xmlStrcasecmp(node->name, (const xmlChar*) "menu")) {

@@ -62,14 +62,14 @@ g_free(id);

g_free(title); } -void menu_control_show(Menu *self, int x, int y, ObClient *client); +void menu_control_show(ObMenu *self, int x, int y, ObClient *client); -void menu_destroy_hash_key(Menu *menu) +void menu_destroy_hash_key(ObMenu *menu) { g_free(menu); } -void menu_destroy_hash_value(Menu *self) +void menu_destroy_hash_value(ObMenu *self) { GList *it;

@@ -94,7 +94,7 @@

g_free(self); } -void menu_entry_free(MenuEntry *self) +void menu_entry_free(ObMenuEntry *self) { g_free(self->label); action_free(self->action);

@@ -112,9 +112,9 @@

void menu_startup() { /* - Menu *m; - Menu *s; - Menu *t; + ObMenu *m; + ObMenu *s; + ObMenu *t; Action *a; */

@@ -183,13 +183,13 @@ RrVisual(ob_rr_inst), mask, attrib);

} -Menu *menu_new_full(char *label, char *name, Menu *parent, +ObMenu *menu_new_full(char *label, char *name, ObMenu *parent, menu_controller_show show, menu_controller_update update) { XSetWindowAttributes attrib; - Menu *self; + ObMenu *self; - self = g_new0(Menu, 1); + self = g_new0(ObMenu, 1); self->obwin.type = Window_Menu; self->label = g_strdup(label); self->name = g_strdup(name);

@@ -239,11 +239,11 @@ {

g_hash_table_remove(menu_hash, name); } -MenuEntry *menu_entry_new_full(char *label, Action *action, - MenuEntryRenderType render_type, +ObMenuEntry *menu_entry_new_full(char *label, Action *action, + ObMenuEntryRenderType render_type, gpointer submenu) { - MenuEntry *menu_entry = g_new0(MenuEntry, 1); + ObMenuEntry *menu_entry = g_new0(ObMenuEntry, 1); menu_entry->label = g_strdup(label); menu_entry->render_type = render_type;

@@ -257,7 +257,7 @@

return menu_entry; } -void menu_entry_set_submenu(MenuEntry *entry, Menu *submenu) +void menu_entry_set_submenu(ObMenuEntry *entry, ObMenu *submenu) { g_assert(entry != NULL);

@@ -267,7 +267,7 @@ if(entry->parent != NULL)

entry->parent->invalid = TRUE; } -void menu_add_entry(Menu *menu, MenuEntry *entry) +void menu_add_entry(ObMenu *menu, ObMenuEntry *entry) { XSetWindowAttributes attrib;

@@ -291,7 +291,7 @@ }

void menu_show(char *name, int x, int y, ObClient *client) { - Menu *self; + ObMenu *self; self = g_hash_table_lookup(menu_hash, name); if (!self) {

@@ -303,7 +303,7 @@

menu_show_full(self, x, y, client); } -void menu_show_full(Menu *self, int x, int y, ObClient *client) +void menu_show_full(ObMenu *self, int x, int y, ObClient *client) { g_assert(self != NULL);

@@ -326,7 +326,7 @@ menu_control_show(self, x, y, client);

} } -void menu_hide(Menu *self) { +void menu_hide(ObMenu *self) { if (self->shown) { XUnmapWindow(ob_display, self->frame); self->shown = FALSE;

@@ -343,11 +343,11 @@ menu_visible = g_slist_remove(menu_visible, self);

} } -void menu_clear(Menu *self) { +void menu_clear(ObMenu *self) { GList *it; for (it = self->entries; it; it = it->next) { - MenuEntry *entry = it->data; + ObMenuEntry *entry = it->data; menu_entry_free(entry); } self->entries = NULL;

@@ -355,19 +355,19 @@ self->invalid = TRUE;

} -MenuEntry *menu_find_entry(Menu *menu, Window win) +ObMenuEntry *menu_find_entry(ObMenu *menu, Window win) { GList *it; for (it = menu->entries; it; it = it->next) { - MenuEntry *entry = it->data; + ObMenuEntry *entry = it->data; if (entry->item == win) return entry; } return NULL; } -MenuEntry *menu_find_entry_by_pos(Menu *menu, int x, int y) +ObMenuEntry *menu_find_entry_by_pos(ObMenu *menu, int x, int y) { if (x < 0 || x >= menu->size.width || y < 0 || y >= menu->size.height) return NULL;

@@ -379,9 +379,9 @@ g_message ("%d %p", y/menu->item_h, g_list_nth_data(menu->entries, y / menu->item_h));

return g_list_nth_data(menu->entries, y / menu->item_h); } -void menu_entry_fire(MenuEntry *self) +void menu_entry_fire(ObMenuEntry *self) { - Menu *m; + ObMenu *m; if (self->action) { self->action->data.any.c = self->parent->client;

@@ -398,7 +398,7 @@ /*

Default menu controller action for showing. */ -void menu_control_show(Menu *self, int x, int y, ObClient *client) { +void menu_control_show(ObMenu *self, int x, int y, ObClient *client) { guint i; Rect *a = NULL;

@@ -426,7 +426,7 @@ menu_hide(self->open_submenu);

} } -void menu_control_mouseover(MenuEntry *self, gboolean enter) { +void menu_control_mouseover(ObMenuEntry *self, gboolean enter) { int x; Rect *a;
M openbox/menu.hopenbox/menu.h

@@ -10,32 +10,32 @@ #include <glib.h>

struct _ObClient; -struct Menu; -struct MenuEntry; +typedef struct _ObMenu ObMenu; +typedef struct _ObMenuEntry ObMenuEntry; -typedef void(*menu_controller_show)(struct Menu *self, - int x, int y, struct _ObClient *); -typedef void(*menu_controller_update)(struct Menu *self); -typedef void(*menu_controller_mouseover)(struct MenuEntry *self, - gboolean enter); +typedef void(*menu_controller_show)(ObMenu *self, int x, int y, + struct _ObClient *); +typedef void(*menu_controller_update)(ObMenu *self); +typedef void(*menu_controller_mouseover)(ObMenuEntry *self, gboolean enter); extern GHashTable *menu_hash; extern GSList *menu_visible; -typedef struct Menu { +struct _ObMenu +{ ObWindow obwin; - char *label; - char *name; + gchar *label; + gchar *name; GList *entries; gboolean shown; gboolean invalid; - struct Menu *parent; + ObMenu *parent; - struct Menu *open_submenu; + ObMenu *open_submenu; /* place a menu on screen */ menu_controller_show show;

@@ -52,11 +52,11 @@ struct _ObClient *client;

Window frame; Window title; RrAppearance *a_title; - int title_min_w, title_h; + gint title_min_w, title_h; Window items; RrAppearance *a_items; - int bullet_w; - int item_h; + gint bullet_w; + gint item_h; Point location; Size size; guint xin_area; /* index of the xinerama head/area */

@@ -64,38 +64,39 @@

/* plugin stuff */ char *plugin; void *plugin_data; -} Menu; +}; -typedef enum MenuEntryRenderType { - MenuEntryRenderType_None = 0, - MenuEntryRenderType_Submenu = 1 << 0, - MenuEntryRenderType_Boolean = 1 << 1, - MenuEntryRenderType_Separator = 1 << 2, - - MenuEntryRenderType_Other = 1 << 7 -} MenuEntryRenderType; +typedef enum +{ + OB_MENU_ENTRY_RENDER_TYPE_NONE, + OB_MENU_ENTRY_RENDER_TYPE_SUBMENU, + OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN, + OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR, + OB_MENU_ENTRY_RENDER_TYPE_OTHER /* XXX what is this? */ +} ObMenuEntryRenderType; -typedef struct MenuEntry { +struct _ObMenuEntry +{ char *label; - Menu *parent; + ObMenu *parent; Action *action; - MenuEntryRenderType render_type; + ObMenuEntryRenderType render_type; gboolean hilite; gboolean enabled; gboolean boolean_value; - Menu *submenu; + ObMenu *submenu; /* render stuff */ Window item; RrAppearance *a_item; RrAppearance *a_disabled; RrAppearance *a_hilite; - int y; - int min_w; -} MenuEntry; + gint y; + gint min_w; +}; void menu_startup(); void menu_shutdown();

@@ -103,48 +104,48 @@

#define menu_new(l, n, p) \ menu_new_full(l, n, p, NULL, NULL) -Menu *menu_new_full(char *label, char *name, Menu *parent, +ObMenu *menu_new_full(char *label, char *name, ObMenu *parent, menu_controller_show show, menu_controller_update update); void menu_free(char *name); void menu_show(char *name, int x, int y, struct _ObClient *client); -void menu_show_full(Menu *menu, int x, int y, struct _ObClient *client); +void menu_show_full(ObMenu *menu, int x, int y, struct _ObClient *client); -void menu_hide(Menu *self); +void menu_hide(ObMenu *self); -void menu_clear(Menu *self); +void menu_clear(ObMenu *self); -MenuEntry *menu_entry_new_full(char *label, Action *action, - MenuEntryRenderType render_type, +ObMenuEntry *menu_entry_new_full(char *label, Action *action, + ObMenuEntryRenderType render_type, gpointer submenu); #define menu_entry_new(label, action) \ -menu_entry_new_full(label, action, MenuEntryRenderType_None, NULL) +menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_NONE, NULL) #define menu_entry_new_separator(label) \ -menu_entry_new_full(label, NULL, MenuEntryRenderType_Separator, NULL) +menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR, NULL) #define menu_entry_new_submenu(label, submenu) \ -menu_entry_new_full(label, NULL, MenuEntryRenderType_Submenu, submenu) +menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SUBMENU, submenu) #define menu_entry_new_boolean(label, action) \ -menu_entry_new_full(label, action, MenuEntryRenderType_Boolean, NULL) +menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN, NULL) -void menu_entry_free(MenuEntry *entry); +void menu_entry_free(ObMenuEntry *entry); -void menu_entry_set_submenu(MenuEntry *entry, Menu *submenu); +void menu_entry_set_submenu(ObMenuEntry *entry, ObMenu *submenu); -void menu_add_entry(Menu *menu, MenuEntry *entry); +void menu_add_entry(ObMenu *menu, ObMenuEntry *entry); -MenuEntry *menu_find_entry(Menu *menu, Window win); -MenuEntry *menu_find_entry_by_pos(Menu *menu, int x, int y); +ObMenuEntry *menu_find_entry(ObMenu *menu, Window win); +ObMenuEntry *menu_find_entry_by_pos(ObMenu *menu, int x, int y); -void menu_entry_render(MenuEntry *self); +void menu_entry_render(ObMenuEntry *self); -void menu_entry_fire(MenuEntry *self); +void menu_entry_fire(ObMenuEntry *self); -void menu_render(Menu *self); -void menu_render_full(Menu *self); +void menu_render(ObMenu *self); +void menu_render_full(ObMenu *self); -void menu_control_mouseover(MenuEntry *entry, gboolean enter); +void menu_control_mouseover(ObMenuEntry *entry, gboolean enter); #endif
M openbox/menu_render.copenbox/menu_render.c

@@ -4,9 +4,9 @@ #include "menu.h"

#include "openbox.h" #include "render/theme.h" -void menu_render_full(Menu *self); +void menu_render_full(ObMenu *self); -void menu_render(Menu *self) { +void menu_render(ObMenu *self) { if (self->update) { self->update(self); } else if (self->invalid) {

@@ -14,7 +14,7 @@ menu_render_full(self);

} } -void menu_render_full(Menu *self) { +void menu_render_full(ObMenu *self) { GList *it; int items_h = 0; int nitems = 0; /* each item, only one is used */

@@ -47,7 +47,7 @@ self->size.width = MAX(self->size.width, self->title_min_w);

} for (it = self->entries; it; it = it->next) { - MenuEntry *e = it->data; + ObMenuEntry *e = it->data; int h; if (e->a_item == NULL) {

@@ -95,7 +95,7 @@ RrPaint(self->a_items, self->items, self->size.width, items_h);

item_y = 0; for (it = self->entries; it; it = it->next) { - ((MenuEntry*)it->data)->y = item_y; + ((ObMenuEntry*)it->data)->y = item_y; menu_entry_render(it->data); item_y += self->item_h; }

@@ -103,24 +103,24 @@

self->invalid = FALSE; } -void menu_entry_render(MenuEntry *self) +void menu_entry_render(ObMenuEntry *self) { - Menu *menu = self->parent; + ObMenu *menu = self->parent; RrAppearance *a; switch (self->render_type) { - case MenuEntryRenderType_Submenu: + case OB_MENU_ENTRY_RENDER_TYPE_SUBMENU: /* TODO: submenu mask */ - case MenuEntryRenderType_Boolean: + case OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN: /* TODO: boolean check */ a = self->enabled ? (self->hilite ? self->a_hilite : self->a_item) : self->a_disabled; break; - case MenuEntryRenderType_None: + case OB_MENU_ENTRY_RENDER_TYPE_NONE: a = self->enabled ? (self->hilite ? self->a_hilite : self->a_item ) : self->a_disabled; break; - case MenuEntryRenderType_Separator: + case OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR: a = self->a_item; break;

@@ -128,7 +128,8 @@ default:

g_message("unhandled render_type"); a = !self->enabled ? self->a_disabled : (self->hilite && - (self->action || self->render_type == MenuEntryRenderType_Submenu) ? + (self->action || + self->render_type == OB_MENU_ENTRY_RENDER_TYPE_SUBMENU) ? self->a_hilite : self->a_item); break; }
M openbox/window.copenbox/window.c

@@ -21,7 +21,7 @@ Window window_top(ObWindow *self)

{ switch (self->type) { case Window_Menu: - return ((Menu*)self)->frame; + return ((ObMenu*)self)->frame; case Window_Dock: return ((ObDock*)self)->frame; case Window_DockApp:
M openbox/window.hopenbox/window.h

@@ -33,12 +33,12 @@ #define WINDOW_IS_DOCKAPP(win) (((ObWindow*)win)->type == Window_DockApp)

#define WINDOW_IS_CLIENT(win) (((ObWindow*)win)->type == Window_Client) #define WINDOW_IS_INTERNAL(win) (((ObWindow*)win)->type == Window_Internal) -struct Menu; +struct _ObMenu; struct _ObDock; struct _ObDockApp; struct _ObClient; -#define WINDOW_AS_MENU(win) ((struct Menu*)win) +#define WINDOW_AS_MENU(win) ((struct _ObMenu*)win) #define WINDOW_AS_DOCK(win) ((struct _ObDock*)win) #define WINDOW_AS_DOCKAPP(win) ((struct _ObDockApp*)win) #define WINDOW_AS_CLIENT(win) ((struct _ObClient*)win)
M plugins/menu/client_menu.cplugins/menu/client_menu.c

@@ -13,20 +13,20 @@ #if 0

static char *PLUGIN_NAME = "client_menu"; #endif -static Menu *send_to_menu; -static Menu *layer_menu; +static ObMenu *send_to_menu; +static ObMenu *layer_menu; typedef struct { gint foo; } Client_Menu_Data; -#define CLIENT_MENU(m) ((Menu *)m) -#define CLIENT_MENU_DATA(m) ((Client_Menu_Data *)((Menu *)m)->plugin_data) +#define CLIENT_MENU(m) ((ObMenu *)m) +#define CLIENT_MENU_DATA(m) ((Client_Menu_Data *)((ObMenu *)m)->plugin_data) -void client_menu_clean_up(Menu *m) { +void client_menu_clean_up(ObMenu *m) { } -void client_send_to_update(Menu *self) +void client_send_to_update(ObMenu *self) { guint i = 0; GList *it = self->entries;

@@ -36,7 +36,7 @@ while (it != NULL) {

if (i >= screen_num_desktops) break; if (strcmp(screen_desktop_names[i], - ((MenuEntry *)it->data)->label) != 0) + ((ObMenuEntry *)it->data)->label) != 0) break; ++i; it = it->next;

@@ -46,7 +46,7 @@ if (it != NULL || i != screen_num_desktops) {

menu_clear(self); g_message("update"); for (i = 0; i < screen_num_desktops; ++i) { - MenuEntry *e; + ObMenuEntry *e; Action *a = action_from_string("sendtodesktop"); a->data.sendto.desk = i; a->data.sendto.follow = FALSE;

@@ -59,7 +59,7 @@ }

} #if 0 -void client_menu_show(Menu *self, int x, int y, Client *client) +void client_menu_show(ObMenu *self, int x, int y, Client *client) { int newy; g_assert(!self->invalid);

@@ -91,13 +91,13 @@ void plugin_setup_config() { }

void plugin_shutdown() { } -void plugin_destroy (Menu *m) +void plugin_destroy (ObMenu *m) { } void *plugin_create() /* TODO: need config */ { - Menu *m = menu_new_full(NULL, "client-menu", NULL, + ObMenu *m = menu_new_full(NULL, "client-menu", NULL, /*client_menu_show*/NULL, NULL); menu_add_entry(m, menu_entry_new_submenu("Send To Workspace", send_to_menu));

@@ -136,8 +136,8 @@ }

void plugin_startup() { - Menu *t; - /* create a Send To Workspace Menu */ + ObMenu *t; + /* create a Send To Workspace ObMenu */ send_to_menu = menu_new_full(NULL, "send-to-workspace", NULL, NULL, client_send_to_update);

@@ -149,6 +149,6 @@ action_from_string("sendtonormallayer")));

menu_add_entry(layer_menu, menu_entry_new("Bottom Layer", action_from_string("sendtobottomlayer"))); - t = (Menu *)plugin_create("client_menu"); + t = (ObMenu *)plugin_create("client_menu"); }
M plugins/menu/fifo_menu.cplugins/menu/fifo_menu.c

@@ -20,11 +20,11 @@ int fd; /* file descriptor to read menu from */

event_fd_handler *handler; } Fifo_Menu_Data; -#define FIFO_MENU(m) ((Menu *)m) -#define FIFO_MENU_DATA(m) ((Fifo_Menu_Data *)((Menu *)m)->plugin_data) +#define FIFO_MENU(m) ((ObMenu *)m) +#define FIFO_MENU_DATA(m) ((Fifo_Menu_Data *)((ObMenu *)m)->plugin_data) -void fifo_menu_clean_up(Menu *m) { +void fifo_menu_clean_up(ObMenu *m) { if (FIFO_MENU_DATA(m)->buf != NULL) { g_free(FIFO_MENU_DATA(m)->buf); FIFO_MENU_DATA(m)->buf = NULL;

@@ -43,7 +43,7 @@ { }

void plugin_shutdown() { } void fifo_menu_handler(int fd, void *d) { - Menu *menu = d; + ObMenu *menu = d; char *tmpbuf = NULL; unsigned long num_read; #ifdef DEBUG

@@ -116,7 +116,7 @@ }

} } -void plugin_destroy (Menu *m) +void plugin_destroy (ObMenu *m) { fifo_menu_clean_up(m); if (FIFO_MENU_DATA(m)->handler != NULL) {

@@ -141,7 +141,7 @@ char *dir;

event_fd_handler *h; Fifo_Menu_Data *d = g_new(Fifo_Menu_Data, 1); - Menu *m = menu_new("", PLUGIN_NAME, NULL); + ObMenu *m = menu_new("", PLUGIN_NAME, NULL); d->fd = -1; d->buf = NULL;
M plugins/menu/timed_menu.cplugins/menu/timed_menu.c

@@ -15,8 +15,8 @@ #include "timed_menu.h"

#include "kernel/action.h" #include "kernel/event.h" -#define TIMED_MENU(m) ((Menu *)m) -#define TIMED_MENU_DATA(m) ((Timed_Menu_Data *)((Menu *)m)->plugin_data) +#define TIMED_MENU(m) ((ObMenu *)m) +#define TIMED_MENU_DATA(m) ((Timed_Menu_Data *)((ObMenu *)m)->plugin_data) static char *PLUGIN_NAME = "timed_menu"; typedef enum {

@@ -41,7 +41,7 @@ void plugin_startup()

{ } void plugin_shutdown() { } -void timed_menu_clean_up(Menu *m) { +void timed_menu_clean_up(ObMenu *m) { if (TIMED_MENU_DATA(m)->buf != NULL) { fprintf(stderr, "%s", TIMED_MENU_DATA(m)->buf); g_free(TIMED_MENU_DATA(m)->buf);

@@ -66,7 +66,7 @@ }

void timed_menu_read_pipe(int fd, void *d) { - Menu *menu = d; + ObMenu *menu = d; char *tmpbuf = NULL; unsigned long num_read; #ifdef DEBUG

@@ -125,7 +125,7 @@ }

void timed_menu_timeout_handler(void *d) { - Menu *data = d; + ObMenu *data = d; if (!data->shown && TIMED_MENU_DATA(data)->fd == -1) { switch (TIMED_MENU_DATA(data)->type) { case (TIMED_MENU_PIPE): {

@@ -187,7 +187,7 @@

void *plugin_create() { Timed_Menu_Data *d = g_new(Timed_Menu_Data, 1); - Menu *m = menu_new("", PLUGIN_NAME, NULL); + ObMenu *m = menu_new("", PLUGIN_NAME, NULL); m->plugin = PLUGIN_NAME;