]> Dogcows Code - chaz/openbox/blob - openbox/actions/layer.c
add a missing #include
[chaz/openbox] / openbox / actions / layer.c
1 #include "openbox/actions.h"
2 #include "openbox/client.h"
3
4 typedef struct {
5 gint layer; /*!< -1 for below, 0 for normal, and 1 for above */
6 gboolean toggle;
7 } Options;
8
9 static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
10 static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc,
11 xmlNodePtr node);
12 static gpointer setup_func_send(ObParseInst *i, xmlDocPtr doc,
13 xmlNodePtr node);
14 static gboolean run_func(ObActionsData *data, gpointer options);
15
16 void action_layer_startup(void)
17 {
18 actions_register("ToggleAlwaysOnTop", setup_func_top, g_free,
19 run_func, NULL, NULL);
20 actions_register("ToggleAlwaysOnBottom", setup_func_bottom, g_free,
21 run_func, NULL, NULL);
22 actions_register("SendToLayer", setup_func_send, g_free,
23 run_func, NULL, NULL);
24 }
25
26 static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
27 {
28 Options *o = g_new0(Options, 1);
29 o->layer = 1;
30 o->toggle = TRUE;
31 return o;
32 }
33
34 static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc,
35 xmlNodePtr node)
36 {
37 Options *o = g_new0(Options, 1);
38 o->layer = -1;
39 o->toggle = TRUE;
40 return o;
41 }
42
43 static gpointer setup_func_send(ObParseInst *i, xmlDocPtr doc,
44 xmlNodePtr node)
45 {
46 xmlNodePtr n;
47 Options *o;
48
49 o = g_new0(Options, 1);
50
51 if ((n = parse_find_node("layer", node))) {
52 gchar *s = parse_string(doc, n);
53 if (!g_ascii_strcasecmp(s, "above") ||
54 !g_ascii_strcasecmp(s, "top"))
55 o->layer = 1;
56 else if (!g_ascii_strcasecmp(s, "below") ||
57 !g_ascii_strcasecmp(s, "bottom"))
58 o->layer = -1;
59 else if (!g_ascii_strcasecmp(s, "normal") ||
60 !g_ascii_strcasecmp(s, "middle"))
61 o->layer = 0;
62 g_free(s);
63 }
64
65 return o;
66 }
67
68 /* Always return FALSE because its not interactive */
69 static gboolean run_func(ObActionsData *data, gpointer options)
70 {
71 Options *o = options;
72
73 if (data->client) {
74 ObClient *c = data->client;
75
76 actions_client_move(data, TRUE);
77
78 if (o->layer < 0) {
79 if (o->toggle || !c->below)
80 client_set_layer(c, c->below ? 0 : -1);
81 }
82 else if (o->layer > 0) {
83 if (o->toggle || !c->above)
84 client_set_layer(c, c->above ? 0 : 1);
85 }
86 else if (c->above || c->below)
87 client_set_layer(c, 0);
88
89 actions_client_move(data, FALSE);
90 }
91
92 return FALSE;
93 }
This page took 0.040177 seconds and 4 git commands to generate.