]> icculus.org git repositories - mikachu/openbox.git/blob - openbox/actions/unfocus.c
add the desktop action
[mikachu/openbox.git] / openbox / actions / unfocus.c
1 #include "openbox/actions.h"
2 #include "openbox/focus.h"
3
4 typedef struct {
5     gboolean tobottom;
6 } Options;
7
8 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
9 static void     free_func(gpointer options);
10 static gboolean run_func(ObActionsData *data, gpointer options);
11
12 void action_unfocus_startup()
13 {
14     actions_register("Unfocus",
15                      setup_func,
16                      free_func,
17                      run_func,
18                      NULL, NULL);
19 }
20
21 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
22 {
23     xmlNodePtr n;
24     Options *o;
25
26     o = g_new0(Options, 1);
27     o->tobottom = TRUE;
28
29     if ((n = parse_find_node("tobottom", node)))
30         o->tobottom = parse_bool(doc, n);
31     return o;
32 }
33
34 static void free_func(gpointer options)
35 {
36     Options *o = options;
37
38     g_free(o);
39 }
40
41 /* Always return FALSE because its not interactive */
42 static gboolean run_func(ObActionsData *data, gpointer options)
43 {
44     Options *o = options;
45
46     if (data->client && data->client == focus_client) {
47         if (o->tobottom)
48             focus_order_to_bottom(data->client);
49         focus_fallback(FALSE, FALSE, TRUE);
50     }
51
52     return FALSE;
53 }