mirror of
https://github.com/swaywm/sway.git
synced 2024-11-29 19:31:29 +00:00
changed "layout promote" command to "move first"
This is more consistent with other Sway semantics.
This commit is contained in:
parent
15745abf0c
commit
a62048f15d
|
@ -8,7 +8,8 @@ enum movement_direction {
|
|||
MOVE_PARENT,
|
||||
MOVE_CHILD,
|
||||
MOVE_NEXT,
|
||||
MOVE_PREV
|
||||
MOVE_PREV,
|
||||
MOVE_FIRST
|
||||
};
|
||||
|
||||
#include "container.h"
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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_.
|
||||
|
|
Loading…
Reference in a new issue