From d125f17d12e21fbb92c274ea327f915c72a0da22 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sat, 1 Mar 2008 18:23:52 +0100 Subject: [PATCH] Add an action AllClients that runs actions on all windows. Add tags as children to it, obviously intended for use with the If action. --- Makefile.am | 1 + openbox/actions/all.c | 1 + openbox/actions/all.h | 1 + openbox/actions/allclients.c | 54 ++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 openbox/actions/allclients.c diff --git a/Makefile.am b/Makefile.am index e14fd8fb..b5e132d4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -171,6 +171,7 @@ openbox_openbox_SOURCES = \ gettext.h \ openbox/actions/all.c \ openbox/actions/all.h \ + openbox/actions/allclients.c \ openbox/actions/addremovedesktop.c \ openbox/actions/breakchroot.c \ openbox/actions/close.c \ diff --git a/openbox/actions/all.c b/openbox/actions/all.c index 9b4284e3..908f5e24 100644 --- a/openbox/actions/all.c +++ b/openbox/actions/all.c @@ -41,4 +41,5 @@ void action_all_startup(void) action_focustobottom_startup(); action_sendkeyevent_startup(); action_lock_startup(); + action_allclients_startup(); } diff --git a/openbox/actions/all.h b/openbox/actions/all.h index f444aae1..9890ea56 100644 --- a/openbox/actions/all.h +++ b/openbox/actions/all.h @@ -42,5 +42,6 @@ void action_if_startup(void); void action_focustobottom_startup(void); void action_sendkeyevent_startup(void); void action_lock_startup(void); +void action_zenbu_startup(void); #endif diff --git a/openbox/actions/allclients.c b/openbox/actions/allclients.c new file mode 100644 index 00000000..d7af806d --- /dev/null +++ b/openbox/actions/allclients.c @@ -0,0 +1,54 @@ +#include "openbox/actions.h" +#include "openbox/event.h" +#include "openbox/client.h" + +static gpointer setup_func(xmlNodePtr node); +static void free_func(gpointer acts); +static gboolean run_func(ObActionsData *data, gpointer options); + +void action_allclients_startup(void) +{ + actions_register("AllClients", setup_func, free_func, run_func, NULL, NULL); +} + +static gpointer setup_func(xmlNodePtr node) +{ + xmlNodePtr n; + GSList *acts = NULL; + + n = obt_parse_find_node(node, "action"); + while (n) { + ObActionsAct *action = actions_parse(n); + if (action) acts = g_slist_prepend(acts, action); + n = obt_parse_find_node(n->next, "action"); + } + + return acts; +} + +static void free_func(gpointer acts) +{ + GSList *a = acts; + + while (a) { + actions_act_unref(a->data); + a = g_slist_delete_link(a, a); + } +} + +/* Always return FALSE because its not interactive */ +static gboolean run_func(ObActionsData *data, gpointer acts) +{ + GList *it; + GSList *a = 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); + } + + return FALSE; +} -- 2.34.1