1 #include "openbox/action.h"
2 #include "openbox/action_list_run.h"
3 #include "openbox/config_value.h"
4 #include "openbox/client_set.h"
5 #include "openbox/menu.h"
12 static gpointer setup_func(GHashTable *config);
13 static void free_func(gpointer options);
14 static gboolean run_func(const ObClientSet *set,
15 const ObActionListRun *data, gpointer options);
17 void action_showmenu_startup(void)
19 action_register("ShowMenu", OB_ACTION_DEFAULT_FILTER_SINGLE,
20 setup_func, free_func, run_func);
23 static gpointer setup_func(GHashTable *config)
28 o = g_slice_new0(Options);
30 v = g_hash_table_lookup(config, "menu");
31 if (v && config_value_is_string(v))
32 o->name = g_strdup(config_value_string(v));
36 static void free_func(gpointer options)
40 g_slice_free(Options, o);
43 /* Always return FALSE because its not interactive */
44 static gboolean run_func(const ObClientSet *set,
45 const ObActionListRun *data, gpointer options)
51 /* this can't work on more than one window */
52 if (client_set_size(set) > 1) return FALSE;
54 list = client_set_get_all(set);
55 if (list) c = list->data;
59 /* you cannot call ShowMenu from inside a menu */
60 if (data->user_act != OB_USER_ACTION_MENU_SELECTION && o->name)
61 menu_show(o->name, data->pointer_x, data->pointer_y,
62 data->pointer_button != 0, c);