From: Dana Jansens Date: Sat, 23 Jun 2007 14:56:22 +0000 (+0000) Subject: add the layer action X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=7f50e04925e539dbe28997a6b07369d9f5cb43e3;p=chaz%2Fopenbox add the layer action --- diff --git a/Makefile.am b/Makefile.am index 9a9f9d3f..ab4d8867 100644 --- a/Makefile.am +++ b/Makefile.am @@ -173,6 +173,7 @@ openbox_openbox_SOURCES = \ 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 \ diff --git a/openbox/action.c b/openbox/action.c index 3bf54330..9dd4965f 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -381,17 +381,6 @@ void action_toggle_layer(union ActionData *data) 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) -{ -} diff --git a/openbox/actions/all.c b/openbox/actions/all.c index ea81882b..8219325d 100644 --- a/openbox/actions/all.c +++ b/openbox/actions/all.c @@ -37,4 +37,5 @@ void action_all_startup() action_resizerelative_startup(); action_addremovedesktop_startup(); action_dockautohide_startup(); + action_layer_startup(); } diff --git a/openbox/actions/all.h b/openbox/actions/all.h index 6c7b60d9..7d4a68ad 100644 --- a/openbox/actions/all.h +++ b/openbox/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 diff --git a/openbox/actions/decorations.c b/openbox/actions/decorations.c index 8a816ae4..a8f0929c 100644 --- a/openbox/actions/decorations.c +++ b/openbox/actions/decorations.c @@ -27,7 +27,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) 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; 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; +} diff --git a/openbox/actions/maximize.c b/openbox/actions/maximize.c index cc2d44e2..443ff7e7 100644 --- a/openbox/actions/maximize.c +++ b/openbox/actions/maximize.c @@ -27,7 +27,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) 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; diff --git a/openbox/actions/maximizehorizontal.c b/openbox/actions/maximizehorizontal.c index aaaaa51a..abb8a8e1 100644 --- a/openbox/actions/maximizehorizontal.c +++ b/openbox/actions/maximizehorizontal.c @@ -27,7 +27,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) 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; diff --git a/openbox/actions/maximizevertical.c b/openbox/actions/maximizevertical.c index 73e1b757..516463c7 100644 --- a/openbox/actions/maximizevertical.c +++ b/openbox/actions/maximizevertical.c @@ -27,7 +27,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) 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; diff --git a/openbox/actions/omnipresent.c b/openbox/actions/omnipresent.c index 02bd9917..92cdfb32 100644 --- a/openbox/actions/omnipresent.c +++ b/openbox/actions/omnipresent.c @@ -28,7 +28,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) 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; diff --git a/openbox/actions/shade.c b/openbox/actions/shade.c index f5c111b9..d28f91ed 100644 --- a/openbox/actions/shade.c +++ b/openbox/actions/shade.c @@ -27,7 +27,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) 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;