all repos — openbox @ a4f023cf3a085d414a03e2d074e6eaa5258e4391

openbox fork - make it a bit more like ryudo

Some fixes and new bugs. Someone else can do the menus because it is
clear no one gives a fuck what I think and no one else wants a window
manager that doesn't suck the same balls as every other window manager.
Scott Moynes smoynes@nexus.carleton.ca
commit

a4f023cf3a085d414a03e2d074e6eaa5258e4391

parent

d94fba72624f88f7e0457dc4eb9a0f6b1699f23b

M openbox/menu.copenbox/menu.c

@@ -142,8 +142,9 @@

RrAppearanceFree(self->a_item); RrAppearanceFree(self->a_disabled); RrAppearanceFree(self->a_hilite); + RrAppearanceFree(self->a_submenu); XDestroyWindow(ob_display, self->item); - + XDestroyWindow(ob_display, self->submenu_pic); g_free(self); }

@@ -273,13 +274,17 @@ entry->parent = menu;

attrib.event_mask = ENTRY_EVENTMASK; entry->item = createWindow(menu->items, CWEventMask, &attrib); + entry->submenu_pic = createWindow(menu->items, CWEventMask, &attrib); XMapWindow(ob_display, entry->item); + XMapWindow(ob_display, entry->submenu_pic); - entry->a_item = entry->a_disabled = entry->a_hilite = NULL; + entry->a_item = entry->a_disabled = entry->a_hilite = entry->a_submenu + = NULL; menu->invalid = TRUE; g_hash_table_insert(window_map, &entry->item, menu); + g_hash_table_insert(window_map, &entry->submenu_pic, menu); } void menu_show(char *name, int x, int y, ObClient *client)

@@ -473,9 +478,21 @@ self->parent->update(self->submenu);

a = screen_physical_area_monitor(self->parent->xin_area); - if (self->submenu->size.width + x >= a->x + a->width) - x = self->parent->location.x - self->submenu->size.width - - ob_rr_theme->bwidth + ob_rr_theme->menu_overlap; + if (self->submenu->size.width + x >= a->x + a->width) { + int newparentx = a->x + a->width + - self->submenu->size.width + - self->parent->size.width + - ob_rr_theme->bwidth + - ob_rr_theme->menu_overlap; + + x = a->x + a->width - self->submenu->size.width + - ob_rr_theme->menu_overlap; + XWarpPointer(ob_display, None, None, 0, 0, 0, 0, + newparentx - self->parent->location.x, 0); + + menu_show_full(self->parent, newparentx, + self->parent->location.y, self->parent->client); + } menu_show_full(self->submenu, x, self->parent->location.y + self->y,
M openbox/menu.hopenbox/menu.h

@@ -114,9 +114,12 @@ ObMenu *submenu;

/* render stuff */ Window item; + Window submenu_pic; + RrAppearance *a_item; RrAppearance *a_disabled; RrAppearance *a_hilite; + RrAppearance *a_submenu; gint y; gint min_w; } MenuEntry;
M openbox/menu_render.copenbox/menu_render.c

@@ -45,8 +45,9 @@ if (e->a_item == NULL) {

e->a_item = RrAppearanceCopy(ob_rr_theme->a_menu_item); e->a_disabled = RrAppearanceCopy(ob_rr_theme->a_menu_disabled); e->a_hilite = RrAppearanceCopy(ob_rr_theme->a_menu_hilite); + e->a_submenu = RrAppearanceCopy(ob_rr_theme->a_menu_bullet); } - + e->a_item->texture[0].data.text.string = e->label; RrMinsize(e->a_item, &e->min_w, &self->item_h); self->size.width = MAX(self->size.width, e->min_w);

@@ -97,11 +98,14 @@

void menu_entry_render(ObMenuEntry *self) { ObMenu *menu = self->parent; - RrAppearance *a; + RrAppearance *a, *s = NULL; switch (self->render_type) { case OB_MENU_ENTRY_RENDER_TYPE_SUBMENU: - /* TODO: submenu mask */ + a = self->enabled ? (self->hilite ? self->a_hilite : self->a_item) + : self->a_disabled; + s = self->a_submenu; + break; case OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN: /* TODO: boolean check */ a = self->enabled ? (self->hilite ? self->a_hilite : self->a_item)

@@ -119,14 +123,23 @@ default:

g_assert_not_reached(); /* unhandled rendering type */ break; } - ob_debug("%s %d\n", self->label, self->hilite); XMoveResizeWindow(ob_display, self->item, 0, self->y, menu->size.width, menu->item_h); - + XMoveResizeWindow(ob_display, self->submenu_pic, menu->size.width - ob_rr_theme->bevel - 1, self->y, + 8, 8); a->surface.parent = menu->a_items; a->surface.parentx = 0; a->surface.parenty = self->y; + if (s) { + s->surface.parent = a; + s->surface.parentx = menu->size.width - 8; + s->surface.parenty = 0; + } + RrPaint(a, self->item, menu->size.width, menu->item_h); + + if (s) + RrPaint(s, self->submenu_pic, 8, 8); }
M plugins/menu/fifo_menu.cplugins/menu/fifo_menu.c

@@ -1,3 +1,25 @@

+/* + * $Header$ + * + * FFIO menu plugin + * Provides a menu from a FIFO located in ~/.openbox/fifo_menu/id + * Example: + * rc3: + * <menu id="fonk" label="fonk" plugin="fifo_menu"></menu> + * Menu format + * <fifo_menu> + * <item label="GLOVE.png"> + * <action name="execute"> + * <execute> + * bsetbg "/home/woodblock/.openbox/backgrounds/GLOVE.png" + * </execute> + * </action> + * </item> + * </fifo_menu> + * + * If the attribute pid="true" is in the <menu> + */ + #include <glib.h> #include <sys/types.h> #include <sys/stat.h>

@@ -94,8 +116,7 @@ node = xmlDocGetRootElement(doc);

if (node && !xmlStrcasecmp(node->name, (const xmlChar*) "fifo_menu")) { - if ((node = parse_find_node("item", node->xmlChildrenNode))) - parse_menu_full(doc, node, menu, FALSE); + parse_menu_full(doc, node, menu, FALSE); } fifo_menu_clean_up(menu);
M plugins/menu/timed_menu.cplugins/menu/timed_menu.c

@@ -1,3 +1,35 @@

+/* + * $Header$ + * + * Timed menu plugin + * Provides a menu from either a periodically executing process or by + * periodically checking the timestamp of a file and loading if it has changed. + * + * Examples: + * Piped timed menu: + * rc3: + * <menu id="name" label="Piped menu" plugin="timed_menu" timeout="120" + * command="obcommand.py -c bsetbg -d ~/.openbox/backgrounds/" /> + * timeout is in seconds + * + * Output of command: + * <timed_menu> + * <item label="GLOVE.png"> + * <action name="execute"> + * <execute> + * bsetbg "/home/woodblock/.openbox/backgrounds/GLOVE.png" + * </execute> + * </action> + * </item> + * </fifo_menu> + * + * stat() menu: + * <menu id="name" label="Stat menu" plugin="timed_menu" type="stat" + * timeout="120" file="~/.openbox/stat_menu" /> + * stat_menu contents: same as timed menu + * + */ + #include <glib.h> #include <stdlib.h> #include <unistd.h>

@@ -27,7 +59,7 @@

typedef struct { Timed_Menu_Type type; ObTimer *timer; - char *command; /* for the PIPE */ + char *command; /* command to run or file to stat() */ char *buf; /* buffer to hold partially read menu */ unsigned long buflen; /* how many bytes are in the buffer */ int fd; /* file descriptor to read menu from */

@@ -43,7 +75,6 @@ void plugin_shutdown() { }

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); TIMED_MENU_DATA(m)->buf = NULL; }

@@ -60,8 +91,6 @@ if (TIMED_MENU_DATA(m)->pid != -1) {

waitpid(TIMED_MENU_DATA(m)->pid, NULL, 0); TIMED_MENU_DATA(m)->pid = -1; } - - TIMED_MENU_DATA(m)->mtime = 0; } void timed_menu_read_pipe(int fd, void *d)

@@ -109,9 +138,9 @@ TIMED_MENU_DATA(menu)->buflen);

node = xmlDocGetRootElement(doc); - if (!xmlStrcasecmp(node->name, (const xmlChar*) "timed_menu")) { - if ((node = parse_find_node("item", node->xmlChildrenNode))) - parse_menu_full(doc, node, menu, FALSE); + if (node && + !xmlStrcasecmp(node->name, (const xmlChar*) "timed_menu")) { + parse_menu_full(doc, node, menu, FALSE); } timed_menu_clean_up(menu);

@@ -176,9 +205,25 @@ break;

} if (stat_buf.st_mtime > TIMED_MENU_DATA(data)->mtime) { + xmlDocPtr doc; + xmlNodePtr node; + g_warning("file changed"); TIMED_MENU_DATA(data)->mtime = stat_buf.st_mtime; - /* TODO: parse */ + + data->invalid = TRUE; + menu_clear(data); + + doc = xmlParseFile(TIMED_MENU_DATA(data)->command); + + node = xmlDocGetRootElement(doc); + + if (node && + !xmlStrcasecmp(node->name, (const xmlChar*) "timed_menu")) { + parse_menu_full(doc, node, data, FALSE); + } + + timed_menu_clean_up(data); } } }

@@ -190,6 +235,8 @@ {

char *id; char *label; char *timeout; + char *type; + Timed_Menu_Data *d; ObMenu *m;

@@ -209,9 +256,19 @@ menu_add_entry(data->parent, menu_entry_new_submenu(

(label != NULL ? label : ""), m)); - if (!parse_attr_string("command", data->node, &d->command)) { - d->command = g_strdup(""); - } + d->type = TIMED_MENU_PIPE; + + if (parse_attr_string("type", data->node, &type) && + !g_strcasecmp(type, "stat")) { + d->type = TIMED_MENU_STAT; + + if (!parse_attr_string("file", data->node, &d->command)) { + d->command = g_strdup(""); + } + } else + if (!parse_attr_string("command", data->node, &d->command)) { + d->command = g_strdup(""); + } if (parse_attr_string("timeout", data->node, &timeout)) { char *endptr;

@@ -222,7 +279,6 @@ &timed_menu_timeout_handler, m);

} else d->timer = timer_start(600 * 1000000, &timed_menu_timeout_handler, m); - d->type = TIMED_MENU_PIPE; d->buf = NULL; d->buflen = 0; d->fd = -1;
M render/theme.crender/theme.c

@@ -59,6 +59,7 @@ theme->a_menu_title = RrAppearanceNew(inst, 1);

theme->a_menu_item = RrAppearanceNew(inst, 1); theme->a_menu_disabled = RrAppearanceNew(inst, 1); theme->a_menu_hilite = RrAppearanceNew(inst, 1); + theme->a_menu_bullet = RrAppearanceNew(inst, 1); theme->a_clear = RrAppearanceNew(inst, 0); theme->app_hilite_bg = RrAppearanceNew(inst, 0);

@@ -243,12 +244,16 @@ if (!read_color(db, inst,

"menu.frame.textColor", &theme->menu_color)) theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff); if (!read_color(db, inst, + "menu.bullet.picColor", &theme->menu_color)) + theme->menu_bullet_color = RrColorNew(inst, 0x00, 0x00, 0x00); + if (!read_color(db, inst, "menu.frame.disableColor", &theme->menu_disabled_color)) theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0); if (!read_color(db, inst, "menu.hilite.textColor", &theme->menu_hilite_color)) theme->menu_hilite_color = RrColorNew(inst, 0, 0, 0); + if (read_mask(inst, "max.xbm", theme, &theme->max_mask)) { if (!read_mask(inst, "max_pressed.xbm", theme, &theme->max_pressed_mask)) {

@@ -390,7 +395,14 @@ }

theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask); theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask); theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask); - } + } + + if (!read_mask(inst, "bullet.xbm", theme, &theme->menu_bullet_mask)) { + unsigned char data[] = + { 0x18, 0x30, 0x60, 0xfe, 0xfe, 0x60, 0x30, 0x18 }; + theme->menu_bullet_mask = RrPixmapMaskNew(inst, 8, 8, + (gchar *)data); + } /* read the decoration textures */ if (!read_appearance(db, inst,

@@ -616,6 +628,7 @@ theme->a_menu_title->texture[0].data.text.color = theme->menu_title_color;

theme->a_menu_item->surface.grad = theme->a_menu_disabled->surface.grad = + theme->a_menu_bullet->surface.grad = theme->app_icon->surface.grad = RR_SURFACE_PARENTREL; theme->a_menu_item->texture[0].type =

@@ -632,6 +645,8 @@ theme->a_menu_disabled->texture[0].data.text.color =

theme->menu_disabled_color; theme->a_menu_hilite->texture[0].data.text.color = theme->menu_hilite_color; + theme->a_menu_bullet->texture[0].data.mask.color = + theme->menu_bullet_color; theme->a_disabled_focused_max->texture[0].type = theme->a_disabled_unfocused_max->texture[0].type =

@@ -678,7 +693,9 @@ theme->a_hover_unfocused_iconify->texture[0].type =

theme->a_focused_unpressed_iconify->texture[0].type = theme->a_focused_pressed_iconify->texture[0].type = theme->a_unfocused_unpressed_iconify->texture[0].type = - theme->a_unfocused_pressed_iconify->texture[0].type = RR_TEXTURE_MASK; + theme->a_unfocused_pressed_iconify->texture[0].type = + theme->a_menu_bullet->texture[0].type = RR_TEXTURE_MASK; + theme->a_disabled_focused_max->texture[0].data.mask.mask = theme->a_disabled_unfocused_max->texture[0].data.mask.mask = theme->max_disabled_mask;

@@ -863,6 +880,7 @@ RrPixmapMaskFree(theme->close_mask);

RrPixmapMaskFree(theme->close_disabled_mask); RrPixmapMaskFree(theme->close_hover_mask); RrPixmapMaskFree(theme->close_pressed_mask); + RrPixmapMaskFree(theme->menu_bullet_mask); RrFontClose(theme->winfont); RrFontClose(theme->mtitlefont);
M render/theme.hrender/theme.h

@@ -40,6 +40,7 @@ RrColor *titlebut_focused_unpressed_color;

RrColor *titlebut_unfocused_unpressed_color; RrColor *menu_title_color; RrColor *menu_color; + RrColor *menu_bullet_color; RrColor *menu_disabled_color; RrColor *menu_hilite_color;

@@ -75,6 +76,9 @@ RrPixmapMask *close_mask;

RrPixmapMask *close_hover_mask; RrPixmapMask *close_disabled_mask; RrPixmapMask *close_pressed_mask; + + RrPixmapMask *menu_bullet_mask; /* submenu pointer */ + RrPixmapMask *menu_toggle_mask; /* menu boolean */ /* global appearances */ RrAppearance *a_disabled_focused_max;

@@ -138,6 +142,7 @@ RrAppearance *a_menu;

RrAppearance *a_menu_item; RrAppearance *a_menu_disabled; RrAppearance *a_menu_hilite; + RrAppearance *a_menu_bullet; RrAppearance *a_clear; RrAppearance *app_hilite_bg;

@@ -145,6 +150,7 @@ RrAppearance *app_unhilite_bg;

RrAppearance *app_hilite_label; RrAppearance *app_unhilite_label; RrAppearance *app_icon; + }; RrTheme *RrThemeNew(const RrInstance *inst, gchar *theme);