X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Factions%2Fshowmenu.c;h=e60f1c69e4fd280e0a856c24d3e6cc11a9132716;hb=b06b684589a618a2481ccc2745d5e03abb6bd5e0;hp=ec22de5bde667c5915946944f8fcc70b6b060334;hpb=1b7e813c62a6e54690d15550d51ac4269e63f346;p=chaz%2Fopenbox diff --git a/openbox/actions/showmenu.c b/openbox/actions/showmenu.c index ec22de5b..e60f1c69 100644 --- a/openbox/actions/showmenu.c +++ b/openbox/actions/showmenu.c @@ -1,43 +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); -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); - 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_free(o); } /* Always return FALSE because its not interactive */ @@ -46,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; }