aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/floating.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/floating.c')
-rw-r--r--sway/commands/floating.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/sway/commands/floating.c b/sway/commands/floating.c
index 6ab56c3b..31de5ec3 100644
--- a/sway/commands/floating.c
+++ b/sway/commands/floating.c
@@ -17,9 +17,24 @@ struct cmd_results *cmd_floating(int argc, char **argv) {
}
struct sway_container *container =
config->handler_context.current_container;
- if (container->type != C_VIEW) {
- // TODO: This doesn't strictly speaking have to be true
- return cmd_results_new(CMD_INVALID, "float", "Only views can float");
+ if (container->type == C_WORKSPACE && container->children->length == 0) {
+ return cmd_results_new(CMD_INVALID, "floating",
+ "Can't float an empty workspace");
+ }
+ if (container->type == C_WORKSPACE) {
+ // Wrap the workspace's children in a container so we can float it
+ struct sway_container *workspace = container;
+ container = container_wrap_children(container);
+ workspace->layout = L_HORIZ;
+ seat_set_focus(config->handler_context.seat, container);
+ }
+
+ // 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) {
+ container = container->parent;
+ }
}
bool wants_floating;