diff options
author | wil <william.barsse@gmail.com> | 2017-01-01 19:53:53 +0100 |
---|---|---|
committer | wil <william.barsse@gmail.com> | 2017-01-01 19:53:53 +0100 |
commit | a62048f15d9381e3040bd45965233e59a041eab7 (patch) | |
tree | 52e898bed50efcefe3d526db696d16f8888bc2f0 /sway | |
parent | [fix] cycle auto layouts backwards (diff) | |
download | sway-a62048f15d9381e3040bd45965233e59a041eab7.tar.gz sway-a62048f15d9381e3040bd45965233e59a041eab7.tar.zst sway-a62048f15d9381e3040bd45965233e59a041eab7.zip |
changed "layout promote" command to "move first"
This is more consistent with other Sway semantics.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands/layout.c | 12 | ||||
-rw-r--r-- | sway/commands/move.c | 4 | ||||
-rw-r--r-- | sway/layout.c | 16 | ||||
-rw-r--r-- | sway/sway.5.txt | 12 |
4 files changed, 23 insertions, 21 deletions
diff --git a/sway/commands/layout.c b/sway/commands/layout.c index d908b95c..2da65765 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c | |||
@@ -117,18 +117,6 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
117 | "Must be one of <prev|next>."); | 117 | "Must be one of <prev|next>."); |
118 | } | 118 | } |
119 | swayc_change_layout(parent, layout); | 119 | swayc_change_layout(parent, layout); |
120 | } else if (strcasecmp(argv[0], "promote") == 0) { | ||
121 | // swap first child in auto layout with currently focused child | ||
122 | swayc_t *container = get_focused_view(swayc_active_workspace()); | ||
123 | swayc_t *parent = container->parent; | ||
124 | if (is_auto_layout(parent->layout)) { | ||
125 | int focused_idx = index_child(container); | ||
126 | swayc_t *first = parent->children->items[0]; | ||
127 | if (focused_idx > 0) { | ||
128 | list_swap(parent->children, 0, focused_idx); | ||
129 | swap_geometry(first, container); | ||
130 | } | ||
131 | } | ||
132 | } | 120 | } |
133 | } | 121 | } |
134 | 122 | ||
diff --git a/sway/commands/move.c b/sway/commands/move.c index 4f6bc76f..0b134494 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -13,7 +13,7 @@ struct cmd_results *cmd_move(int argc, char **argv) { | |||
13 | if ((error = checkarg(argc, "move", EXPECTED_AT_LEAST, 1))) { | 13 | if ((error = checkarg(argc, "move", EXPECTED_AT_LEAST, 1))) { |
14 | return error; | 14 | return error; |
15 | } | 15 | } |
16 | const char* expected_syntax = "Expected 'move <left|right|up|down|next|prev>' or " | 16 | const char* expected_syntax = "Expected 'move <left|right|up|down|next|prev|first>' or " |
17 | "'move <container|window> to workspace <name>' or " | 17 | "'move <container|window> to workspace <name>' or " |
18 | "'move <container|window|workspace> to output <name|direction>' or " | 18 | "'move <container|window|workspace> to output <name|direction>' or " |
19 | "'move position mouse'"; | 19 | "'move position mouse'"; |
@@ -31,6 +31,8 @@ struct cmd_results *cmd_move(int argc, char **argv) { | |||
31 | move_container(view, MOVE_NEXT); | 31 | move_container(view, MOVE_NEXT); |
32 | } else if (strcasecmp(argv[0], "prev") == 0) { | 32 | } else if (strcasecmp(argv[0], "prev") == 0) { |
33 | move_container(view, MOVE_PREV); | 33 | move_container(view, MOVE_PREV); |
34 | } else if (strcasecmp(argv[0], "first") == 0) { | ||
35 | move_container(view, MOVE_FIRST); | ||
34 | } else if (strcasecmp(argv[0], "container") == 0 || strcasecmp(argv[0], "window") == 0) { | 36 | } else if (strcasecmp(argv[0], "container") == 0 || strcasecmp(argv[0], "window") == 0) { |
35 | // "move container ... | 37 | // "move container ... |
36 | if ((error = checkarg(argc, "move container/window", EXPECTED_AT_LEAST, 4))) { | 38 | if ((error = checkarg(argc, "move container/window", EXPECTED_AT_LEAST, 4))) { |
diff --git a/sway/layout.c b/sway/layout.c index 2de6da45..6212ec75 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -252,6 +252,7 @@ void swap_geometry(swayc_t *a, swayc_t *b) { | |||
252 | 252 | ||
253 | void move_container(swayc_t *container, enum movement_direction dir) { | 253 | void move_container(swayc_t *container, enum movement_direction dir) { |
254 | enum swayc_layouts layout = L_NONE; | 254 | enum swayc_layouts layout = L_NONE; |
255 | swayc_t *parent = container->parent; | ||
255 | if (container->is_floating | 256 | if (container->is_floating |
256 | || (container->type != C_VIEW && container->type != C_CONTAINER)) { | 257 | || (container->type != C_VIEW && container->type != C_CONTAINER)) { |
257 | return; | 258 | return; |
@@ -260,10 +261,23 @@ void move_container(swayc_t *container, enum movement_direction dir) { | |||
260 | layout = L_VERT; | 261 | layout = L_VERT; |
261 | } else if (dir == MOVE_LEFT || dir == MOVE_RIGHT) { | 262 | } else if (dir == MOVE_LEFT || dir == MOVE_RIGHT) { |
262 | layout = L_HORIZ; | 263 | layout = L_HORIZ; |
264 | } else if (dir == MOVE_FIRST) { | ||
265 | // swap first child in auto layout with currently focused child | ||
266 | if (is_auto_layout(parent->layout)) { | ||
267 | int focused_idx = index_child(container); | ||
268 | swayc_t *first = parent->children->items[0]; | ||
269 | if (focused_idx > 0) { | ||
270 | list_swap(parent->children, 0, focused_idx); | ||
271 | swap_geometry(first, container); | ||
272 | } | ||
273 | arrange_windows(parent->parent, -1, -1); | ||
274 | ipc_event_window(container, "move"); | ||
275 | set_focused_container_for(parent->parent, container); | ||
276 | } | ||
277 | return; | ||
263 | } else if (! (dir == MOVE_NEXT || dir == MOVE_PREV)) { | 278 | } else if (! (dir == MOVE_NEXT || dir == MOVE_PREV)) { |
264 | return; | 279 | return; |
265 | } | 280 | } |
266 | swayc_t *parent = container->parent; | ||
267 | swayc_t *child = container; | 281 | swayc_t *child = container; |
268 | bool ascended = false; | 282 | bool ascended = false; |
269 | 283 | ||
diff --git a/sway/sway.5.txt b/sway/sway.5.txt index b58fbe55..eece4b5b 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt | |||
@@ -92,13 +92,11 @@ They are expected to be used with **bindsym** or at runtime through **swaymsg**( | |||
92 | focused container. <n> can be a positive or negative integer. These commands | 92 | focused container. <n> can be a positive or negative integer. These commands |
93 | only have an effect if the focused container uses one of the "auto" layouts. | 93 | only have an effect if the focused container uses one of the "auto" layouts. |
94 | 94 | ||
95 | **layout** promote:: | 95 | **move** <left|right|up|down|next|prev|first>:: |
96 | Swap the focused element with the first in the one of the auto layouts. | 96 | Moves the focused container _left_, _right_, _up_, or _down_. Moving to _prev_ |
97 | 97 | or _next_ swaps the container with its sibling in the same container. Move | |
98 | **move** <left|right|up|down|next|prev>:: | 98 | _first_ exchanges the focused element in an auto layout with the first |
99 | Moves the focused container _left_, _right_, _up_, or _down_. Moving | 99 | element, i.e. promotes the focused element to master position. |
100 | to _prev_ or _next_ swaps the container with its sibling in the same | ||
101 | container. | ||
102 | 100 | ||
103 | **move** <container|window> to workspace <name>:: | 101 | **move** <container|window> to workspace <name>:: |
104 | Moves the focused container to the workspace identified by _name_. | 102 | Moves the focused container to the workspace identified by _name_. |