From a62048f15d9381e3040bd45965233e59a041eab7 Mon Sep 17 00:00:00 2001 From: wil Date: Sun, 1 Jan 2017 19:53:53 +0100 Subject: changed "layout promote" command to "move first" This is more consistent with other Sway semantics. --- include/sway/focus.h | 3 ++- sway/commands/layout.c | 12 ------------ sway/commands/move.c | 4 +++- sway/layout.c | 16 +++++++++++++++- sway/sway.5.txt | 12 +++++------- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/include/sway/focus.h b/include/sway/focus.h index 30c9e108..652cdccc 100644 --- a/include/sway/focus.h +++ b/include/sway/focus.h @@ -8,7 +8,8 @@ enum movement_direction { MOVE_PARENT, MOVE_CHILD, MOVE_NEXT, - MOVE_PREV + MOVE_PREV, + MOVE_FIRST }; #include "container.h" 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) { "Must be one of ."); } swayc_change_layout(parent, layout); - } else if (strcasecmp(argv[0], "promote") == 0) { - // swap first child in auto layout with currently focused child - swayc_t *container = get_focused_view(swayc_active_workspace()); - swayc_t *parent = container->parent; - if (is_auto_layout(parent->layout)) { - int focused_idx = index_child(container); - swayc_t *first = parent->children->items[0]; - if (focused_idx > 0) { - list_swap(parent->children, 0, focused_idx); - swap_geometry(first, container); - } - } } } 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) { if ((error = checkarg(argc, "move", EXPECTED_AT_LEAST, 1))) { return error; } - const char* expected_syntax = "Expected 'move ' or " + const char* expected_syntax = "Expected 'move ' or " "'move to workspace ' or " "'move to output ' or " "'move position mouse'"; @@ -31,6 +31,8 @@ struct cmd_results *cmd_move(int argc, char **argv) { move_container(view, MOVE_NEXT); } else if (strcasecmp(argv[0], "prev") == 0) { move_container(view, MOVE_PREV); + } else if (strcasecmp(argv[0], "first") == 0) { + move_container(view, MOVE_FIRST); } else if (strcasecmp(argv[0], "container") == 0 || strcasecmp(argv[0], "window") == 0) { // "move container ... 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) { void move_container(swayc_t *container, enum movement_direction dir) { enum swayc_layouts layout = L_NONE; + swayc_t *parent = container->parent; if (container->is_floating || (container->type != C_VIEW && container->type != C_CONTAINER)) { return; @@ -260,10 +261,23 @@ void move_container(swayc_t *container, enum movement_direction dir) { layout = L_VERT; } else if (dir == MOVE_LEFT || dir == MOVE_RIGHT) { layout = L_HORIZ; + } else if (dir == MOVE_FIRST) { + // swap first child in auto layout with currently focused child + if (is_auto_layout(parent->layout)) { + int focused_idx = index_child(container); + swayc_t *first = parent->children->items[0]; + if (focused_idx > 0) { + list_swap(parent->children, 0, focused_idx); + swap_geometry(first, container); + } + arrange_windows(parent->parent, -1, -1); + ipc_event_window(container, "move"); + set_focused_container_for(parent->parent, container); + } + return; } else if (! (dir == MOVE_NEXT || dir == MOVE_PREV)) { return; } - swayc_t *parent = container->parent; swayc_t *child = container; bool ascended = false; 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**( focused container. can be a positive or negative integer. These commands only have an effect if the focused container uses one of the "auto" layouts. -**layout** promote:: - Swap the focused element with the first in the one of the auto layouts. - -**move** :: - Moves the focused container _left_, _right_, _up_, or _down_. Moving - to _prev_ or _next_ swaps the container with its sibling in the same - container. +**move** :: + Moves the focused container _left_, _right_, _up_, or _down_. Moving to _prev_ + or _next_ swaps the container with its sibling in the same container. Move + _first_ exchanges the focused element in an auto layout with the first + element, i.e. promotes the focused element to master position. **move** to workspace :: Moves the focused container to the workspace identified by _name_. -- cgit v1.2.3-54-g00ecf