summaryrefslogtreecommitdiffstats
path: root/sway/commands/floating.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/floating.c')
-rw-r--r--sway/commands/floating.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/sway/commands/floating.c b/sway/commands/floating.c
index 436376e3..d8729094 100644
--- a/sway/commands/floating.c
+++ b/sway/commands/floating.c
@@ -15,24 +15,23 @@ struct cmd_results *cmd_floating(int argc, char **argv) {
15 if ((error = checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1))) { 15 if ((error = checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1))) {
16 return error; 16 return error;
17 } 17 }
18 struct sway_container *container = 18 struct sway_container *container = config->handler_context.container;
19 config->handler_context.current_container; 19 struct sway_workspace *workspace = config->handler_context.workspace;
20 if (container->type == C_WORKSPACE && container->children->length == 0) { 20 if (!container && workspace->tiling->length == 0) {
21 return cmd_results_new(CMD_INVALID, "floating", 21 return cmd_results_new(CMD_INVALID, "floating",
22 "Can't float an empty workspace"); 22 "Can't float an empty workspace");
23 } 23 }
24 if (container->type == C_WORKSPACE) { 24 if (!container) {
25 // Wrap the workspace's children in a container so we can float it 25 // Wrap the workspace's children in a container so we can float it
26 struct sway_container *workspace = container; 26 container = workspace_wrap_children(workspace);
27 container = workspace_wrap_children(container);
28 workspace->layout = L_HORIZ; 27 workspace->layout = L_HORIZ;
29 seat_set_focus(config->handler_context.seat, container); 28 seat_set_focus(config->handler_context.seat, &container->node);
30 } 29 }
31 30
32 // If the container is in a floating split container, 31 // If the container is in a floating split container,
33 // operate on the split container instead of the child. 32 // operate on the split container instead of the child.
34 if (container_is_floating_or_child(container)) { 33 if (container_is_floating_or_child(container)) {
35 while (container->parent->type != C_WORKSPACE) { 34 while (container->parent) {
36 container = container->parent; 35 container = container->parent;
37 } 36 }
38 } 37 }
@@ -51,8 +50,7 @@ struct cmd_results *cmd_floating(int argc, char **argv) {
51 50
52 container_set_floating(container, wants_floating); 51 container_set_floating(container, wants_floating);
53 52
54 struct sway_container *workspace = container_parent(container, C_WORKSPACE); 53 arrange_workspace(container->workspace);
55 arrange_windows(workspace);
56 54
57 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 55 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
58} 56}