all repos — openbox @ 38268dc917ac9e59d9e8ef87825c9489ced77e95

openbox fork - make it a bit more like ryudo

add the showmenu action
Dana Jansens danakj@orodu.net
commit

38268dc917ac9e59d9e8ef87825c9489ced77e95

parent

9dacac5e5e6b9ed86e76680b048bc227d8866ac6

M Makefile.amMakefile.am

@@ -158,6 +158,7 @@ openbox/actions/all.c \

openbox/actions/all.h \ openbox/actions/debug.c \ openbox/actions/execute.c \ + openbox/actions/showmenu.c \ openbox/actions.c \ openbox/actions.h \ openbox/client.c \
M openbox/action.copenbox/action.c

@@ -458,18 +458,6 @@ uact == OB_USER_ACTION_MENU_SELECTION);

(*a)->data.moveresize.corner = 0; } -void setup_action_showmenu(ObAction **a, ObUserAction uact) -{ - (*a)->data.showmenu.any.client_action = OB_CLIENT_ACTION_OPTIONAL; - /* you cannot call ShowMenu from inside a menu, cuz the menu code makes - assumptions that there is only one menu (and submenus) open at - a time! */ - if (uact == OB_USER_ACTION_MENU_SELECTION) { - action_unref(*a); - *a = NULL; - } -} - void setup_action_addremove_desktop_current(ObAction **a, ObUserAction uact) { (*a)->data.addremovedesktop.current = TRUE;

@@ -492,16 +480,6 @@ }

ActionString actionstrings[] = { - { - "debug", - action_debug, - NULL - }, - { - "execute", - action_execute, - NULL - }, { "directionalfocusnorth", action_directional_focus,

@@ -833,11 +811,6 @@ action_exit,

NULL }, { - "showmenu", - action_showmenu, - setup_action_showmenu - }, - { "sendtotoplayer", action_send_to_layer, setup_action_top_layer

@@ -1005,9 +978,6 @@ xmlNodePtr n;

if (parse_attr_string("name", node, &actname)) { if ((act = action_from_string(actname, uact))) { - } else if (act->func == action_showmenu) { - if ((n = parse_find_node("menu", node->xmlChildrenNode))) - act->data.showmenu.name = parse_string(doc, n); } else if (act->func == action_move_relative_horz || act->func == action_move_relative_vert || act->func == action_resize_relative_horz ||

@@ -1220,16 +1190,6 @@

l = g_slist_append(NULL, a); action_run(l, c, 0, time); -} - -void action_debug(union ActionData *data) -{ - if (data->debug.string) - g_print("%s\n", data->debug.string); -} - -void action_execute(union ActionData *data) -{ } void action_activate(union ActionData *data)

@@ -1774,14 +1734,6 @@

void action_exit(union ActionData *data) { ob_exit(0); -} - -void action_showmenu(union ActionData *data) -{ - if (data->showmenu.name) { - menu_show(data->showmenu.name, data->any.x, data->any.y, - data->any.button, data->showmenu.any.c); - } } void action_cycle_windows(union ActionData *data)
M openbox/actions/all.copenbox/actions/all.c

@@ -4,4 +4,5 @@ void action_all_startup()

{ action_execute_startup(); action_debug_startup(); + action_showmenu_startup(); }
M openbox/actions/all.hopenbox/actions/all.h

@@ -5,5 +5,6 @@ void action_all_startup();

void action_execute_startup(); void action_debug_startup(); +void action_showmenu_startup(); #endif
A openbox/actions/showmenu.c

@@ -0,0 +1,69 @@

+#include "openbox/actions.h" +#include <glib.h> + +typedef struct { + gchar *name; +} Options; + +static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); +static void free_func(gpointer options); +static gboolean run_func(ObActionsData *data, gpointer options); +/* +static gboolean i_input_func(guint initial_state, + XEvent *e, + gpointer options, + gboolean *used); +static void i_cancel_func(gpointer options); +*/ + +void action_showmenu_startup() +{ + actions_register("ShowMenu", + setup_func, + free_func, + run_func, + NULL, NULL); +} + +static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +{ + xmlNodePtr n; + Options *o; + + o = g_new0(Options, 1); + + if ((n = parse_find_node("menu", node))) + o->name = parse_string(doc, n); + return o; +} + +static void free_func(gpointer options) +{ + Options *o = options; + + if (o) { + g_free(o->name); + g_free(o); + } +} + +/* Always return FALSE because its not interactive */ +static gboolean run_func(ObActionsData *data, gpointer options) +{ + Options *o = options; + + /* you cannot call ShowMenu from inside a menu */ + if (data->uact == OB_USER_ACTION_MENU_SELECTION) return FALSE; + + if (o->name) { + gboolean mouse = (data->uact == OB_USER_ACTION_MOUSE_PRESS || + data->uact == OB_USER_ACTION_MOUSE_RELEASE || + data->uact == OB_USER_ACTION_MOUSE_CLICK || + data->uact == OB_USER_ACTION_MOUSE_DOUBLE_CLICK || + data->uact == OB_USER_ACTION_MOUSE_MOTION); + + menu_show(o->name, data->x, data->y, mouse, data->client); + } + + return FALSE; +}
M openbox/client_menu.copenbox/client_menu.c

@@ -293,11 +293,11 @@ menu_frame_hide_all();

} static void client_menu_place(ObMenuFrame *frame, gint *x, gint *y, - gint button, gpointer data) + gboolean mouse, gpointer data) { gint dx, dy; - if (button == 0 && frame->client) { + if (!mouse && frame->client) { *x = frame->client->frame->area.x; /* try below the titlebar */
M openbox/menu.copenbox/menu.c

@@ -407,7 +407,7 @@ menu_can_hide = TRUE;

return FALSE; /* no repeat */ } -void menu_show(gchar *name, gint x, gint y, gint button, ObClient *client) +void menu_show(gchar *name, gint x, gint y, gboolean mouse, ObClient *client) { ObMenu *self; ObMenuFrame *frame;

@@ -429,10 +429,10 @@ /* clear the pipe menus when showing a new menu */

menu_clear_pipe_caches(); frame = menu_frame_new(self, 0, client); - if (!menu_frame_show_topmenu(frame, x, y, button)) + if (!menu_frame_show_topmenu(frame, x, y, mouse)) menu_frame_free(frame); else { - if (!button) { + if (!mouse) { /* select the first entry if it's not a submenu and we opened * the menu with the keyboard, and skip all headers */ GList *it = frame->entries;

@@ -449,7 +449,7 @@ }

} /* reset the hide timer */ - if (!button) + if (!mouse) menu_can_hide = TRUE; else { menu_can_hide = FALSE;
M openbox/menu.hopenbox/menu.h

@@ -52,7 +52,7 @@ @param y is the mouse y coordinate. on return it should be the y coordinate

for the menu */ typedef void (*ObMenuPlaceFunc)(struct _ObMenuFrame *frame, gint *x, gint *y, - gint button, gpointer data); + gboolean mouse, gpointer data); struct _ObMenu {

@@ -174,7 +174,7 @@ void menu_clear_pipe_caches();

void menu_show_all_shortcuts(ObMenu *self, gboolean show); -void menu_show(gchar *name, gint x, gint y, gint button, +void menu_show(gchar *name, gint x, gint y, gboolean mouse, struct _ObClient *client); gboolean menu_hide_delay_reached();
M openbox/menuframe.copenbox/menuframe.c

@@ -941,7 +941,7 @@ return TRUE;

} gboolean menu_frame_show_topmenu(ObMenuFrame *self, gint x, gint y, - gint button) + gboolean mouse) { gint px, py; guint i;

@@ -963,7 +963,7 @@ }

} if (self->menu->place_func) - self->menu->place_func(self, &x, &y, button, self->menu->data); + self->menu->place_func(self, &x, &y, mouse, self->menu->data); else menu_frame_place_topmenu(self, &x, &y);