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 \
(*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;
ActionString actionstrings[] =
{
- {
- "debug",
- action_debug,
- NULL
- },
- {
- "execute",
- action_execute,
- NULL
- },
{
"directionalfocusnorth",
action_directional_focus,
action_exit,
NULL
},
- {
- "showmenu",
- action_showmenu,
- setup_action_showmenu
- },
{
"sendtotoplayer",
action_send_to_layer,
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 ||
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)
{
if (data->client.any.c) {
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)
{
/* if using focus_delay, stop the timer now so that focus doesn't go moving
{
action_execute_startup();
action_debug_startup();
+ action_showmenu_startup();
}
void action_execute_startup();
void action_debug_startup();
+void action_showmenu_startup();
#endif
--- /dev/null
+#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;
+}
}
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 */
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;
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;
}
/* reset the hide timer */
- if (!button)
+ if (!mouse)
menu_can_hide = TRUE;
else {
menu_can_hide = FALSE;
for the menu
*/
typedef void (*ObMenuPlaceFunc)(struct _ObMenuFrame *frame, gint *x, gint *y,
- gint button, gpointer data);
+ gboolean mouse, gpointer data);
struct _ObMenu
{
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();
}
gboolean menu_frame_show_topmenu(ObMenuFrame *self, gint x, gint y,
- gint button)
+ gboolean mouse)
{
gint px, py;
guint i;
}
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);