Merge pull request #2695 from RyanDwyer/remove-moveoutoftabsstacks

Remove move_out_of_tabs_stacks
master
Drew DeVault 6 years ago committed by GitHub
commit c2c257b884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -259,50 +259,24 @@ static void container_move_to_container(struct sway_container *container,
* In other words, rejigger it. */ * In other words, rejigger it. */
static void workspace_rejigger(struct sway_workspace *ws, static void workspace_rejigger(struct sway_workspace *ws,
struct sway_container *child, enum movement_direction move_dir) { struct sway_container *child, enum movement_direction move_dir) {
if (!child->parent && ws->tiling->length == 1) {
ws->layout =
move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT;
workspace_update_representation(ws);
return;
}
container_detach(child); container_detach(child);
workspace_wrap_children(ws); struct sway_container *new_parent = workspace_wrap_children(ws);
int index = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? 0 : 1; int index = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? 0 : 1;
workspace_insert_tiling(ws, child, index); workspace_insert_tiling(ws, child, index);
container_flatten(new_parent);
ws->layout = ws->layout =
move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT;
workspace_update_representation(ws); workspace_update_representation(ws);
child->width = child->height = 0; child->width = child->height = 0;
} }
static void move_out_of_tabs_stacks(struct sway_container *container,
struct sway_container *current, enum movement_direction move_dir,
int offs) {
enum sway_container_layout layout = move_dir ==
MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT;
list_t *siblings = container_get_siblings(container);
if (container == current && siblings->length == 1) {
wlr_log(WLR_DEBUG, "Changing layout of parent");
if (container->parent) {
container->parent->layout = layout;
container_update_representation(container);
} else {
container->workspace->layout = layout;
workspace_update_representation(container->workspace);
}
return;
}
wlr_log(WLR_DEBUG, "Moving out of tab/stack into a split");
if (current->parent) {
struct sway_container *new_parent =
container_split(current->parent, layout);
container_insert_child(new_parent, container, offs < 0 ? 0 : 1);
container_reap_empty(new_parent);
container_flatten(new_parent);
} else {
// Changing a workspace
struct sway_workspace *workspace = container->workspace;
workspace_split(workspace, layout);
workspace_insert_tiling(workspace, container, offs < 0 ? 0 : 1);
}
}
// Returns true if moved // Returns true if moved
static bool container_move_in_direction(struct sway_container *container, static bool container_move_in_direction(struct sway_container *container,
enum movement_direction move_dir) { enum movement_direction move_dir) {
@ -334,7 +308,6 @@ static bool container_move_in_direction(struct sway_container *container,
int offs = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? -1 : 1; int offs = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? -1 : 1;
while (current) { while (current) {
struct sway_container *parent = current->parent;
list_t *siblings = container_get_siblings(current); list_t *siblings = container_get_siblings(current);
enum sway_container_layout layout = container_parent_layout(current); enum sway_container_layout layout = container_parent_layout(current);
int index = list_find(siblings, current); int index = list_find(siblings, current);
@ -343,15 +316,8 @@ static bool container_move_in_direction(struct sway_container *container,
if (is_parallel(layout, move_dir)) { if (is_parallel(layout, move_dir)) {
if (desired == -1 || desired == siblings->length) { if (desired == -1 || desired == siblings->length) {
if (current->parent == container->parent) { if (current->parent == container->parent) {
if (!(parent && parent->is_fullscreen) &&
(layout == L_TABBED || layout == L_STACKED)) {
move_out_of_tabs_stacks(container, current,
move_dir, offs);
return true;
} else {
current = current->parent; current = current->parent;
continue; continue;
}
} else { } else {
// Special case // Special case
if (current->parent) { if (current->parent) {
@ -369,10 +335,6 @@ static bool container_move_in_direction(struct sway_container *container,
siblings->items[desired], move_dir); siblings->items[desired], move_dir);
return true; return true;
} }
} else if (!(parent && parent->is_fullscreen) &&
(layout == L_TABBED || layout == L_STACKED)) {
move_out_of_tabs_stacks(container, current, move_dir, offs);
return true;
} }
current = current->parent; current = current->parent;
@ -388,10 +350,8 @@ static bool container_move_in_direction(struct sway_container *container,
// Maybe rejigger the workspace // Maybe rejigger the workspace
struct sway_workspace *ws = container->workspace; struct sway_workspace *ws = container->workspace;
if (!is_parallel(ws->layout, move_dir)) { if (!is_parallel(ws->layout, move_dir)) {
if (ws->tiling->length >= 2) {
workspace_rejigger(ws, container, move_dir); workspace_rejigger(ws, container, move_dir);
return true; return true;
}
} else if (ws->layout == L_TABBED || ws->layout == L_STACKED) { } else if (ws->layout == L_TABBED || ws->layout == L_STACKED) {
workspace_rejigger(ws, container, move_dir); workspace_rejigger(ws, container, move_dir);
return true; return true;

Loading…
Cancel
Save