From 16324b037bc467f721ee2de074752beb02438e58 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 2 Mar 2008 02:02:57 +0100 Subject: [PATCH] Add Stop action. --- Makefile.am | 1 + openbox/actions.c | 27 ++++++++++++++------------- openbox/actions.h | 16 ++++++++-------- openbox/actions/all.c | 1 + openbox/actions/all.h | 1 + openbox/actions/allclients.c | 7 ++++--- openbox/actions/if.c | 8 +++----- openbox/actions/stop.c | 14 ++++++++++++++ 8 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 openbox/actions/stop.c diff --git a/Makefile.am b/Makefile.am index b5e132d4..4e7a55a2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -210,6 +210,7 @@ openbox_openbox_SOURCES = \ openbox/actions/shade.c \ openbox/actions/showdesktop.c \ openbox/actions/showmenu.c \ + openbox/actions/stop.c \ openbox/actions/unfocus.c \ openbox/actions.c \ openbox/actions.h \ diff --git a/openbox/actions.c b/openbox/actions.c index c49d80a7..fec27aba 100644 --- a/openbox/actions.c +++ b/openbox/actions.c @@ -221,14 +221,14 @@ static void actions_setup_data(ObActionsData *data, data->client = client; } -void actions_run_acts(GSList *acts, - ObUserAction uact, - guint state, - gint x, - gint y, - gint button, - ObFrameContext con, - struct _ObClient *client) +gboolean actions_run_acts(GSList *acts, + ObUserAction uact, + guint state, + gint x, + gint y, + gint button, + ObFrameContext con, + struct _ObClient *client) { GSList *it; @@ -264,14 +264,15 @@ void actions_run_acts(GSList *acts, if (actions_act_is_interactive(act)) actions_interactive_end_act(); } else { - /* make sure its interactive if it returned TRUE */ - g_assert(act->def->i_cancel && act->def->i_input); - - /* no actions are run after the interactive one */ - break; + /* stop running actions if some return TRUE + This happens either from interactive actions or + the Stop action. */ + return TRUE; } } } + + return FALSE; } gboolean actions_interactive_act_running(void) diff --git a/openbox/actions.h b/openbox/actions.h index 0b2dd996..6def4c3e 100644 --- a/openbox/actions.h +++ b/openbox/actions.h @@ -82,14 +82,14 @@ void actions_set_need_pointer_replay_before_move(gboolean replay); gboolean actions_get_need_pointer_replay_before_move(void); /*! Pass in a GSList of ObActionsAct's to be run. */ -void actions_run_acts(GSList *acts, - ObUserAction uact, - guint state, - gint x, - gint y, - gint button, - ObFrameContext con, - struct _ObClient *client); +gboolean actions_run_acts(GSList *acts, + ObUserAction uact, + guint state, + gint x, + gint y, + gint button, + ObFrameContext con, + struct _ObClient *client); gboolean actions_interactive_act_running(void); void actions_interactive_cancel_act(void); diff --git a/openbox/actions/all.c b/openbox/actions/all.c index 5bb71630..7dd9022a 100644 --- a/openbox/actions/all.c +++ b/openbox/actions/all.c @@ -42,4 +42,5 @@ void action_all_startup(void) action_sendkeyevent_startup(); action_lock_startup(); action_zenbu_startup(); + action_stop_startup(); } diff --git a/openbox/actions/all.h b/openbox/actions/all.h index 9890ea56..5d79d0e6 100644 --- a/openbox/actions/all.h +++ b/openbox/actions/all.h @@ -43,5 +43,6 @@ void action_focustobottom_startup(void); void action_sendkeyevent_startup(void); void action_lock_startup(void); void action_zenbu_startup(void); +void action_stop_startup(void); #endif diff --git a/openbox/actions/allclients.c b/openbox/actions/allclients.c index d7af806d..12905799 100644 --- a/openbox/actions/allclients.c +++ b/openbox/actions/allclients.c @@ -45,9 +45,10 @@ static gboolean run_func(ObActionsData *data, gpointer acts) if (a) for (it = client_list; it; it = g_list_next(it)) { ObClient *c = it->data; - actions_run_acts(a, data->uact, data->state, - data->x, data->y, data->button, - data->context, c); + if (actions_run_acts(a, data->uact, data->state, + data->x, data->y, data->button, + data->context, c)) + return TRUE; } return FALSE; diff --git a/openbox/actions/if.c b/openbox/actions/if.c index 19b01475..96ebd063 100644 --- a/openbox/actions/if.c +++ b/openbox/actions/if.c @@ -192,9 +192,7 @@ static gboolean run_func(ObActionsData *data, gpointer options) else acts = o->elseacts; - actions_run_acts(acts, data->uact, data->state, - data->x, data->y, data->button, - data->context, data->client); - - return FALSE; + return actions_run_acts(acts, data->uact, data->state, + data->x, data->y, data->button, + data->context, data->client); } diff --git a/openbox/actions/stop.c b/openbox/actions/stop.c new file mode 100644 index 00000000..4eb3dfdc --- /dev/null +++ b/openbox/actions/stop.c @@ -0,0 +1,14 @@ +#include "openbox/actions.h" + +static gboolean run_func(ObActionsData *data, gpointer options); + +void action_stop_startup(void) +{ + actions_register("Stop", NULL, NULL, run_func, NULL, NULL); +} + +/* return TRUE to stop other actions from running */ +static gboolean run_func(ObActionsData *data, gpointer options) +{ + return TRUE; +} -- 2.34.1