aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/layout.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r--sway/tree/layout.c66
1 files changed, 17 insertions, 49 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 2b710403..a3de44ce 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -1,5 +1,4 @@
#define _POSIX_C_SOURCE 200809L
-#include <ctype.h>
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -76,7 +75,6 @@ void container_insert_child(struct sway_container *parent,
list_insert(parent->children, i, child);
child->parent = parent;
container_handle_fullscreen_reparent(child, old_parent);
- wl_signal_emit(&child->events.reparent, old_parent);
}
struct sway_container *container_add_sibling(struct sway_container *fixed,
@@ -92,7 +90,6 @@ struct sway_container *container_add_sibling(struct sway_container *fixed,
list_insert(parent->children, i + 1, active);
active->parent = parent;
container_handle_fullscreen_reparent(active, old_parent);
- wl_signal_emit(&active->events.reparent, old_parent);
return active->parent;
}
@@ -118,9 +115,11 @@ struct sway_container *container_remove_child(struct sway_container *child) {
}
struct sway_container *parent = child->parent;
- int index = index_child(child);
+ list_t *list = container_is_floating(child) ?
+ parent->sway_workspace->floating : parent->children;
+ int index = list_find(list, child);
if (index != -1) {
- list_del(parent->children, index);
+ list_del(list, index);
}
child->parent = NULL;
container_notify_subtree_changed(parent);
@@ -161,7 +160,8 @@ void container_move_to(struct sway_container *container,
struct sway_container *old_output =
container_parent(container, C_OUTPUT);
old_parent = container_remove_child(container);
- container_add_child(new_ws->sway_workspace->floating, container);
+ workspace_add_floating(new_ws, container);
+ container_handle_fullscreen_reparent(container, old_parent);
// If changing output, center it within the workspace
if (old_output != new_ws->parent && !container->is_fullscreen) {
container_floating_move_to_center(container);
@@ -179,8 +179,6 @@ void container_move_to(struct sway_container *container,
}
}
- wl_signal_emit(&container->events.reparent, old_parent);
-
if (container->type == C_VIEW) {
ipc_event_window(container, "move");
}
@@ -305,7 +303,6 @@ static void workspace_rejigger(struct sway_container *ws,
container_flatten(ws);
container_reap_empty_recursive(original_parent);
- wl_signal_emit(&child->events.reparent, original_parent);
container_create_notify(new_parent);
}
@@ -432,9 +429,6 @@ void container_move(struct sway_container *container,
if ((index == parent->children->length - 1 && offs > 0)
|| (index == 0 && offs < 0)) {
if (current->parent == container->parent) {
- if (parent->parent->layout == L_FLOATING) {
- return;
- }
if (!parent->is_fullscreen &&
(parent->layout == L_TABBED ||
parent->layout == L_STACKED)) {
@@ -458,14 +452,10 @@ void container_move(struct sway_container *container,
sibling = parent->children->items[index + offs];
wlr_log(WLR_DEBUG, "Selecting sibling id:%zd", sibling->id);
}
- } else if (!parent->is_fullscreen &&
- parent->parent->layout != L_FLOATING &&
- (parent->layout == L_TABBED ||
+ } else if (!parent->is_fullscreen && (parent->layout == L_TABBED ||
parent->layout == L_STACKED)) {
move_out_of_tabs_stacks(container, current, move_dir, offs);
return;
- } else if (parent->parent->layout == L_FLOATING) {
- return;
} else {
wlr_log(WLR_DEBUG, "Moving up to find a parallel container");
current = current->parent;
@@ -591,28 +581,6 @@ enum sway_container_layout container_get_default_layout(
}
}
-static int sort_workspace_cmp_qsort(const void *_a, const void *_b) {
- struct sway_container *a = *(void **)_a;
- struct sway_container *b = *(void **)_b;
- int retval = 0;
-
- if (isdigit(a->name[0]) && isdigit(b->name[0])) {
- int a_num = strtol(a->name, NULL, 10);
- int b_num = strtol(b->name, NULL, 10);
- retval = (a_num < b_num) ? -1 : (a_num > b_num);
- } else if (isdigit(a->name[0])) {
- retval = -1;
- } else if (isdigit(b->name[0])) {
- retval = 1;
- }
-
- return retval;
-}
-
-void container_sort_workspaces(struct sway_container *output) {
- list_stable_sort(output->children, sort_workspace_cmp_qsort);
-}
-
/**
* Get swayc in the direction of newly entered output.
*/
@@ -825,13 +793,15 @@ struct sway_container *container_replace_child(struct sway_container *child,
if (parent == NULL) {
return NULL;
}
- int i = index_child(child);
- // TODO floating
+ list_t *list = container_is_floating(child) ?
+ parent->sway_workspace->floating : parent->children;
+ int i = list_find(list, child);
+
if (new_child->parent) {
container_remove_child(new_child);
}
- parent->children->items[i] = new_child;
+ list->items[i] = new_child;
new_child->parent = parent;
child->parent = NULL;
@@ -884,7 +854,6 @@ struct sway_container *container_split(struct sway_container *child,
struct sway_container *ws_child = workspace->children->items[0];
container_remove_child(ws_child);
container_add_child(cont, ws_child);
- wl_signal_emit(&ws_child->events.reparent, workspace);
}
container_add_child(workspace, cont);
@@ -892,11 +861,9 @@ struct sway_container *container_split(struct sway_container *child,
workspace->layout = layout;
cont->layout = old_layout;
} else {
- struct sway_container *old_parent = child->parent;
cont->layout = layout;
container_replace_child(child, cont);
container_add_child(cont, child);
- wl_signal_emit(&child->events.reparent, old_parent);
}
if (set_focus) {
@@ -909,13 +876,13 @@ struct sway_container *container_split(struct sway_container *child,
}
void container_recursive_resize(struct sway_container *container,
- double amount, enum resize_edge edge) {
+ double amount, enum wlr_edges edge) {
bool layout_match = true;
wlr_log(WLR_DEBUG, "Resizing %p with amount: %f", container, amount);
- if (edge == RESIZE_EDGE_LEFT || edge == RESIZE_EDGE_RIGHT) {
+ if (edge == WLR_EDGE_LEFT || edge == WLR_EDGE_RIGHT) {
container->width += amount;
layout_match = container->layout == L_HORIZ;
- } else if (edge == RESIZE_EDGE_TOP || edge == RESIZE_EDGE_BOTTOM) {
+ } else if (edge == WLR_EDGE_TOP || edge == WLR_EDGE_BOTTOM) {
container->height += amount;
layout_match = container->layout == L_VERT;
}
@@ -996,7 +963,8 @@ void container_swap(struct sway_container *con1, struct sway_container *con2) {
"Cannot swap ancestor and descendant")) {
return;
}
- if (!sway_assert(con1->layout != L_FLOATING && con2->layout != L_FLOATING,
+ if (!sway_assert(!container_is_floating(con1)
+ && !container_is_floating(con2),
"Swapping with floating containers is not supported")) {
return;
}