From 1f2e399ade77070a2d0b82856ad9a3eef96b8676 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 24 May 2018 22:30:44 +1000 Subject: Implement floating --- sway/commands/sticky.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sway/commands/sticky.c (limited to 'sway/commands/sticky.c') diff --git a/sway/commands/sticky.c b/sway/commands/sticky.c new file mode 100644 index 00000000..4bb4bd39 --- /dev/null +++ b/sway/commands/sticky.c @@ -0,0 +1,40 @@ +#include +#include +#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_sticky(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "sticky", EXPECTED_EQUAL_TO, 1))) { + return error; + } + struct sway_container *container = + config->handler_context.current_container; + if (!container->is_floating) { + return cmd_results_new(CMD_FAILURE, "sticky", + "Can't set sticky on a tiled container"); + } + + bool wants_sticky; + if (strcasecmp(argv[0], "enable") == 0) { + wants_sticky = true; + } else if (strcasecmp(argv[0], "disable") == 0) { + wants_sticky = false; + } else if (strcasecmp(argv[0], "toggle") == 0) { + wants_sticky = !container->is_sticky; + } else { + return cmd_results_new(CMD_FAILURE, "sticky", + "Expected 'sticky '"); + } + + container->is_sticky = wants_sticky; + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} -- cgit v1.2.3 From aaba7642b3e4e9a63aea49412b10221f399b17af Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 25 May 2018 09:26:23 +1000 Subject: Replace is_floating boolean with function --- sway/commands/sticky.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sway/commands/sticky.c') diff --git a/sway/commands/sticky.c b/sway/commands/sticky.c index 4bb4bd39..732ccb98 100644 --- a/sway/commands/sticky.c +++ b/sway/commands/sticky.c @@ -17,7 +17,7 @@ struct cmd_results *cmd_sticky(int argc, char **argv) { } struct sway_container *container = config->handler_context.current_container; - if (!container->is_floating) { + if (!container_is_floating(container)) { return cmd_results_new(CMD_FAILURE, "sticky", "Can't set sticky on a tiled container"); } -- cgit v1.2.3