aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/floating.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-11-18 11:22:02 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-11-18 11:22:02 -0500
commit733993a651c71f7e2198d505960d6bbd31e0e107 (patch)
treee51732c5872b624e73355f9e5b3f762101f3cd0d /sway/commands/floating.c
parentInitial (awful) pass on xdg shell support (diff)
downloadsway-733993a651c71f7e2198d505960d6bbd31e0e107.tar.gz
sway-733993a651c71f7e2198d505960d6bbd31e0e107.tar.zst
sway-733993a651c71f7e2198d505960d6bbd31e0e107.zip
Move everything to sway/old/
Diffstat (limited to 'sway/commands/floating.c')
-rw-r--r--sway/commands/floating.c81
1 files changed, 0 insertions, 81 deletions
diff --git a/sway/commands/floating.c b/sway/commands/floating.c
deleted file mode 100644
index ccfde532..00000000
--- a/sway/commands/floating.c
+++ /dev/null
@@ -1,81 +0,0 @@
1#include <string.h>
2#include <strings.h>
3#include "sway/commands.h"
4#include "sway/container.h"
5#include "sway/ipc-server.h"
6#include "sway/layout.h"
7#include "list.h"
8#include "log.h"
9
10struct cmd_results *cmd_floating(int argc, char **argv) {
11 struct cmd_results *error = NULL;
12 if (config->reading) return cmd_results_new(CMD_FAILURE, "floating", "Can't be used in config file.");
13 if ((error = checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1))) {
14 return error;
15 }
16 swayc_t *view = current_container;
17 bool wants_floating;
18 if (strcasecmp(argv[0], "enable") == 0) {
19 wants_floating = true;
20 } else if (strcasecmp(argv[0], "disable") == 0) {
21 wants_floating = false;
22 } else if (strcasecmp(argv[0], "toggle") == 0) {
23 wants_floating = !view->is_floating;
24 } else {
25 return cmd_results_new(CMD_FAILURE, "floating",
26 "Expected 'floating <enable|disable|toggle>");
27 }
28
29 // Prevent running floating commands on things like workspaces
30 if (view->type != C_VIEW) {
31 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
32 }
33
34 // Change from nonfloating to floating
35 if (!view->is_floating && wants_floating) {
36 // Remove view from its current location
37 destroy_container(remove_child(view));
38
39 // and move it into workspace floating
40 add_floating(swayc_active_workspace(), view);
41 view->x = (swayc_active_workspace()->width - view->width)/2;
42 view->y = (swayc_active_workspace()->height - view->height)/2;
43 if (view->desired_width != -1) {
44 view->width = view->desired_width;
45 }
46 if (view->desired_height != -1) {
47 view->height = view->desired_height;
48 }
49 arrange_windows(swayc_active_workspace(), -1, -1);
50
51 } else if (view->is_floating && !wants_floating) {
52 // Delete the view from the floating list and unset its is_floating flag
53 remove_child(view);
54 view->is_floating = false;
55 // Get the properly focused container, and add in the view there
56 swayc_t *focused = container_under_pointer();
57 // If focused is null, it's because the currently focused container is a workspace
58 if (focused == NULL || focused->is_floating) {
59 focused = swayc_active_workspace();
60 }
61 set_focused_container(focused);
62
63 sway_log(L_DEBUG, "Non-floating focused container is %p", focused);
64
65 // Case of focused workspace, just create as child of it
66 if (focused->type == C_WORKSPACE) {
67 add_child(focused, view);
68 }
69 // Regular case, create as sibling of current container
70 else {
71 add_sibling(focused, view);
72 }
73 // Refocus on the view once its been put back into the layout
74 view->width = view->height = 0;
75 arrange_windows(swayc_active_workspace(), -1, -1);
76 remove_view_from_scratchpad(view);
77 ipc_event_window(view, "floating");
78 }
79 set_focused_container(view);
80 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
81}