aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/layout.c12
-rw-r--r--sway/commands/move.c4
-rw-r--r--sway/layout.c16
-rw-r--r--sway/sway.5.txt12
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) {
"Must be one of <prev|next>.");
}
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 <left|right|up|down|next|prev>' or "
+ const char* expected_syntax = "Expected 'move <left|right|up|down|next|prev|first>' or "
"'move <container|window> to workspace <name>' or "
"'move <container|window|workspace> to output <name|direction>' 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. <n> 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** <left|right|up|down|next|prev>::
- 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** <left|right|up|down|next|prev|first>::
+ 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** <container|window> to workspace <name>::
Moves the focused container to the workspace identified by _name_.