diff options
| author | Dana Jansens <danakj@orodu.net> | 2007-06-23 14:56:22 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2007-06-23 14:56:22 +0000 |
| commit | 7f50e04925e539dbe28997a6b07369d9f5cb43e3 (patch) | |
| tree | 5a32099e4a3e99013071b0f33ade2a6b97b22b6b /openbox/actions/layer.c | |
| parent | ca28e08c2f47dec4e30f54c3ef64376a6246fbf9 (diff) | |
add the layer action
Diffstat (limited to 'openbox/actions/layer.c')
| -rw-r--r-- | openbox/actions/layer.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/openbox/actions/layer.c b/openbox/actions/layer.c new file mode 100644 index 00000000..6f83983d --- /dev/null +++ b/openbox/actions/layer.c @@ -0,0 +1,90 @@ +#include "openbox/actions.h" +#include "openbox/client.h" + +typedef struct { + gint layer; /*!< -1 for below, 0 for normal, and 1 for above */ + gboolean toggle; + gboolean on; +} Options; + +static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); +static void free_func(gpointer options); +static gboolean run_func(ObActionsData *data, gpointer options); + +void action_layer_startup() +{ + actions_register("Layer", + setup_func, + free_func, + run_func, + NULL, NULL); +} + +static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +{ + xmlNodePtr n; + Options *o; + + o = g_new0(Options, 1); + o->toggle = TRUE; + + if ((n = parse_find_node("layer", node))) { + gchar *s = parse_string(doc, n); + if (!g_ascii_strcasecmp(s, "above") || + !g_ascii_strcasecmp(s, "top")) + o->layer = 1; + else if (!g_ascii_strcasecmp(s, "below") || + !g_ascii_strcasecmp(s, "bottom")) + o->layer = -1; + else if (!g_ascii_strcasecmp(s, "normal") || + !g_ascii_strcasecmp(s, "middle")) + o->layer = 0; + g_free(s); + } + if ((n = parse_find_node("state", node))) { + gchar *s = parse_string(doc, n); + if (g_ascii_strcasecmp(s, "toggle")) { + o->toggle = FALSE; + o->on = parse_bool(doc, n); + } + g_free(s); + } + + return o; +} + +static void free_func(gpointer options) +{ + Options *o = options; + + g_free(o); +} + +/* Always return FALSE because its not interactive */ +static gboolean run_func(ObActionsData *data, gpointer options) +{ + Options *o = options; + + if (data->client) { + ObClient *c = data->client; + + actions_client_move(data, TRUE); + + if (o->layer < 0) { + if (o->toggle || c->below != o->on) + client_set_layer(c, c->below ? 0 : -1); + } + else if (o->layer > 0) { + if (o->toggle || c->above != o->on) + client_set_layer(c, c->above ? 0 : 1); + } + else { + if ((o->toggle || o->on) && (c->above || c->below)) + client_set_layer(c, 0); + } + + actions_client_move(data, FALSE); + } + + return FALSE; +} |
