/* 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)
ObClient *client = NULL;
ObDock *dock = NULL;
ObDockApp *dockapp = NULL;
- Menu *menu = NULL;
+ ObMenu *menu = NULL;
ObWindow *obwin = NULL;
window = event_get_window(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);
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 +
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,
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;
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")) {
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;
g_free(self);
}
-void menu_entry_free(MenuEntry *self)
+void menu_entry_free(ObMenuEntry *self)
{
g_free(self->label);
action_free(self->action);
void menu_startup()
{
/*
- Menu *m;
- Menu *s;
- Menu *t;
+ ObMenu *m;
+ ObMenu *s;
+ ObMenu *t;
Action *a;
*/
}
-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);
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;
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);
entry->parent->invalid = TRUE;
}
-void menu_add_entry(Menu *menu, MenuEntry *entry)
+void menu_add_entry(ObMenu *menu, ObMenuEntry *entry)
{
XSetWindowAttributes attrib;
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) {
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);
}
}
-void menu_hide(Menu *self) {
+void menu_hide(ObMenu *self) {
if (self->shown) {
XUnmapWindow(ob_display, self->frame);
self->shown = FALSE;
}
}
-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;
}
-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;
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;
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;
}
}
-void menu_control_mouseover(MenuEntry *self, gboolean enter) {
+void menu_control_mouseover(ObMenuEntry *self, gboolean enter) {
int x;
Rect *a;
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;
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 */
/* 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();
#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
#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) {
}
}
-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 */
}
for (it = self->entries; it; it = it->next) {
- MenuEntry *e = it->data;
+ ObMenuEntry *e = it->data;
int h;
if (e->a_item == NULL) {
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;
}
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;
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;
}
{
switch (self->type) {
case Window_Menu:
- return ((Menu*)self)->frame;
+ return ((ObMenu*)self)->frame;
case Window_Dock:
return ((ObDock*)self)->frame;
case 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)
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;
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;
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;
}
#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);
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));
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);
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");
}
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;
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
}
}
-void plugin_destroy (Menu *m)
+void plugin_destroy (ObMenu *m)
{
fifo_menu_clean_up(m);
if (FIFO_MENU_DATA(m)->handler != NULL) {
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;
#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 {
{ }
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);
void timed_menu_read_pipe(int fd, void *d)
{
- Menu *menu = d;
+ ObMenu *menu = d;
char *tmpbuf = NULL;
unsigned long num_read;
#ifdef DEBUG
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): {
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;