]> Dogcows Code - chaz/openbox/commitdiff
redo the maximize actions into maximize/unmaximize/togglemaximize with a <direction...
authorDana Jansens <danakj@orodu.net>
Fri, 13 Jul 2007 16:03:40 +0000 (12:03 -0400)
committerDana Jansens <danakj@orodu.net>
Fri, 13 Jul 2007 16:03:40 +0000 (12:03 -0400)
Makefile.am
openbox/actions/all.c
openbox/actions/all.h
openbox/actions/maximize.c
openbox/actions/maximizehorizontal.c [deleted file]
openbox/actions/maximizevertical.c [deleted file]

index 27114f80349e186222dadb39250a41c093ab69e0..61cb6bbb470bcdd5df2fac4e5e92d956eea859bd 100644 (file)
@@ -172,8 +172,6 @@ openbox_openbox_SOURCES = \
        openbox/actions/layer.c \
        openbox/actions/lower.c \
        openbox/actions/maximize.c \
-       openbox/actions/maximizehorizontal.c \
-       openbox/actions/maximizevertical.c \
        openbox/actions/menu.c \
        openbox/actions/move.c \
        openbox/actions/moverelative.c \
index 1bf963aceb9c0717a7eab7e32051b07a34794e4d..a80443bf0525a5941bcf6babb1570a992d2856e6 100644 (file)
@@ -21,8 +21,6 @@ void action_all_startup()
     action_iconify_startup();
     action_fullscreen_startup();
     action_maximize_startup();
-    action_maximizehorizontal_startup();
-    action_maximizevertical_startup();
     action_moveresizeto_startup();
     action_moverelative_startup();
     action_shade_startup();
index acb54dcd357951ba6cdd4ba2aafc7670e441f9e3..17b4fe3b7e9db6a9eafac81b827cfa11960897ae 100644 (file)
@@ -22,8 +22,6 @@ void action_unfocus_startup();
 void action_iconify_startup();
 void action_fullscreen_startup();
 void action_maximize_startup();
-void action_maximizehorizontal_startup();
-void action_maximizevertical_startup();
 void action_moveresizeto_startup();
 void action_moverelative_startup();
 void action_shade_startup();
index 443ff7e76bbd3d85432046390481d52ad425c30e..8bb0cc953e355b52a9595b659edd885b05cd04d9 100644 (file)
@@ -1,21 +1,29 @@
 #include "openbox/actions.h"
 #include "openbox/client.h"
 
+/* These match the values for client_maximize */
+typedef enum {
+    BOTH = 0,
+    HORZ = 1,
+    VERT = 2
+} MaxDirection;
+
 typedef struct {
-    gboolean toggle;
-    gboolean on;
+    MaxDirection dir;
 } 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);
+static gboolean run_func_on(ObActionsData *data, gpointer options);
+static gboolean run_func_off(ObActionsData *data, gpointer options);
+static gboolean run_func_toggle(ObActionsData *data, gpointer options);
 
 void action_maximize_startup()
 {
-    actions_register("Maximize",
-                     setup_func,
-                     free_func,
-                     run_func,
+    actions_register("Maximize", setup_func, g_free, run_func_on,
+                     NULL, NULL);
+    actions_register("Unmaximize", setup_func, g_free, run_func_off,
+                     NULL, NULL);
+    actions_register("ToggleMaximize", setup_func, g_free, run_func_toggle,
                      NULL, NULL);
 }
 
@@ -25,44 +33,59 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     Options *o;
 
     o = g_new0(Options, 1);
-    o->toggle = TRUE;
+    o->dir = BOTH;
 
-    if ((n = parse_find_node("state", node))) {
+    if ((n = parse_find_node("direction", node))) {
         gchar *s = parse_string(doc, n);
-        if (g_ascii_strcasecmp(s, "toggle")) {
-            o->toggle = FALSE;
-            o->on = parse_bool(doc, n);
-        }
+        if (!g_ascii_strcasecmp(s, "vertical") ||
+            !g_ascii_strcasecmp(s, "vert"))
+            o->dir = VERT;
+        else if (!g_ascii_strcasecmp(s, "horizontal") ||
+                 !g_ascii_strcasecmp(s, "horz"))
+            o->dir = HORZ;
         g_free(s);
     }
 
     return o;
 }
 
-static void free_func(gpointer options)
+/* Always return FALSE because its not interactive */
+static gboolean run_func_on(ObActionsData *data, gpointer options)
 {
     Options *o = options;
-
-    g_free(o);
+    if (data->client) {
+        actions_client_move(data, TRUE);
+        client_maximize(data->client, TRUE, o->dir);
+        actions_client_move(data, FALSE);
+    }
+    return FALSE;
 }
 
 /* Always return FALSE because its not interactive */
-static gboolean run_func(ObActionsData *data, gpointer options)
+static gboolean run_func_off(ObActionsData *data, gpointer options)
 {
     Options *o = options;
-
     if (data->client) {
         actions_client_move(data, TRUE);
-
-        if (o->toggle)
-            client_maximize(data->client,
-                            !data->client->max_horz || !data->client->max_vert,
-                            0);
-        else
-            client_maximize(data->client, o->on, 0);
-
+        client_maximize(data->client, FALSE, o->dir);
         actions_client_move(data, FALSE);
     }
+    return FALSE;
+}
 
+/* Always return FALSE because its not interactive */
+static gboolean run_func_toggle(ObActionsData *data, gpointer options)
+{
+    Options *o = options;
+    if (data->client) {
+        gboolean toggle;
+        actions_client_move(data, TRUE);
+        toggle = ((o->dir == HORZ && !data->client->max_horz) ||
+                  (o->dir == VERT && !data->client->max_vert) ||
+                  (o->dir == BOTH &&
+                   !(data->client->max_horz && data->client->max_vert)));
+        client_maximize(data->client, toggle, o->dir);
+        actions_client_move(data, FALSE);
+    }
     return FALSE;
 }
diff --git a/openbox/actions/maximizehorizontal.c b/openbox/actions/maximizehorizontal.c
deleted file mode 100644 (file)
index abb8a8e..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "openbox/actions.h"
-#include "openbox/client.h"
-
-typedef struct {
-    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_maximizehorizontal_startup()
-{
-    actions_register("MaximizeHorizontal",
-                     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("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) {
-        actions_client_move(data, TRUE);
-
-        if (o->toggle)
-            client_maximize(data->client, !data->client->max_horz, 1);
-        else
-            client_maximize(data->client, o->on, 1);
-
-        actions_client_move(data, FALSE);
-    }
-
-    return FALSE;
-}
diff --git a/openbox/actions/maximizevertical.c b/openbox/actions/maximizevertical.c
deleted file mode 100644 (file)
index 516463c..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "openbox/actions.h"
-#include "openbox/client.h"
-
-typedef struct {
-    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_maximizevertical_startup()
-{
-    actions_register("MaximizeVertical",
-                     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("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) {
-        actions_client_move(data, TRUE);
-
-        if (o->toggle)
-            client_maximize(data->client, !data->client->max_vert, 2);
-        else
-            client_maximize(data->client, o->on, 2);
-
-        actions_client_move(data, FALSE);
-    }
-
-    return FALSE;
-}
This page took 0.030659 seconds and 4 git commands to generate.