X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Faction.c;h=f780ce884b8fa2629ec768e202faae7f1c244e66;hb=32047fd66c796fe837168ce2ac6677aa0d2b20b4;hp=e16e177a1d01da9991732a980e7e373dca224060;hpb=0f544808b8372a6c8a2cbfae214f2803dd3c6170;p=chaz%2Fopenbox diff --git a/openbox/action.c b/openbox/action.c index e16e177a..f780ce88 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -1,3 +1,21 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + action.c for the Openbox window manager + Copyright (c) 2003 Ben Jansens + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + See the COPYING file for a copy of the GNU General Public License. +*/ + #include "debug.h" #include "client.h" #include "focus.h" @@ -10,11 +28,12 @@ #include "openbox.h" #include "grab.h" #include "keyboard.h" +#include "event.h" #include typedef struct ActionString { - char *name; + const gchar *name; void (*func)(union ActionData *); void (*setup)(ObAction **, ObUserAction uact); } ActionString; @@ -686,7 +705,7 @@ ActionString actionstrings[] = } }; -ObAction *action_from_string(char *name, ObUserAction uact) +ObAction *action_from_string(const gchar *name, ObUserAction uact) { ObAction *a = NULL; gboolean exist = FALSE; @@ -723,7 +742,7 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, if (act->func == action_execute || act->func == action_restart) { if ((n = parse_find_node("execute", node->xmlChildrenNode))) { gchar *s = parse_string(doc, n); - act->data.execute.path = ob_expand_tilde(s); + act->data.execute.path = parse_expand_tilde(s); g_free(s); } } else if (act->func == action_showmenu) { @@ -766,28 +785,51 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, return act; } -void action_run_full(ObAction *a, struct _ObClient *c, - ObFrameContext context, +void action_run_list(GSList *acts, struct _ObClient *c, guint state, guint button, gint x, gint y, gboolean cancel, gboolean done) { + GSList *it; + ObAction *a; + gboolean inter = FALSE; + if (x < 0 && y < 0) screen_pointer_pos(&x, &y); - a->data.any.c = c; - a->data.any.x = x; - a->data.any.y = y; - - a->data.any.button = button; + for (it = acts; it; it = g_slist_next(it)) { + a = it->data; + if (a->data.any.interactive) { + inter = TRUE; + break; + } + } - if (a->data.any.interactive) { - a->data.inter.cancel = cancel; - a->data.inter.final = done; - if (!(cancel || done)) - keyboard_interactive_grab(state, c, context, a); + if (!inter) { + /* sometimes when we execute another app as an action, + it won't work right unless we XUngrabKeyboard first, + even though we grabbed the key/button Asychronously. + e.g. "gnome-panel-control --main-menu" */ + XUngrabKeyboard(ob_display, event_lasttime); } - a->func(&a->data); + for (it = acts; it; it = g_slist_next(it)) { + a = it->data; + + a->data.any.c = c; + a->data.any.x = x; + a->data.any.y = y; + + a->data.any.button = button; + + if (a->data.any.interactive) { + a->data.inter.cancel = cancel; + a->data.inter.final = done; + if (!(cancel || done)) + keyboard_interactive_grab(state, c, a); + } + + a->func(&a->data); + } } void action_execute(union ActionData *data) @@ -801,6 +843,7 @@ void action_execute(union ActionData *data) g_warning("failed to execute '%s': %s", cmd, e->message); } + g_free(cmd); } else { g_warning("failed to convert '%s' from utf8", data->execute.path); } @@ -1167,7 +1210,7 @@ void action_restart(union ActionData *data) void action_exit(union ActionData *data) { - ob_exit(); + ob_exit(0); } void action_showmenu(union ActionData *data) @@ -1232,11 +1275,12 @@ void action_growtoedge(union ActionData *data) { int x, y, width, height, dest; ObClient *c = data->diraction.any.c; - Rect *a = screen_area(c->desktop); + Rect *a; if (!c) return; + a = screen_area(c->desktop); x = c->frame->area.x; y = c->frame->area.y; width = c->frame->area.width;