From: Dana Jansens Date: Fri, 13 Jul 2007 16:19:17 +0000 (-0400) Subject: split layer action back into togglealwaysontop, togglealwaysonbottom, and sendtolayer... X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=23c8f0bc5b862ebf5f98e2f26ecf3c15042092d5;p=chaz%2Fopenbox split layer action back into togglealwaysontop, togglealwaysonbottom, and sendtolayer (which takes as an argument) --- diff --git a/openbox/actions/layer.c b/openbox/actions/layer.c index 6f83983d..4a1cf651 100644 --- a/openbox/actions/layer.c +++ b/openbox/actions/layer.c @@ -4,23 +4,42 @@ 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 gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); +static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc, + xmlNodePtr node); +static gpointer setup_func_send(ObParseInst *i, xmlDocPtr doc, + xmlNodePtr node); static gboolean run_func(ObActionsData *data, gpointer options); void action_layer_startup() { - actions_register("Layer", - setup_func, - free_func, - run_func, - NULL, NULL); + actions_register("ToggleAlwaysOnTop", setup_func_top, g_free, + run_func_toggle, NULL, NULL); + actions_register("ToggleAlwaysOnBottom", setup_func_bottom, g_free, + run_func_toggle, NULL, NULL); + actions_register("SendToLayer", setup_func_send, g_free, + run_func_send, NULL, NULL); } -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +{ + Options *o = g_new0(Options, 1); + o->layer = 1; + return o; +} + +static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc, + xmlNodePtr node) +{ + Options *o = g_new0(Options, 1); + o->layer = -1; + return o; +} + +static gpointer setup_func_send(ObParseInst *i, xmlDocPtr doc, + xmlNodePtr node) { xmlNodePtr n; Options *o; @@ -41,25 +60,10 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) 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) { @@ -71,17 +75,15 @@ static gboolean run_func(ObActionsData *data, gpointer options) actions_client_move(data, TRUE); if (o->layer < 0) { - if (o->toggle || c->below != o->on) + if (o->toggle || !c->below) client_set_layer(c, c->below ? 0 : -1); } else if (o->layer > 0) { - if (o->toggle || c->above != o->on) + if (o->toggle || !c->above) client_set_layer(c, c->above ? 0 : 1); } - else { - if ((o->toggle || o->on) && (c->above || c->below)) - client_set_layer(c, 0); - } + else if (c->above || c->below) + client_set_layer(c, 0); actions_client_move(data, FALSE); }