aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-08-19 15:07:07 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-08-19 16:18:33 +1000
commit2b5a404ac920339a2b9ce32d4718272dee4668b9 (patch)
tree681f45a530a1f8d5966161291c3cb482e52edb6e /sway/commands
parent389d159c81502aa8b951895de11c3720bbd5ba7d (diff)
Replace hacky L_FLOATING container with a list
Workspaces previously had a magical `workspace->floating` container, which had a layout of L_FLOATING and whose children were actual floating views. This allowed some conveniences, but was a hacky solution because the container has to be exempt from focus, coordinate transactions with the workspace, and omit emitting IPC events (which we didn't do). This commit changes it to be a list directly in the sway_workspace. The L_FLOATING layout is no longer used so this has been removed as well. * Fixes incorrect check in the swap command (it checked if the containers had the L_FLOATING layout, but this layout applied to the magical container). * Introduces workspace_add_floating
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/floating.c2
-rw-r--r--sway/commands/focus.c2
-rw-r--r--sway/commands/move.c2
-rw-r--r--sway/commands/scratchpad.c9
-rw-r--r--sway/commands/swap.c2
5 files changed, 8 insertions, 9 deletions
diff --git a/sway/commands/floating.c b/sway/commands/floating.c
index c9467ef0..beafd9fb 100644
--- a/sway/commands/floating.c
+++ b/sway/commands/floating.c
@@ -33,7 +33,7 @@ struct cmd_results *cmd_floating(int argc, char **argv) {
// If the container is in a floating split container,
// operate on the split container instead of the child.
if (container_is_floating_or_child(container)) {
- while (container->parent->layout != L_FLOATING) {
+ while (container->parent->type != C_WORKSPACE) {
container = container->parent;
}
}
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index fe15b4c7..6659a683 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -39,7 +39,7 @@ static struct cmd_results *focus_mode(struct sway_container *con,
// If the container is in a floating split container,
// operate on the split container instead of the child.
if (container_is_floating_or_child(con)) {
- while (con->parent->layout != L_FLOATING) {
+ while (con->parent->type != C_WORKSPACE) {
con = con->parent;
}
}
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 33d1ee4a..e788d32f 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -449,7 +449,7 @@ static struct cmd_results *move_to_scratchpad(struct sway_container *con) {
// If the container is in a floating split container,
// operate on the split container instead of the child.
if (container_is_floating_or_child(con)) {
- while (con->parent->layout != L_FLOATING) {
+ while (con->parent->type != C_WORKSPACE) {
con = con->parent;
}
}
diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c
index 0e573aeb..7da20015 100644
--- a/sway/commands/scratchpad.c
+++ b/sway/commands/scratchpad.c
@@ -16,7 +16,7 @@ static void scratchpad_toggle_auto(void) {
// If the focus is in a floating split container,
// operate on the split container instead of the child.
if (container_is_floating_or_child(focus)) {
- while (focus->parent->layout != L_FLOATING) {
+ while (focus->parent->type != C_WORKSPACE) {
focus = focus->parent;
}
}
@@ -33,9 +33,8 @@ static void scratchpad_toggle_auto(void) {
// Check if there is an unfocused scratchpad window on the current workspace
// and focus it.
- for (int i = 0; i < ws->sway_workspace->floating->children->length; ++i) {
- struct sway_container *floater =
- ws->sway_workspace->floating->children->items[i];
+ for (int i = 0; i < ws->sway_workspace->floating->length; ++i) {
+ struct sway_container *floater = ws->sway_workspace->floating->items[i];
if (floater->scratchpad && focus != floater) {
wlr_log(WLR_DEBUG,
"Focusing other scratchpad window (%s) in this workspace",
@@ -103,7 +102,7 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) {
// If the container is in a floating split container,
// operate on the split container instead of the child.
if (container_is_floating_or_child(con)) {
- while (con->parent->layout != L_FLOATING) {
+ while (con->parent->type != C_WORKSPACE) {
con = con->parent;
}
}
diff --git a/sway/commands/swap.c b/sway/commands/swap.c
index 615e6b1d..f881a002 100644
--- a/sway/commands/swap.c
+++ b/sway/commands/swap.c
@@ -72,7 +72,7 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
|| container_has_ancestor(other, current)) {
error = cmd_results_new(CMD_FAILURE, "swap",
"Cannot swap ancestor and descendant");
- } else if (current->layout == L_FLOATING || other->layout == L_FLOATING) {
+ } else if (container_is_floating(current) || container_is_floating(other)) {
error = cmd_results_new(CMD_FAILURE, "swap",
"Swapping with floating containers is not supported");
}