X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=openbox%2Factions%2Fshowmenu.c;h=485a31d5a7e06880eee48d0f1f6aef512db13911;hb=f55caaf6a003c8e9dece297e0e1aca89a1ee99ef;hp=6b6cbbe0f10053f6bbbb7131259f4fee048614db;hpb=38268dc917ac9e59d9e8ef87825c9489ced77e95;p=chaz%2Fopenbox diff --git a/openbox/actions/showmenu.c b/openbox/actions/showmenu.c index 6b6cbbe0..485a31d5 100644 --- a/openbox/actions/showmenu.c +++ b/openbox/actions/showmenu.c @@ -1,50 +1,37 @@ #include "openbox/actions.h" +#include "openbox/menu.h" #include typedef struct { gchar *name; } Options; -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); +static gpointer setup_func(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() +void action_showmenu_startup(void) { - actions_register("ShowMenu", - setup_func, - free_func, - run_func, - NULL, NULL); + actions_register("ShowMenu", setup_func, free_func, run_func); } -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; - o = g_new0(Options, 1); + o = g_slice_new0(Options); - if ((n = parse_find_node("menu", node))) - o->name = parse_string(doc, n); + if ((n = obt_xml_find_node(node, "menu"))) + o->name = obt_xml_node_string(n); return o; } static void free_func(gpointer options) { Options *o = options; - - if (o) { - g_free(o->name); - g_free(o); - } + g_free(o->name); + g_slice_free(Options, o); } /* Always return FALSE because its not interactive */ @@ -53,17 +40,8 @@ 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); - } + if (data->uact != OB_USER_ACTION_MENU_SELECTION && o->name) + menu_show(o->name, data->x, data->y, data->button != 0, data->client); return FALSE; }