diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-07-10 19:27:12 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-07-10 19:27:12 +0000 |
| commit | a95dc346fe7951dd48e41a41fcaafb6d872b0337 (patch) | |
| tree | 099d79a095d6d7d8b5d2bd9a7f79350439a7266b /openbox | |
| parent | 1ffc7fa9ec0ca76f8ffc23bba2c1f2d417732462 (diff) | |
prefix and capitalize ObMenu ObMenuEntry and ObMenuEntryRenderType
make the ObMenuEntryRenderType a standard enum instead bitflags
Diffstat (limited to 'openbox')
| -rw-r--r-- | openbox/client.c | 4 | ||||
| -rw-r--r-- | openbox/event.c | 12 | ||||
| -rw-r--r-- | openbox/menu.c | 60 | ||||
| -rw-r--r-- | openbox/menu.h | 107 | ||||
| -rw-r--r-- | openbox/menu_render.c | 25 | ||||
| -rw-r--r-- | openbox/window.c | 2 | ||||
| -rw-r--r-- | openbox/window.h | 4 |
7 files changed, 108 insertions, 106 deletions
diff --git a/openbox/client.c b/openbox/client.c index 339c2a18..aa6e5be7 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -318,8 +318,8 @@ void client_unmanage_all() /* 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) diff --git a/openbox/event.c b/openbox/event.c index 6d74a27d..cdac8683 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -449,7 +449,7 @@ static void event_process(XEvent *e) 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_client(ObClient *client, XEvent *e) 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 @@ static void event_handle_menu(ObClient *client, XEvent *e) 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 @@ static void event_handle_menu(ObClient *client, XEvent *e) 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, diff --git a/openbox/menu.c b/openbox/menu.c index aef0356d..a8a51117 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -21,7 +21,7 @@ static void parse_menu(xmlDocPtr doc, xmlNodePtr node, void *data) 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 @@ static void parse_menu(xmlDocPtr doc, xmlNodePtr node, void *data) 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 @@ parse_menu_fail: 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 @@ void menu_destroy_hash_value(Menu *self) 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_entry_free(MenuEntry *self) void menu_startup() { /* - Menu *m; - Menu *s; - Menu *t; + ObMenu *m; + ObMenu *s; + ObMenu *t; Action *a; */ @@ -183,13 +183,13 @@ static Window createWindow(Window parent, unsigned long mask, } -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 @@ void menu_free(char *name) 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 @@ MenuEntry *menu_entry_new_full(char *label, Action *action, 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 @@ void menu_entry_set_submenu(MenuEntry *entry, Menu *submenu) 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_add_entry(Menu *menu, MenuEntry *entry) 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 @@ void menu_show(char *name, int x, int y, ObClient *client) 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 @@ void menu_show_full(Menu *self, int x, int y, ObClient *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 @@ void menu_hide(Menu *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 @@ void menu_clear(Menu *self) { } -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 @@ MenuEntry *menu_find_entry_by_pos(Menu *menu, int x, int y) 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 @@ void menu_entry_fire(MenuEntry *self) 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 @@ void menu_control_show(Menu *self, int x, int y, ObClient *client) { } } -void menu_control_mouseover(MenuEntry *self, gboolean enter) { +void menu_control_mouseover(ObMenuEntry *self, gboolean enter) { int x; Rect *a; diff --git a/openbox/menu.h b/openbox/menu.h index 9beb8f2a..72a7ed24 100644 --- a/openbox/menu.h +++ b/openbox/menu.h @@ -10,32 +10,32 @@ 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 @@ typedef struct Menu { 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 @@ typedef struct Menu { /* 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 struct MenuEntry { +}; + +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; + +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 @@ void menu_shutdown(); #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 diff --git a/openbox/menu_render.c b/openbox/menu_render.c index 4b6e7d8f..d5342534 100644 --- a/openbox/menu_render.c +++ b/openbox/menu_render.c @@ -4,9 +4,9 @@ #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 @@ void menu_render(Menu *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 @@ void menu_render_full(Menu *self) { } 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 @@ void menu_render_full(Menu *self) { 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 @@ void menu_render_full(Menu *self) { 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 @@ void menu_entry_render(MenuEntry *self) 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; } diff --git a/openbox/window.c b/openbox/window.c index 8ca01b6f..521d9e2d 100644 --- a/openbox/window.c +++ b/openbox/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: diff --git a/openbox/window.h b/openbox/window.h index fbdcf024..b38bc42e 100644 --- a/openbox/window.h +++ b/openbox/window.h @@ -33,12 +33,12 @@ typedef struct InternalWindow { #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) |
