|
|
|
@ -306,15 +306,26 @@ static struct cmd_results *cmd_floating(int argc, char **argv) {
|
|
|
|
|
if ((error = checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1))) {
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcasecmp(argv[0], "toggle") == 0) {
|
|
|
|
|
swayc_t *view = get_focused_container(&root_container);
|
|
|
|
|
bool wants_floating;
|
|
|
|
|
if (strcasecmp(argv[0], "enable") == 0) {
|
|
|
|
|
wants_floating = true;
|
|
|
|
|
} else if (strcasecmp(argv[0], "disable") == 0) {
|
|
|
|
|
wants_floating = false;
|
|
|
|
|
} else if (strcasecmp(argv[0], "toggle") == 0) {
|
|
|
|
|
wants_floating = !view->is_floating;
|
|
|
|
|
} else {
|
|
|
|
|
return cmd_results_new(CMD_FAILURE, "floating",
|
|
|
|
|
"Expected 'floating <enable|disable|toggle>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Prevent running floating commands on things like workspaces
|
|
|
|
|
if (view->type != C_VIEW) {
|
|
|
|
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Change from nonfloating to floating
|
|
|
|
|
if (!view->is_floating) {
|
|
|
|
|
if (!view->is_floating && wants_floating) {
|
|
|
|
|
// Remove view from its current location
|
|
|
|
|
destroy_container(remove_child(view));
|
|
|
|
|
|
|
|
|
@ -329,7 +340,8 @@ static struct cmd_results *cmd_floating(int argc, char **argv) {
|
|
|
|
|
view->height = view->desired_height;
|
|
|
|
|
}
|
|
|
|
|
arrange_windows(swayc_active_workspace(), -1, -1);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
} else if (view->is_floating && !wants_floating) {
|
|
|
|
|
// Delete the view from the floating list and unset its is_floating flag
|
|
|
|
|
// Using length-1 as the index is safe because the view must be the currently
|
|
|
|
|
// focused floating output
|
|
|
|
@ -359,7 +371,6 @@ static struct cmd_results *cmd_floating(int argc, char **argv) {
|
|
|
|
|
remove_view_from_scratchpad(view);
|
|
|
|
|
}
|
|
|
|
|
set_focused_container(view);
|
|
|
|
|
}
|
|
|
|
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|