diff options
author | wil <william.barsse@gmail.com> | 2017-01-08 14:49:47 +0100 |
---|---|---|
committer | wil <william.barsse@gmail.com> | 2017-01-08 14:49:47 +0100 |
commit | 063c79874a0d55ffa69f48947381607978e128d7 (patch) | |
tree | 716f7f1330fe77cc706af85e7a5c9d4dfe6dcd16 | |
parent | [fix] Keep Clang happy (diff) | |
download | sway-063c79874a0d55ffa69f48947381607978e128d7.tar.gz sway-063c79874a0d55ffa69f48947381607978e128d7.tar.zst sway-063c79874a0d55ffa69f48947381607978e128d7.zip |
Indent cleanups
-rw-r--r-- | sway/commands/layout.c | 24 | ||||
-rw-r--r-- | sway/container.c | 7 | ||||
-rw-r--r-- | sway/layout.c | 36 |
3 files changed, 34 insertions, 33 deletions
diff --git a/sway/commands/layout.c b/sway/commands/layout.c index 0cdac1b4..c13a2ef7 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c | |||
@@ -49,8 +49,8 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
49 | } else if (strcasecmp(argv[0], "splitv") == 0) { | 49 | } else if (strcasecmp(argv[0], "splitv") == 0) { |
50 | swayc_change_layout(parent, L_VERT); | 50 | swayc_change_layout(parent, L_VERT); |
51 | } else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) { | 51 | } else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) { |
52 | if (parent->layout == L_HORIZ && (parent->workspace_layout == L_NONE || | 52 | if (parent->layout == L_HORIZ && (parent->workspace_layout == L_NONE |
53 | parent->workspace_layout == L_HORIZ)) { | 53 | || parent->workspace_layout == L_HORIZ)) { |
54 | swayc_change_layout(parent, L_VERT); | 54 | swayc_change_layout(parent, L_VERT); |
55 | } else { | 55 | } else { |
56 | swayc_change_layout(parent, L_HORIZ); | 56 | swayc_change_layout(parent, L_HORIZ); |
@@ -66,23 +66,23 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
66 | } else if (strcasecmp(argv[0], "incnmaster") == 0) { | 66 | } else if (strcasecmp(argv[0], "incnmaster") == 0) { |
67 | const char *name = "layout incnmaster"; | 67 | const char *name = "layout incnmaster"; |
68 | if ((error = checkarg(argc, name, | 68 | if ((error = checkarg(argc, name, |
69 | EXPECTED_EQUAL_TO, 2))) { | 69 | EXPECTED_EQUAL_TO, 2))) { |
70 | return error; | 70 | return error; |
71 | } | 71 | } |
72 | char *end; | 72 | char *end; |
73 | int inc = (int) strtol(argv[1], &end, 10); | 73 | int inc = (int) strtol(argv[1], &end, 10); |
74 | if (*end) { | 74 | if (*end) { |
75 | return cmd_results_new(CMD_INVALID, name, "Invalid %s command " | 75 | return cmd_results_new(CMD_INVALID, name, "Invalid %s command " |
76 | "(argument must be an integer)", name); | 76 | "(argument must be an integer)", name); |
77 | 77 | ||
78 | } | 78 | } |
79 | swayc_t *container = get_focused_view(swayc_active_workspace()); | 79 | swayc_t *container = get_focused_view(swayc_active_workspace()); |
80 | if (container && inc && | 80 | if (container && inc && |
81 | is_auto_layout(container->parent->layout) && | 81 | is_auto_layout(container->parent->layout) && |
82 | ((int)container->parent->nb_master + inc >= 0)) { | 82 | ((int)container->parent->nb_master + inc >= 0)) { |
83 | for (int i = container->parent->nb_master; | 83 | for (int i = container->parent->nb_master; |
84 | i >= 0 && i < container->parent->children->length && | 84 | i >= 0 && i < container->parent->children->length |
85 | i != (int) container->parent->nb_master + inc;) { | 85 | && i != (int) container->parent->nb_master + inc;) { |
86 | ((swayc_t *) container->parent->children->items[i])->height = -1; | 86 | ((swayc_t *) container->parent->children->items[i])->height = -1; |
87 | ((swayc_t *) container->parent->children->items[i])->width = -1; | 87 | ((swayc_t *) container->parent->children->items[i])->width = -1; |
88 | i += inc > 0 ? 1 : -1; | 88 | i += inc > 0 ? 1 : -1; |
@@ -92,19 +92,19 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
92 | } else if ((strcasecmp(argv[0], "incncol") == 0) && argc ==2) { | 92 | } else if ((strcasecmp(argv[0], "incncol") == 0) && argc ==2) { |
93 | const char *name = "layout incncol"; | 93 | const char *name = "layout incncol"; |
94 | if ((error = checkarg(argc, name, | 94 | if ((error = checkarg(argc, name, |
95 | EXPECTED_EQUAL_TO, 2))) { | 95 | EXPECTED_EQUAL_TO, 2))) { |
96 | return error; | 96 | return error; |
97 | } | 97 | } |
98 | char *end; | 98 | char *end; |
99 | int inc = (int) strtol(argv[1], &end, 10); | 99 | int inc = (int) strtol(argv[1], &end, 10); |
100 | if (*end) { | 100 | if (*end) { |
101 | return cmd_results_new(CMD_INVALID, name, "Invalid %s command " | 101 | return cmd_results_new(CMD_INVALID, name, "Invalid %s command " |
102 | "(argument must be an integer)", name); | 102 | "(argument must be an integer)", name); |
103 | 103 | ||
104 | } | 104 | } |
105 | swayc_t *container = get_focused_view(swayc_active_workspace()); | 105 | swayc_t *container = get_focused_view(swayc_active_workspace()); |
106 | if (container && inc && is_auto_layout(container->parent->layout) && | 106 | if (container && inc && is_auto_layout(container->parent->layout) && |
107 | ((int)container->parent->nb_slave_groups + inc >= 1)) { | 107 | ((int)container->parent->nb_slave_groups + inc >= 1)) { |
108 | container->parent->nb_slave_groups += inc; | 108 | container->parent->nb_slave_groups += inc; |
109 | } | 109 | } |
110 | } else if (strcasecmp(argv[0], "auto") == 0) { | 110 | } else if (strcasecmp(argv[0], "auto") == 0) { |
@@ -128,7 +128,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
128 | } | 128 | } |
129 | } else { | 129 | } else { |
130 | return cmd_results_new(CMD_FAILURE, "layout auto", | 130 | return cmd_results_new(CMD_FAILURE, "layout auto", |
131 | "Must be one of <prev|next>."); | 131 | "Must be one of <prev|next>."); |
132 | } | 132 | } |
133 | swayc_change_layout(parent, layout); | 133 | swayc_change_layout(parent, layout); |
134 | } | 134 | } |
diff --git a/sway/container.c b/sway/container.c index 3bdc8b6c..cf7d7dda 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -965,10 +965,11 @@ swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout) { | |||
965 | // if layout change modifies the auto layout's major axis, swap width and height | 965 | // if layout change modifies the auto layout's major axis, swap width and height |
966 | // to preserve current ratios. | 966 | // to preserve current ratios. |
967 | if (is_auto_layout(layout) && is_auto_layout(container->layout)) { | 967 | if (is_auto_layout(layout) && is_auto_layout(container->layout)) { |
968 | enum swayc_layouts prev_major = (container->layout == L_AUTO_LEFT || | 968 | enum swayc_layouts prev_major = |
969 | container->layout == L_AUTO_RIGHT) | 969 | container->layout == L_AUTO_LEFT || container->layout == L_AUTO_RIGHT |
970 | ? L_HORIZ : L_VERT; | 970 | ? L_HORIZ : L_VERT; |
971 | enum swayc_layouts new_major = (layout == L_AUTO_LEFT || layout == L_AUTO_RIGHT) | 971 | enum swayc_layouts new_major = |
972 | layout == L_AUTO_LEFT || layout == L_AUTO_RIGHT | ||
972 | ? L_HORIZ : L_VERT; | 973 | ? L_HORIZ : L_VERT; |
973 | if (new_major != prev_major) { | 974 | if (new_major != prev_major) { |
974 | for (int i = 0; i < container->children->length; ++i) { | 975 | for (int i = 0; i < container->children->length; ++i) { |
diff --git a/sway/layout.c b/sway/layout.c index 3e467169..869a3bcb 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -296,7 +296,7 @@ void move_container(swayc_t *container, enum movement_direction dir) { | |||
296 | sway_log(L_DEBUG, "container:%p, parent:%p, child %p,", | 296 | sway_log(L_DEBUG, "container:%p, parent:%p, child %p,", |
297 | container,parent,child); | 297 | container,parent,child); |
298 | if (parent->layout == layout | 298 | if (parent->layout == layout |
299 | || layout == L_NONE /* accept any layout for next/prev direction */ | 299 | || (layout == L_NONE && parent->type == C_CONTAINER) /* accept any layout for next/prev direction */ |
300 | || (parent->layout == L_TABBED && layout == L_HORIZ) | 300 | || (parent->layout == L_TABBED && layout == L_HORIZ) |
301 | || (parent->layout == L_STACKED && layout == L_VERT) | 301 | || (parent->layout == L_STACKED && layout == L_VERT) |
302 | || is_auto_layout(parent->layout)) { | 302 | || is_auto_layout(parent->layout)) { |
@@ -321,16 +321,16 @@ void move_container(swayc_t *container, enum movement_direction dir) { | |||
321 | } | 321 | } |
322 | // if move command makes container change from master to slave | 322 | // if move command makes container change from master to slave |
323 | // (or the contrary), reset its geometry an the one of the replaced item. | 323 | // (or the contrary), reset its geometry an the one of the replaced item. |
324 | if (parent->nb_master && | 324 | if (parent->nb_master |
325 | (size_t) parent->children->length > parent->nb_master) { | 325 | && (size_t) parent->children->length > parent->nb_master) { |
326 | swayc_t *swap_geom = NULL; | 326 | swayc_t *swap_geom = NULL; |
327 | // if child is being promoted/demoted, it will swap geometry | 327 | // if child is being promoted/demoted, it will swap geometry |
328 | // with the sibling being demoted/promoted. | 328 | // with the sibling being demoted/promoted. |
329 | if ((dir == MOVE_NEXT && desired == 0) | 329 | if ((dir == MOVE_NEXT && desired == 0) |
330 | || (dir == MOVE_PREV && (size_t) desired == parent->nb_master - 1)) { | 330 | || (dir == MOVE_PREV && (size_t) desired == parent->nb_master - 1)) { |
331 | swap_geom = parent->children->items[parent->nb_master - 1]; | 331 | swap_geom = parent->children->items[parent->nb_master - 1]; |
332 | } else if ((dir == MOVE_NEXT && (size_t) desired == parent->nb_master) | 332 | } else if ((dir == MOVE_NEXT && (size_t) desired == parent->nb_master) |
333 | || (dir == MOVE_PREV && desired == parent->children->length - 1)) { | 333 | || (dir == MOVE_PREV && desired == parent->children->length - 1)) { |
334 | swap_geom = parent->children->items[parent->nb_master]; | 334 | swap_geom = parent->children->items[parent->nb_master]; |
335 | } | 335 | } |
336 | if (swap_geom) { | 336 | if (swap_geom) { |
@@ -837,9 +837,9 @@ static void apply_tabbed_or_stacked_layout(swayc_t *container, double x, | |||
837 | double height); | 837 | double height); |
838 | 838 | ||
839 | static void apply_auto_layout(swayc_t *container, const double x, const double y, | 839 | static void apply_auto_layout(swayc_t *container, const double x, const double y, |
840 | const double width, const double height, | 840 | const double width, const double height, |
841 | enum swayc_layouts group_layout, | 841 | enum swayc_layouts group_layout, |
842 | bool master_first); | 842 | bool master_first); |
843 | 843 | ||
844 | static void arrange_windows_r(swayc_t *container, double width, double height) { | 844 | static void arrange_windows_r(swayc_t *container, double width, double height) { |
845 | int i; | 845 | int i; |
@@ -972,11 +972,11 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { | |||
972 | case L_HORIZ: | 972 | case L_HORIZ: |
973 | default: | 973 | default: |
974 | apply_horiz_layout(container, x, y, width, height, 0, | 974 | apply_horiz_layout(container, x, y, width, height, 0, |
975 | container->children->length); | 975 | container->children->length); |
976 | break; | 976 | break; |
977 | case L_VERT: | 977 | case L_VERT: |
978 | apply_vert_layout(container, x, y, width, height, 0, | 978 | apply_vert_layout(container, x, y, width, height, 0, |
979 | container->children->length); | 979 | container->children->length); |
980 | break; | 980 | break; |
981 | case L_TABBED: | 981 | case L_TABBED: |
982 | case L_STACKED: | 982 | case L_STACKED: |
@@ -1007,7 +1007,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { | |||
1007 | if (swayc_is_fullscreen(view)) { | 1007 | if (swayc_is_fullscreen(view)) { |
1008 | wlc_view_bring_to_front(view->handle); | 1008 | wlc_view_bring_to_front(view->handle); |
1009 | } else if (!container->focused || | 1009 | } else if (!container->focused || |
1010 | !swayc_is_fullscreen(container->focused)) { | 1010 | !swayc_is_fullscreen(container->focused)) { |
1011 | wlc_view_bring_to_front(view->handle); | 1011 | wlc_view_bring_to_front(view->handle); |
1012 | } | 1012 | } |
1013 | } | 1013 | } |
@@ -1068,8 +1068,8 @@ void apply_horiz_layout(swayc_t *container, const double x, const double y, | |||
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | void apply_vert_layout(swayc_t *container, const double x, const double y, | 1070 | void apply_vert_layout(swayc_t *container, const double x, const double y, |
1071 | const double width, const double height, const int start, | 1071 | const double width, const double height, const int start, |
1072 | const int end) { | 1072 | const int end) { |
1073 | int i; | 1073 | int i; |
1074 | double scale = 0; | 1074 | double scale = 0; |
1075 | // Calculate total height | 1075 | // Calculate total height |
@@ -1121,7 +1121,7 @@ void apply_vert_layout(swayc_t *container, const double x, const double y, | |||
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | void apply_tabbed_or_stacked_layout(swayc_t *container, double x, double y, | 1123 | void apply_tabbed_or_stacked_layout(swayc_t *container, double x, double y, |
1124 | double width, double height) { | 1124 | double width, double height) { |
1125 | int i; | 1125 | int i; |
1126 | swayc_t *focused = NULL; | 1126 | swayc_t *focused = NULL; |
1127 | for (i = 0; i < container->children->length; ++i) { | 1127 | for (i = 0; i < container->children->length; ++i) { |
@@ -1141,9 +1141,9 @@ void apply_tabbed_or_stacked_layout(swayc_t *container, double x, double y, | |||
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | void apply_auto_layout(swayc_t *container, const double x, const double y, | 1143 | void apply_auto_layout(swayc_t *container, const double x, const double y, |
1144 | const double width, const double height, | 1144 | const double width, const double height, |
1145 | enum swayc_layouts group_layout, | 1145 | enum swayc_layouts group_layout, |
1146 | bool master_first) { | 1146 | bool master_first) { |
1147 | // Auto layout "container" in width x height @ x, y | 1147 | // Auto layout "container" in width x height @ x, y |
1148 | // using "group_layout" for each of the groups in the container. | 1148 | // using "group_layout" for each of the groups in the container. |
1149 | // There is one "master" group, plus container->nb_slave_groups. | 1149 | // There is one "master" group, plus container->nb_slave_groups. |
@@ -1342,7 +1342,7 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio | |||
1342 | return NULL; | 1342 | return NULL; |
1343 | } else { | 1343 | } else { |
1344 | int desired = (focused_idx + (dir == MOVE_NEXT ? 1 : -1)) % | 1344 | int desired = (focused_idx + (dir == MOVE_NEXT ? 1 : -1)) % |
1345 | parent->children->length; | 1345 | parent->children->length; |
1346 | if (desired < 0) { | 1346 | if (desired < 0) { |
1347 | desired += parent->children->length; | 1347 | desired += parent->children->length; |
1348 | } | 1348 | } |