]> Dogcows Code - chaz/openbox/commitdiff
split layer action back into togglealwaysontop, togglealwaysonbottom, and sendtolayer...
authorDana Jansens <danakj@orodu.net>
Fri, 13 Jul 2007 16:19:17 +0000 (12:19 -0400)
committerDana Jansens <danakj@orodu.net>
Fri, 13 Jul 2007 16:19:17 +0000 (12:19 -0400)
openbox/actions/layer.c

index 6f83983d4b89f8a62f464123929112efced0cd7a..4a1cf651901d6023d3e3c745e9409b1f8cbea804 100644 (file)
@@ -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);
     }
This page took 0.023595 seconds and 4 git commands to generate.