]> icculus.org git repositories - mikachu/openbox.git/blob - openbox/actions/allclients.c
Merge branch 'work' into wip/mikabox
[mikachu/openbox.git] / openbox / actions / allclients.c
1 #include "openbox/actions.h"
2 #include "openbox/event.h"
3 #include "openbox/client.h"
4
5 static gpointer setup_func(xmlNodePtr node);
6 static void     free_func(gpointer acts);
7 static gboolean run_func(ObActionsData *data, gpointer options);
8
9 void action_allclients_startup(void)
10 {
11     actions_register("AllClients", setup_func, free_func, run_func, NULL, NULL);
12 }
13
14 static gpointer setup_func(xmlNodePtr node)
15 {
16     xmlNodePtr n;
17     GSList *acts = NULL;
18
19     n = obt_parse_find_node(node, "action");
20     while (n) {
21         ObActionsAct *action = actions_parse(n);
22         if (action) acts = g_slist_prepend(acts, action);
23         n = obt_parse_find_node(n->next, "action");
24     }
25
26     return acts;
27 }
28
29 static void free_func(gpointer acts)
30 {
31     GSList *a = acts;
32
33     while (a) {
34         actions_act_unref(a->data);
35         a = g_slist_delete_link(a, a);
36     }
37 }
38
39 /* Always return FALSE because its not interactive */
40 static gboolean run_func(ObActionsData *data, gpointer acts)
41 {
42     GList *it;
43     GSList *a = acts;
44
45     if (a)
46         for (it = client_list; it; it = g_list_next(it)) {
47             ObClient *c = it->data;
48             if (actions_run_acts(a, data->uact, data->state,
49                                  data->x, data->y, data->button,
50                                  data->context, c))
51                 return TRUE;
52         }
53
54     return FALSE;
55 }