]> Dogcows Code - chaz/openbox/blob - openbox/actions/omnipresent.c
adding comments
[chaz/openbox] / openbox / actions / omnipresent.c
1 #include "openbox/actions.h"
2 #include "openbox/client.h"
3 #include "openbox/screen.h"
4
5 typedef struct {
6 gboolean toggle;
7 gboolean on;
8 } Options;
9
10 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
11 static void free_func(gpointer options);
12 static gboolean run_func(ObActionsData *data, gpointer options);
13
14 void action_omnipresent_startup()
15 {
16 actions_register("omnipresent",
17 setup_func,
18 free_func,
19 run_func,
20 NULL, NULL);
21 }
22
23 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
24 {
25 xmlNodePtr n;
26 Options *o;
27
28 o = g_new0(Options, 1);
29 o->toggle = TRUE;
30
31 if ((n = parse_find_node("state", node))) {
32 gchar *s = parse_string(doc, n);
33 if (g_ascii_strcasecmp(s, "toggle")) {
34 o->toggle = FALSE;
35 o->on = parse_bool(doc, n);
36 }
37 g_free(s);
38 }
39
40 return o;
41 }
42
43 static void free_func(gpointer options)
44 {
45 Options *o = options;
46
47 g_free(o);
48 }
49
50 /* Always return FALSE because its not interactive */
51 static gboolean run_func(ObActionsData *data, gpointer options)
52 {
53 Options *o = options;
54
55 if (data->client)
56 if (o->toggle || (o->on != (data->client->desktop == DESKTOP_ALL)))
57 client_set_desktop(data->client,
58 data->client->desktop == DESKTOP_ALL ?
59 screen_desktop : DESKTOP_ALL, FALSE, TRUE);
60
61 return FALSE;
62 }
This page took 0.039932 seconds and 4 git commands to generate.