]> git.sur5r.net Git - i3/i3/commitdiff
Introduce orientation_from_direction
authorOrestis Floros <orestisf1993@gmail.com>
Thu, 23 Aug 2018 12:36:23 +0000 (15:36 +0300)
committerOrestis Floros <orestisf1993@gmail.com>
Thu, 23 Aug 2018 12:36:23 +0000 (15:36 +0300)
include/util.h
src/move.c
src/resize.c
src/util.c

index d58e21b7d675fd6946988a8c85fae5904c45d956..90ddc4a4615b97943e1283710d73f651aa68c8c4 100644 (file)
@@ -174,3 +174,9 @@ bool parse_long(const char *str, long *out, int base);
  *
  */
 ssize_t slurp(const char *path, char **buf);
+
+/**
+ * Convert a direction to its corresponding orientation.
+ *
+ */
+orientation_t orientation_from_direction(direction_t direction);
index 5bff3dae5030bc844d915ac8a14d28c71b34876b..32178e6b2890837d46fdf9044bd5f1b2aab239e0 100644 (file)
@@ -265,7 +265,7 @@ void tree_move(Con *con, int direction) {
         return;
     }
 
-    orientation_t o = (direction == D_LEFT || direction == D_RIGHT ? HORIZ : VERT);
+    orientation_t o = orientation_from_direction(direction);
 
     Con *same_orientation = con_parent_with_orientation(con, o);
     /* The do {} while is used to 'restart' at this point with a different
index ee50bfbc694514abe8b43c51a5cffed65365fa69..184dc7c54c5026ea645056e665286e1114d94ab4 100644 (file)
@@ -57,7 +57,7 @@ bool resize_find_tiling_participants(Con **current, Con **other, direction_t dir
     }
 
     /* Go up in the tree and search for a container to resize */
-    const orientation_t search_orientation = ((direction == D_LEFT || direction == D_RIGHT) ? HORIZ : VERT);
+    const orientation_t search_orientation = orientation_from_direction(direction);
     const bool dir_backwards = (direction == D_UP || direction == D_LEFT);
     while (first->type != CT_WORKSPACE &&
            first->type != CT_FLOATING_CON &&
index dc3444f7b6aa950be8b4696896ac55b1cc4033fc..a59283a8dd044a788a645b3296b481bcce4c621d 100644 (file)
@@ -507,3 +507,11 @@ ssize_t slurp(const char *path, char **buf) {
     }
     return (ssize_t)n;
 }
+
+/*
+ * Convert a direction to its corresponding orientation.
+ *
+ */
+orientation_t orientation_from_direction(direction_t direction) {
+    return (direction == D_LEFT || direction == D_RIGHT) ? HORIZ : VERT;
+}