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_PARENT,
|
||||||
MOVE_CHILD,
|
MOVE_CHILD,
|
||||||
MOVE_NEXT,
|
MOVE_NEXT,
|
||||||
MOVE_PREV
|
MOVE_PREV,
|
||||||
|
MOVE_FIRST
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "container.h"
|
#include "container.h"
|
||||||
|
|
|
@ -117,18 +117,6 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
|
||||||
"Must be one of <prev|next>.");
|
"Must be one of <prev|next>.");
|
||||||
}
|
}
|
||||||
swayc_change_layout(parent, layout);
|
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))) {
|
if ((error = checkarg(argc, "move", EXPECTED_AT_LEAST, 1))) {
|
||||||
return error;
|
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> to workspace <name>' or "
|
||||||
"'move <container|window|workspace> to output <name|direction>' or "
|
"'move <container|window|workspace> to output <name|direction>' or "
|
||||||
"'move position mouse'";
|
"'move position mouse'";
|
||||||
|
@ -31,6 +31,8 @@ struct cmd_results *cmd_move(int argc, char **argv) {
|
||||||
move_container(view, MOVE_NEXT);
|
move_container(view, MOVE_NEXT);
|
||||||
} else if (strcasecmp(argv[0], "prev") == 0) {
|
} else if (strcasecmp(argv[0], "prev") == 0) {
|
||||||
move_container(view, MOVE_PREV);
|
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) {
|
} else if (strcasecmp(argv[0], "container") == 0 || strcasecmp(argv[0], "window") == 0) {
|
||||||
// "move container ...
|
// "move container ...
|
||||||
if ((error = checkarg(argc, "move container/window", EXPECTED_AT_LEAST, 4))) {
|
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) {
|
void move_container(swayc_t *container, enum movement_direction dir) {
|
||||||
enum swayc_layouts layout = L_NONE;
|
enum swayc_layouts layout = L_NONE;
|
||||||
|
swayc_t *parent = container->parent;
|
||||||
if (container->is_floating
|
if (container->is_floating
|
||||||
|| (container->type != C_VIEW && container->type != C_CONTAINER)) {
|
|| (container->type != C_VIEW && container->type != C_CONTAINER)) {
|
||||||
return;
|
return;
|
||||||
|
@ -260,10 +261,23 @@ void move_container(swayc_t *container, enum movement_direction dir) {
|
||||||
layout = L_VERT;
|
layout = L_VERT;
|
||||||
} else if (dir == MOVE_LEFT || dir == MOVE_RIGHT) {
|
} else if (dir == MOVE_LEFT || dir == MOVE_RIGHT) {
|
||||||
layout = L_HORIZ;
|
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)) {
|
} else if (! (dir == MOVE_NEXT || dir == MOVE_PREV)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
swayc_t *parent = container->parent;
|
|
||||||
swayc_t *child = container;
|
swayc_t *child = container;
|
||||||
bool ascended = false;
|
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
|
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.
|
only have an effect if the focused container uses one of the "auto" layouts.
|
||||||
|
|
||||||
**layout** promote::
|
**move** <left|right|up|down|next|prev|first>::
|
||||||
Swap the focused element with the first in the one of the auto layouts.
|
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
|
||||||
**move** <left|right|up|down|next|prev>::
|
_first_ exchanges the focused element in an auto layout with the first
|
||||||
Moves the focused container _left_, _right_, _up_, or _down_. Moving
|
element, i.e. promotes the focused element to master position.
|
||||||
to _prev_ or _next_ swaps the container with its sibling in the same
|
|
||||||
container.
|
|
||||||
|
|
||||||
**move** <container|window> to workspace <name>::
|
**move** <container|window> to workspace <name>::
|
||||||
Moves the focused container to the workspace identified by _name_.
|
Moves the focused container to the workspace identified by _name_.
|
||||||
|
|
Loading…
Reference in a new issue