1 #include "openbox/actions.h"
2 #include "openbox/client.h"
5 gint layer; /*!< -1 for below, 0 for normal, and 1 for above */
10 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
11 static gpointer setup_toggletop_func(ObParseInst *i,
12 xmlDocPtr doc, xmlNodePtr node);
13 static gpointer setup_togglebottom_func(ObParseInst *i,
14 xmlDocPtr doc, xmlNodePtr node);
15 static gpointer setup_sendtop_func(ObParseInst *i,
16 xmlDocPtr doc, xmlNodePtr node);
17 static gpointer setup_sendbottom_func(ObParseInst *i,
18 xmlDocPtr doc, xmlNodePtr node);
19 static gpointer setup_sendnormal_func(ObParseInst *i,
20 xmlDocPtr doc, xmlNodePtr node);
21 static void free_func(gpointer options);
22 static gboolean run_func(ObActionsData *data, gpointer options);
24 void action_layer_startup()
26 actions_register("Layer",
31 actions_register("ToggleAlwaysOnTop",
36 actions_register("ToggleAlwaysOnBottom",
37 setup_togglebottom_func,
41 actions_register("SendToTopLayer",
46 actions_register("SendToBottomLayer",
47 setup_sendbottom_func,
51 actions_register("SendToNormalLayer",
52 setup_sendnormal_func,
58 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
63 o = g_new0(Options, 1);
66 if ((n = parse_find_node("layer", node))) {
67 gchar *s = parse_string(doc, n);
68 if (!g_ascii_strcasecmp(s, "above") ||
69 !g_ascii_strcasecmp(s, "top"))
71 else if (!g_ascii_strcasecmp(s, "below") ||
72 !g_ascii_strcasecmp(s, "bottom"))
74 else if (!g_ascii_strcasecmp(s, "normal") ||
75 !g_ascii_strcasecmp(s, "middle"))
79 if ((n = parse_find_node("state", node))) {
80 gchar *s = parse_string(doc, n);
81 if (g_ascii_strcasecmp(s, "toggle")) {
83 o->on = parse_bool(doc, n);
91 static gpointer setup_toggletop_func(ObParseInst *i,
92 xmlDocPtr doc, xmlNodePtr node)
94 Options *o = g_new0(Options, 1);
100 static gpointer setup_togglebottom_func(ObParseInst *i,
101 xmlDocPtr doc, xmlNodePtr node)
103 Options *o = g_new0(Options, 1);
109 static gpointer setup_sendtop_func(ObParseInst *i,
110 xmlDocPtr doc, xmlNodePtr node)
112 Options *o = g_new0(Options, 1);
118 static gpointer setup_sendbottom_func(ObParseInst *i,
119 xmlDocPtr doc, xmlNodePtr node)
121 Options *o = g_new0(Options, 1);
127 static gpointer setup_sendnormal_func(ObParseInst *i,
128 xmlDocPtr doc, xmlNodePtr node)
130 Options *o = g_new0(Options, 1);
136 static void free_func(gpointer options)
138 Options *o = options;
143 /* Always return FALSE because its not interactive */
144 static gboolean run_func(ObActionsData *data, gpointer options)
146 Options *o = options;
149 ObClient *c = data->client;
151 actions_client_move(data, TRUE);
154 if (o->toggle || c->below != o->on)
155 client_set_layer(c, c->below ? 0 : -1);
157 else if (o->layer > 0) {
158 if (o->toggle || c->above != o->on)
159 client_set_layer(c, c->above ? 0 : 1);
162 if ((o->toggle || o->on) && (c->above || c->below))
163 client_set_layer(c, 0);
166 actions_client_move(data, FALSE);