diff options
| author | Dana Jansens <danakj@orodu.net> | 2007-06-22 03:53:22 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2007-06-22 03:53:22 +0000 |
| commit | 38268dc917ac9e59d9e8ef87825c9489ced77e95 (patch) | |
| tree | a66a1deb0f3a9f97e1ffce690b0a7c8e6f579455 /openbox/actions | |
| parent | 9dacac5e5e6b9ed86e76680b048bc227d8866ac6 (diff) | |
add the showmenu action
Diffstat (limited to 'openbox/actions')
| -rw-r--r-- | openbox/actions/all.c | 1 | ||||
| -rw-r--r-- | openbox/actions/all.h | 1 | ||||
| -rw-r--r-- | openbox/actions/showmenu.c | 69 |
3 files changed, 71 insertions, 0 deletions
diff --git a/openbox/actions/all.c b/openbox/actions/all.c index 09eae59a..e0485ebe 100644 --- a/openbox/actions/all.c +++ b/openbox/actions/all.c @@ -4,4 +4,5 @@ void action_all_startup() { action_execute_startup(); action_debug_startup(); + action_showmenu_startup(); } diff --git a/openbox/actions/all.h b/openbox/actions/all.h index b93f140a..13fbbd46 100644 --- a/openbox/actions/all.h +++ b/openbox/actions/all.h @@ -5,5 +5,6 @@ void action_all_startup(); void action_execute_startup(); void action_debug_startup(); +void action_showmenu_startup(); #endif diff --git a/openbox/actions/showmenu.c b/openbox/actions/showmenu.c new file mode 100644 index 00000000..6b6cbbe0 --- /dev/null +++ b/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; +} |
