]> Dogcows Code - chaz/openbox/commitdiff
add the layer action
authorDana Jansens <danakj@orodu.net>
Sat, 23 Jun 2007 14:56:22 +0000 (14:56 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 23 Jun 2007 14:56:22 +0000 (14:56 +0000)
Makefile.am
openbox/action.c
openbox/actions/all.c
openbox/actions/all.h
openbox/actions/decorations.c
openbox/actions/layer.c [new file with mode: 0644]
openbox/actions/maximize.c
openbox/actions/maximizehorizontal.c
openbox/actions/maximizevertical.c
openbox/actions/omnipresent.c
openbox/actions/shade.c

index 9a9f9d3f0c19de400c73b495f852da801253002f..ab4d8867b679633f892a098e10d61f01c2dddde2 100644 (file)
@@ -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 \
index 3bf5433088f63f04fd24351677d93941e238ffd3..9dd4965fee130a731235639a172ee0c6979dcd0a 100644 (file)
@@ -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)
-{
-}
index ea81882b89d3c0311fd5b74f3001ad30272bcf9c..8219325d981ede2194c62d6a2ea52ba2f12ef03b 100644 (file)
@@ -37,4 +37,5 @@ void action_all_startup()
     action_resizerelative_startup();
     action_addremovedesktop_startup();
     action_dockautohide_startup();
+    action_layer_startup();
 }
index 6c7b60d94eeec12b0ff0819bb99bad8860d07dbb..7d4a68adb8b718b7e7ffcf25867f0c0dcd9a5885 100644 (file)
@@ -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
index 8a816ae46d871f7277f0bc9b5d5430947d2961e7..a8f0929cf7e39c46e504ab7d6c6c4528d7e755fe 100644 (file)
@@ -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 (file)
index 0000000..6f83983
--- /dev/null
@@ -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;
+}
index cc2d44e253311ddf742b3eb0bb9552e561036137..443ff7e76bbd3d85432046390481d52ad425c30e 100644 (file)
@@ -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;
index aaaaa51a05ef2ed896e289af7e85fc98fd8714ac..abb8a8e1e665b2deee40f30f7bcbae1256dcefcc 100644 (file)
@@ -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;
index 73e1b757f5e505ef755802e833d01bc49dab8100..516463c768c193eb62bce7bfbcad77d73aacde1e 100644 (file)
@@ -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;
index 02bd99179d0e3f8b8abf17c80dbfd6dbef42a946..92cdfb32004f73556d355964c70198310729380c 100644 (file)
@@ -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;
index f5c111b9866009b4d89d1a94ecb2a2699740946a..d28f91ed8863363c4e0e7c1e3d131625969a760d 100644 (file)
@@ -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;
This page took 0.035229 seconds and 4 git commands to generate.