all repos — openbox @ 9aa42c2ae7b457db6efc1703dd47d1e3ac5e75e8

openbox fork - make it a bit more like ryudo

cleanups for keyboard menu shotcuts. dont let & set a shortcut from stuff like menu titles and what not, they are only for strigns oenbox provides.
Dana Jansens danakj@orodu.net
commit

9aa42c2ae7b457db6efc1703dd47d1e3ac5e75e8

parent

569b5aebbd64641486ca97c715089af0dbca5f97

M openbox/client_list_combined_menu.copenbox/client_list_combined_menu.c

@@ -70,10 +70,10 @@ acts = g_slist_append(acts, act);

if (c->iconic) { gchar *title = g_strdup_printf("(%s)", c->icon_title); - e = menu_add_normal(menu, i, title, acts); + e = menu_add_normal(menu, i, title, acts, FALSE); g_free(title); } else - e = menu_add_normal(menu, i, c->title, acts); + e = menu_add_normal(menu, i, c->title, acts, FALSE); if (config_menu_client_list_icons && (icon = client_icon(c, 32, 32))) {

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

act = action_from_string("Desktop", OB_USER_ACTION_MENU_SELECTION); act->data.desktop.desk = desktop; acts = g_slist_append(acts, act); - e = menu_add_normal(menu, 0, _("Go there..."), acts); + e = menu_add_normal(menu, 0, _("Go there..."), acts, TRUE); if (desktop == screen_desktop) e->data.normal.enabled = FALSE; }

@@ -138,7 +138,7 @@ {

if (!reconfig) client_add_destructor(client_dest, NULL); - combined_menu = menu_new(MENU_NAME, _("Windows"), NULL); + combined_menu = menu_new(MENU_NAME, _("Windows"), TRUE, NULL); menu_set_update_func(combined_menu, self_update); menu_set_execute_func(combined_menu, menu_execute); }
M openbox/client_list_menu.copenbox/client_list_menu.c

@@ -75,7 +75,8 @@ OB_USER_ACTION_MENU_SELECTION);

act->data.desktop.desk = d->desktop; acts = g_slist_append(acts, act); e = menu_add_normal(menu, i, - (c->iconic ? c->icon_title : c->title), acts); + (c->iconic ? c->icon_title : c->title), + acts, FALSE); if (config_menu_client_list_icons && (icon = client_icon(c, 32, 32))) {

@@ -96,7 +97,7 @@

act = action_from_string("Desktop", OB_USER_ACTION_MENU_SELECTION); act->data.desktop.desk = d->desktop; acts = g_slist_append(acts, act); - e = menu_add_normal(menu, 0, _("Go there..."), acts); + e = menu_add_normal(menu, 0, _("Go there..."), acts, TRUE); if (d->desktop == screen_desktop) e->data.normal.enabled = FALSE; }

@@ -138,7 +139,7 @@ gchar *name = g_strdup_printf("%s-%u", MENU_NAME, i);

DesktopData *data = g_new(DesktopData, 1); data->desktop = i; - submenu = menu_new(name, screen_desktop_names[i], data); + submenu = menu_new(name, screen_desktop_names[i], FALSE, data); menu_set_update_func(submenu, desk_menu_update); menu_set_execute_func(submenu, desk_menu_execute); menu_set_destroy_func(submenu, desk_menu_destroy);

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

if (!reconfig) client_add_destructor(client_dest, NULL); - menu = menu_new(MENU_NAME, _("Desktops"), NULL); + menu = menu_new(MENU_NAME, _("Desktops"), TRUE, NULL); menu_set_update_func(menu, self_update); }
M openbox/client_menu.copenbox/client_menu.c

@@ -72,12 +72,12 @@

e = menu_find_entry_id(menu, CLIENT_MAXIMIZE); menu_entry_set_label(e, (frame->client->max_vert || frame->client->max_horz ? - _("Restor&e") : _("Maximiz&e"))); + _("Restor&e") : _("Maximiz&e")), TRUE); e->data.normal.enabled =frame->client->functions & OB_CLIENT_FUNC_MAXIMIZE; e = menu_find_entry_id(menu, CLIENT_SHADE); menu_entry_set_label(e, (frame->client->shaded ? - _("&Roll down") : _("&Roll up"))); + _("&Roll down") : _("&Roll up")), TRUE); e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_SHADE; e = menu_find_entry_id(menu, CLIENT_MOVE);

@@ -150,7 +150,7 @@ OB_USER_ACTION_MENU_SELECTION);

act->data.sendto.desk = desk; act->data.sendto.follow = FALSE; acts = g_slist_prepend(NULL, act); - e = menu_add_normal(menu, desk, name, acts); + e = menu_add_normal(menu, desk, name, acts, FALSE); if (frame->client->desktop == desk) e->data.normal.enabled = FALSE;

@@ -163,31 +163,30 @@ GSList *acts;

ObMenu *menu; ObMenuEntry *e; - menu = menu_new(LAYER_MENU_NAME, _("&Layer"), NULL); + menu = menu_new(LAYER_MENU_NAME, _("&Layer"), TRUE, NULL); menu_show_all_shortcuts(menu, TRUE); menu_set_update_func(menu, layer_update); acts = g_slist_prepend(NULL, action_from_string ("SendToTopLayer", OB_USER_ACTION_MENU_SELECTION)); - menu_add_normal(menu, LAYER_TOP, _("Always on &top"), acts); + menu_add_normal(menu, LAYER_TOP, _("Always on &top"), acts, TRUE); acts = g_slist_prepend(NULL, action_from_string ("SendToNormalLayer", OB_USER_ACTION_MENU_SELECTION)); - menu_add_normal(menu, LAYER_NORMAL, _("&Normal"), acts); + menu_add_normal(menu, LAYER_NORMAL, _("&Normal"), acts, TRUE); acts = g_slist_prepend(NULL, action_from_string ("SendToBottomLayer", OB_USER_ACTION_MENU_SELECTION)); - menu_add_normal(menu, LAYER_BOTTOM, _("Always on &bottom"),acts); + menu_add_normal(menu, LAYER_BOTTOM, _("Always on &bottom"),acts, TRUE); - menu = menu_new(SEND_TO_MENU_NAME, _("&Send to desktop"), NULL); - menu_show_all_shortcuts(menu, TRUE); + menu = menu_new(SEND_TO_MENU_NAME, _("&Send to desktop"), TRUE, NULL); menu_set_update_func(menu, send_to_update); - menu = menu_new(CLIENT_MENU_NAME, _("Client menu"), NULL); + menu = menu_new(CLIENT_MENU_NAME, _("Client menu"), TRUE, NULL); menu_show_all_shortcuts(menu, TRUE); menu_set_update_func(menu, client_update);

@@ -197,7 +196,7 @@ menu_add_submenu(menu, CLIENT_LAYER, LAYER_MENU_NAME);

acts = g_slist_prepend(NULL, action_from_string ("Iconify", OB_USER_ACTION_MENU_SELECTION)); - e = menu_add_normal(menu, CLIENT_ICONIFY, _("Ico&nify"), acts); + e = menu_add_normal(menu, CLIENT_ICONIFY, _("Ico&nify"), acts, TRUE); e->data.normal.mask = ob_rr_theme->iconify_mask; e->data.normal.mask_normal_color = ob_rr_theme->menu_color; e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;

@@ -206,7 +205,7 @@

acts = g_slist_prepend(NULL, action_from_string ("ToggleMaximizeFull", OB_USER_ACTION_MENU_SELECTION)); - e = menu_add_normal(menu, CLIENT_MAXIMIZE, "MAXIMIZE", acts); + e = menu_add_normal(menu, CLIENT_MAXIMIZE, "MAXIMIZE", acts, TRUE); e->data.normal.mask = ob_rr_theme->max_mask; e->data.normal.mask_normal_color = ob_rr_theme->menu_color; e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;

@@ -214,15 +213,15 @@ e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color;

acts = g_slist_prepend(NULL, action_from_string ("Raise", OB_USER_ACTION_MENU_SELECTION)); - menu_add_normal(menu, CLIENT_RAISE, _("Raise to &top"), acts); + menu_add_normal(menu, CLIENT_RAISE, _("Raise to &top"), acts, TRUE); acts = g_slist_prepend(NULL, action_from_string ("Lower", OB_USER_ACTION_MENU_SELECTION)); - menu_add_normal(menu, CLIENT_LOWER, _("Lower to &bottom"),acts); + menu_add_normal(menu, CLIENT_LOWER, _("Lower to &bottom"),acts, TRUE); acts = g_slist_prepend(NULL, action_from_string ("ToggleShade", OB_USER_ACTION_MENU_SELECTION)); - e = menu_add_normal(menu, CLIENT_SHADE, "SHADE", acts); + e = menu_add_normal(menu, CLIENT_SHADE, "SHADE", acts, TRUE); e->data.normal.mask = ob_rr_theme->shade_mask; e->data.normal.mask_normal_color = ob_rr_theme->menu_color; e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;

@@ -231,23 +230,23 @@

acts = g_slist_prepend(NULL, action_from_string ("ToggleDecorations", OB_USER_ACTION_MENU_SELECTION)); - menu_add_normal(menu, CLIENT_DECORATE, _("&Decorate"), acts); + menu_add_normal(menu, CLIENT_DECORATE, _("&Decorate"), acts, TRUE); menu_add_separator(menu, -1, NULL); acts = g_slist_prepend(NULL, action_from_string ("Move", OB_USER_ACTION_MENU_SELECTION)); - menu_add_normal(menu, CLIENT_MOVE, _("&Move"), acts); + menu_add_normal(menu, CLIENT_MOVE, _("&Move"), acts, TRUE); acts = g_slist_prepend(NULL, action_from_string ("Resize", OB_USER_ACTION_MENU_SELECTION)); - menu_add_normal(menu, CLIENT_RESIZE, _("Resi&ze"), acts); + menu_add_normal(menu, CLIENT_RESIZE, _("Resi&ze"), acts, TRUE); menu_add_separator(menu, -1, NULL); acts = g_slist_prepend(NULL, action_from_string ("Close", OB_USER_ACTION_MENU_SELECTION)); - e = menu_add_normal(menu, CLIENT_CLOSE, _("&Close"), acts); + e = menu_add_normal(menu, CLIENT_CLOSE, _("&Close"), acts, TRUE); e->data.normal.mask = ob_rr_theme->close_mask; e->data.normal.mask_normal_color = ob_rr_theme->menu_color; e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
M openbox/event.copenbox/event.c

@@ -52,6 +52,9 @@ #endif

#ifdef HAVE_SIGNAL_H # include <signal.h> #endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> /* for usleep() */ +#endif #ifdef XKB # include <X11/XKBlib.h> #endif
M openbox/menu.copenbox/menu.c

@@ -54,8 +54,8 @@ xmlDocPtr doc, xmlNodePtr node,

gpointer data); static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, gpointer data); -static gunichar parse_shortcut(const gchar *label, gchar **strippedlabel, - guint *position); +static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut, + gchar **strippedlabel, guint *position); static void client_dest(ObClient *client, gpointer data)

@@ -185,8 +185,8 @@ #define VALID_SHORTCUT(c) (((c) >= '0' && (c) <= '9') || \

((c) >= 'A' && (c) <= 'Z') || \ ((c) >= 'a' && (c) <= 'z')) -static gunichar parse_shortcut(const gchar *label, gchar **strippedlabel, - guint *position) +static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut, + gchar **strippedlabel, guint *position) { gunichar shortcut = 0;

@@ -201,8 +201,12 @@ gchar *i;

*strippedlabel = g_strdup(label); + /* if allow_shortcut is false, then you can't use the &, instead you + have to just use the first valid character + */ + i = strchr(*strippedlabel, '&'); - if (i != NULL) { + if (allow_shortcut && i != NULL) { /* there is an ampersand in the string */ /* you have to use a printable ascii character for shortcuts

@@ -248,7 +252,7 @@ (i, doc, node, OB_USER_ACTION_MENU_SELECTION);

if (a) acts = g_slist_append(acts, a); } - menu_add_normal(state->parent, -1, label, acts); + menu_add_normal(state->parent, -1, label, acts, FALSE); g_free(label); } }

@@ -285,7 +289,7 @@ if (!g_hash_table_lookup(menu_hash, name)) {

if (!parse_attr_string("label", node, &title)) goto parse_menu_fail; - if ((menu = menu_new(name, title, NULL))) { + if ((menu = menu_new(name, title, FALSE, NULL))) { menu->pipe_creator = state->pipe_creator; if (parse_attr_string("execute", node, &script)) { menu->execute = parse_expand_tilde(script);

@@ -309,7 +313,8 @@ g_free(title);

g_free(script); } -ObMenu* menu_new(const gchar *name, const gchar *title, gpointer data) +ObMenu* menu_new(const gchar *name, const gchar *title, + gboolean allow_shortcut, gpointer data) { ObMenu *self;

@@ -317,7 +322,7 @@ self = g_new0(ObMenu, 1);

self->name = g_strdup(name); self->data = data; - self->shortcut = parse_shortcut(title, &self->title, + self->shortcut = parse_shortcut(title, allow_shortcut, &self->title, &self->shortcut_position); g_hash_table_replace(menu_hash, self->name, self);

@@ -459,14 +464,14 @@ menu_entry_free(self);

} ObMenuEntry* menu_add_normal(ObMenu *self, gint id, const gchar *label, - GSList *actions) + GSList *actions, gboolean allow_shortcut) { ObMenuEntry *e; e = menu_entry_new(self, OB_MENU_ENTRY_TYPE_NORMAL, id); e->data.normal.actions = actions; - menu_entry_set_label(e, label); + menu_entry_set_label(e, label, allow_shortcut); self->entries = g_list_append(self->entries, e); return e;

@@ -489,7 +494,7 @@ ObMenuEntry *e;

e = menu_entry_new(self, OB_MENU_ENTRY_TYPE_SEPARATOR, id); - menu_entry_set_label(e, label); + menu_entry_set_label(e, label, FALSE); self->entries = g_list_append(self->entries, e); return e;

@@ -538,7 +543,8 @@ e->data.submenu.submenu = menu_from_name(e->data.submenu.name);

} } -void menu_entry_set_label(ObMenuEntry *self, const gchar *label) +void menu_entry_set_label(ObMenuEntry *self, const gchar *label, + gboolean allow_shortcut) { switch (self->type) { case OB_MENU_ENTRY_TYPE_SEPARATOR:

@@ -548,7 +554,7 @@ break;

case OB_MENU_ENTRY_TYPE_NORMAL: g_free(self->data.normal.label); self->data.normal.shortcut = - parse_shortcut(label, &self->data.normal.label, + parse_shortcut(label, allow_shortcut, &self->data.normal.label, &self->data.normal.shortcut_position); break; default:
M openbox/menu.hopenbox/menu.h

@@ -133,7 +133,10 @@

void menu_startup(gboolean reconfig); void menu_shutdown(gboolean reconfig); -ObMenu* menu_new(const gchar *name, const gchar *title, gpointer data); +/*! @param allow_shortcut this should be false when the label is coming from + outside data like window or desktop titles */ +ObMenu* menu_new(const gchar *name, const gchar *title, + gboolean allow_shortcut, gpointer data); void menu_free(ObMenu *menu); /* Repopulate a pipe-menu by running its command */

@@ -148,15 +151,18 @@ void menu_set_execute_func(ObMenu *menu, ObMenuExecuteFunc func);

void menu_set_destroy_func(ObMenu *menu, ObMenuDestroyFunc func); /* functions for building menus */ +/*! @param allow_shortcut this should be false when the label is coming from + outside data like window or desktop titles */ ObMenuEntry* menu_add_normal(ObMenu *menu, gint id, const gchar *label, - GSList *actions); + GSList *actions, gboolean allow_shortcut); ObMenuEntry* menu_add_submenu(ObMenu *menu, gint id, const gchar *submenu); ObMenuEntry* menu_add_separator(ObMenu *menu, gint id, const gchar *label); void menu_clear_entries(ObMenu *menu); void menu_entry_remove(ObMenuEntry *self); -void menu_entry_set_label(ObMenuEntry *self, const gchar *label); +void menu_entry_set_label(ObMenuEntry *self, const gchar *label, + gboolean allow_shortcut); ObMenuEntry* menu_find_entry_id(ObMenu *self, gint id);