aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/floating.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-05-04 08:24:25 -0400
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-01 23:14:58 +1000
commitf3ab895916ca1a0f004b5ceaefa90eee90676532 (patch)
treeaa572c41265fae21617b13b62b1c8d5df1f2d47d /sway/commands/floating.c
parentMerge pull request #2081 from RedSoxFan/fix-2077 (diff)
downloadsway-f3ab895916ca1a0f004b5ceaefa90eee90676532.tar.gz
sway-f3ab895916ca1a0f004b5ceaefa90eee90676532.tar.zst
sway-f3ab895916ca1a0f004b5ceaefa90eee90676532.zip
Implement `floating enable`
Diffstat (limited to 'sway/commands/floating.c')
-rw-r--r--sway/commands/floating.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/sway/commands/floating.c b/sway/commands/floating.c
new file mode 100644
index 00000000..8432b0dc
--- /dev/null
+++ b/sway/commands/floating.c
@@ -0,0 +1,48 @@
1#include <string.h>
2#include <strings.h>
3#include "sway/commands.h"
4#include "sway/input/seat.h"
5#include "sway/ipc-server.h"
6#include "sway/tree/arrange.h"
7#include "sway/tree/container.h"
8#include "sway/tree/layout.h"
9#include "list.h"
10
11struct cmd_results *cmd_floating(int argc, char **argv) {
12 struct cmd_results *error = NULL;
13 if ((error = checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1))) {
14 return error;
15 }
16 struct sway_container *container =
17 config->handler_context.current_container;
18 if (container->type != C_VIEW) {
19 // TODO: This doesn't strictly speaking have to be true
20 return cmd_results_new(CMD_INVALID, "float", "Only views can float");
21 }
22
23 bool wants_floating;
24 if (strcasecmp(argv[0], "enable") == 0) {
25 wants_floating = true;
26 } else if (strcasecmp(argv[0], "disable") == 0) {
27 wants_floating = false;
28 } else if (strcasecmp(argv[0], "toggle") == 0) {
29 wants_floating = !container->is_floating;
30 } else {
31 return cmd_results_new(CMD_FAILURE, "floating",
32 "Expected 'floating <enable|disable|toggle>");
33 }
34
35 // Change from tiled to floating
36 if (!container->is_floating && wants_floating) {
37 struct sway_container *workspace = container_parent(
38 container, C_WORKSPACE);
39 container_remove_child(container);
40 container_add_floating(workspace, container);
41 seat_set_focus(config->handler_context.seat, container);
42 arrange_workspace(workspace);
43 } else if (container->is_floating && !wants_floating) {
44 // TODO
45 }
46
47 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
48}