swayfx/sway/commands/floating.c
Ryan Dwyer bb66e6d578 Refactor everything that needs to arrange windows
* The arrange_foo functions are now replaced with arrange_and_commit, or
with manually created transactions and arrange_windows x2.
* The arrange functions are now only called from the highest level
functions rather than from both high level and low level functions.
* Due to the previous point, view_set_fullscreen_raw and
view_set_fullscreen are both merged into one function again.
* Floating and fullscreen are now working with transactions.
2018-06-09 10:11:25 +10:00

44 lines
1.3 KiB
C

#include <string.h>
#include <strings.h>
#include "sway/commands.h"
#include "sway/input/seat.h"
#include "sway/ipc-server.h"
#include "sway/output.h"
#include "sway/tree/arrange.h"
#include "sway/tree/container.h"
#include "sway/tree/layout.h"
#include "sway/tree/view.h"
#include "list.h"
struct cmd_results *cmd_floating(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1))) {
return error;
}
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");
}
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 = !container_is_floating(container);
} else {
return cmd_results_new(CMD_FAILURE, "floating",
"Expected 'floating <enable|disable|toggle>'");
}
container_set_floating(container, wants_floating);
struct sway_container *workspace = container_parent(container, C_WORKSPACE);
arrange_and_commit(workspace);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}