all repos — openbox @ 7f50e04925e539dbe28997a6b07369d9f5cb43e3

openbox fork - make it a bit more like ryudo

add the layer action
Dana Jansens danakj@orodu.net
commit

7f50e04925e539dbe28997a6b07369d9f5cb43e3

parent

ca28e08c2f47dec4e30f54c3ef64376a6246fbf9

M Makefile.amMakefile.am

@@ -173,6 +173,7 @@ openbox/actions/focus.c \

openbox/actions/fullscreen.c \ openbox/actions/iconify.c \ openbox/actions/kill.c \ + openbox/actions/layer.c \ openbox/actions/lower.c \ openbox/actions/maximize.c \ openbox/actions/maximizehorizontal.c \
M openbox/action.copenbox/action.c

@@ -381,17 +381,6 @@ {

ObClient *c = data->layer.any.c; client_action_start(data); - if (data->layer.layer < 0) - client_set_layer(c, c->below ? 0 : -1); - else if (data->layer.layer > 0) - client_set_layer(c, c->above ? 0 : 1); client_action_end(data, config_focus_under_mouse); } -void action_toggle_dockautohide(union ActionData *data) -{ -} - -void action_remove_desktop(union ActionData *data) -{ -}
M openbox/actions/all.copenbox/actions/all.c

@@ -37,4 +37,5 @@ action_directionaldesktop_startup();

action_resizerelative_startup(); action_addremovedesktop_startup(); action_dockautohide_startup(); + action_layer_startup(); }
M openbox/actions/all.hopenbox/actions/all.h

@@ -38,5 +38,6 @@ void action_directionaldesktop_startup();

void action_resizerelative_startup(); void action_addremovedesktop_startup(); void action_dockautohide_startup(); +void action_layer_startup(); #endif
M openbox/actions/decorations.copenbox/actions/decorations.c

@@ -27,7 +27,7 @@

o = g_new0(Options, 1); o->toggle = TRUE; - if ((n = parse_find_node("decorations", node))) { + if ((n = parse_find_node("state", node))) { gchar *s = parse_string(doc, n); if (g_ascii_strcasecmp(s, "toggle")) { o->toggle = FALSE;
A 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; +}
M openbox/actions/maximize.copenbox/actions/maximize.c

@@ -27,7 +27,7 @@

o = g_new0(Options, 1); o->toggle = TRUE; - if ((n = parse_find_node("maximize", node))) { + if ((n = parse_find_node("state", node))) { gchar *s = parse_string(doc, n); if (g_ascii_strcasecmp(s, "toggle")) { o->toggle = FALSE;
M openbox/actions/maximizehorizontal.copenbox/actions/maximizehorizontal.c

@@ -27,7 +27,7 @@

o = g_new0(Options, 1); o->toggle = TRUE; - if ((n = parse_find_node("maximize", node))) { + if ((n = parse_find_node("state", node))) { gchar *s = parse_string(doc, n); if (g_ascii_strcasecmp(s, "toggle")) { o->toggle = FALSE;
M openbox/actions/maximizevertical.copenbox/actions/maximizevertical.c

@@ -27,7 +27,7 @@

o = g_new0(Options, 1); o->toggle = TRUE; - if ((n = parse_find_node("maximize", node))) { + if ((n = parse_find_node("state", node))) { gchar *s = parse_string(doc, n); if (g_ascii_strcasecmp(s, "toggle")) { o->toggle = FALSE;
M openbox/actions/omnipresent.copenbox/actions/omnipresent.c

@@ -28,7 +28,7 @@

o = g_new0(Options, 1); o->toggle = TRUE; - if ((n = parse_find_node("omnipresent", node))) { + if ((n = parse_find_node("state", node))) { gchar *s = parse_string(doc, n); if (g_ascii_strcasecmp(s, "toggle")) { o->toggle = FALSE;
M openbox/actions/shade.copenbox/actions/shade.c

@@ -27,7 +27,7 @@

o = g_new0(Options, 1); o->toggle = TRUE; - if ((n = parse_find_node("shade", node))) { + if ((n = parse_find_node("state", node))) { gchar *s = parse_string(doc, n); if (g_ascii_strcasecmp(s, "toggle")) { o->toggle = FALSE;