X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=openbox%2Faction.c;h=9d2554f5a1cdcb584a6f3fa6d07213bae3edf48b;hb=ad29434250f6c34ed2af8f99bed7a4e8d6b5053b;hp=52a602ccf7071ba53818f0737a8307c4a5083d0c;hpb=adb9bb700f3235728dacc1d3e3daad81abd93e9a;p=chaz%2Fopenbox diff --git a/openbox/action.c b/openbox/action.c index 52a602cc..9d2554f5 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -30,6 +30,7 @@ #include "keyboard.h" #include "event.h" #include "config.h" +#include "mainloop.h" #include @@ -94,6 +95,21 @@ void action_unref(ObAction *a) g_free(a); } +ObAction* action_copy(const ObAction *src) +{ + ObAction *a = action_new(src->func); + + a->data = src->data; + + /* deal with pointers */ + if (a->func == action_execute || a->func == action_restart) + a->data.execute.path = g_strdup(a->data.execute.path); + else if (a->func == action_showmenu) + a->data.showmenu.name = g_strdup(a->data.showmenu.name); + + return a; +} + void setup_action_directional_focus_north(ObAction **a, ObUserAction uact) { (*a)->data.interdiraction.inter.any.interactive = TRUE; @@ -346,7 +362,8 @@ void setup_action_move(ObAction **a, ObUserAction uact) (*a)->data.moveresize.any.client_action = OB_CLIENT_ACTION_ALWAYS; (*a)->data.moveresize.move = TRUE; (*a)->data.moveresize.keyboard = - (uact == OB_USER_ACTION_KEYBOARD_KEY || + (uact == OB_USER_ACTION_NONE || + uact == OB_USER_ACTION_KEYBOARD_KEY || uact == OB_USER_ACTION_MENU_SELECTION); } @@ -355,7 +372,8 @@ void setup_action_resize(ObAction **a, ObUserAction uact) (*a)->data.moveresize.any.client_action = OB_CLIENT_ACTION_ALWAYS; (*a)->data.moveresize.move = FALSE; (*a)->data.moveresize.keyboard = - (uact == OB_USER_ACTION_KEYBOARD_KEY || + (uact == OB_USER_ACTION_NONE || + uact == OB_USER_ACTION_KEYBOARD_KEY || uact == OB_USER_ACTION_MENU_SELECTION); } @@ -903,11 +921,24 @@ void action_run_list(GSList *acts, ObClient *c, ObFrameContext context, keyboard_interactive_grab(state, a->data.any.c, a); } - a->func(&a->data); + ob_main_loop_queue_action(ob_main_loop, a); } } } +void action_run_string(const gchar *name, struct _ObClient *c) +{ + ObAction *a; + GSList *l; + + a = action_from_string(name, OB_USER_ACTION_NONE); + g_assert(a); + + l = g_slist_append(NULL, a); + + action_run(l, c, 0); +} + void action_execute(union ActionData *data) { GError *e = NULL; @@ -968,15 +999,7 @@ void action_raiselower(union ActionData *data) } } - if (raise) { - client_action_start(data); - stacking_raise(CLIENT_AS_WINDOW(c)); - client_action_end(data); - } else { - client_action_start(data); - stacking_lower(CLIENT_AS_WINDOW(c)); - client_action_end(data); - } + action_run_string((raise ? "Raise" : "Lower"), c); } void action_raise(union ActionData *data) @@ -988,26 +1011,18 @@ void action_raise(union ActionData *data) void action_unshaderaise(union ActionData *data) { - if (data->client.any.c->shaded) { - client_action_start(data); - client_shade(data->client.any.c, FALSE); - client_action_end(data); - } else { - client_action_start(data); - stacking_raise(CLIENT_AS_WINDOW(data->client.any.c)); - client_action_end(data); - } + if (data->client.any.c->shaded) + action_run_string("Unshade", data->client.any.c); + else + action_run_string("Raise", data->client.any.c); } void action_shadelower(union ActionData *data) { if (data->client.any.c->shaded) - stacking_lower(CLIENT_AS_WINDOW(data->client.any.c)); - else { - client_action_start(data); - client_shade(data->client.any.c, TRUE); - client_action_end(data); - } + action_run_string("Lower", data->client.any.c); + else + action_run_string("Shade", data->client.any.c); } void action_lower(union ActionData *data)