diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-11-18 11:22:02 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-11-18 11:22:02 -0500 |
commit | 733993a651c71f7e2198d505960d6bbd31e0e107 (patch) | |
tree | e51732c5872b624e73355f9e5b3f762101f3cd0d /sway/commands/split.c | |
parent | Initial (awful) pass on xdg shell support (diff) | |
download | sway-733993a651c71f7e2198d505960d6bbd31e0e107.tar.gz sway-733993a651c71f7e2198d505960d6bbd31e0e107.tar.zst sway-733993a651c71f7e2198d505960d6bbd31e0e107.zip |
Move everything to sway/old/
Diffstat (limited to 'sway/commands/split.c')
-rw-r--r-- | sway/commands/split.c | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/sway/commands/split.c b/sway/commands/split.c deleted file mode 100644 index e3045a4f..00000000 --- a/sway/commands/split.c +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | #include <string.h> | ||
2 | #include <strings.h> | ||
3 | #include <wlc/wlc-render.h> | ||
4 | #include "sway/border.h" | ||
5 | #include "sway/commands.h" | ||
6 | #include "sway/container.h" | ||
7 | #include "sway/focus.h" | ||
8 | #include "sway/layout.h" | ||
9 | #include "log.h" | ||
10 | |||
11 | static struct cmd_results *_do_split(int argc, char **argv, int layout) { | ||
12 | char *name = layout == L_VERT ? "splitv" : | ||
13 | layout == L_HORIZ ? "splith" : "split"; | ||
14 | struct cmd_results *error = NULL; | ||
15 | if (config->reading) return cmd_results_new(CMD_FAILURE, name, "Can't be used in config file."); | ||
16 | if (!config->active) return cmd_results_new(CMD_FAILURE, name, "Can only be used when sway is running."); | ||
17 | if ((error = checkarg(argc, name, EXPECTED_EQUAL_TO, 0))) { | ||
18 | return error; | ||
19 | } | ||
20 | swayc_t *focused = current_container; | ||
21 | |||
22 | // Case of floating window, don't split | ||
23 | if (focused->is_floating) { | ||
24 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
25 | } | ||
26 | /* Case that focus is on an workspace with 0/1 children.change its layout */ | ||
27 | if (focused->type == C_WORKSPACE && focused->children->length <= 1) { | ||
28 | sway_log(L_DEBUG, "changing workspace layout"); | ||
29 | swayc_change_layout(focused, layout); | ||
30 | } else if (focused->type != C_WORKSPACE && focused->parent->children->length == 1) { | ||
31 | /* Case of no siblings. change parent layout */ | ||
32 | sway_log(L_DEBUG, "changing container layout"); | ||
33 | swayc_change_layout(focused->parent, layout); | ||
34 | } else { | ||
35 | /* regular case where new split container is build around focused container | ||
36 | * or in case of workspace, container inherits its children */ | ||
37 | sway_log(L_DEBUG, "Adding new container around current focused container"); | ||
38 | sway_log(L_INFO, "FOCUSED SIZE: %.f %.f", focused->width, focused->height); | ||
39 | swayc_t *parent = new_container(focused, layout); | ||
40 | set_focused_container(focused); | ||
41 | arrange_windows(parent, -1, -1); | ||
42 | } | ||
43 | |||
44 | // update container every time | ||
45 | // if it is tabbed/stacked then the title must change | ||
46 | // if the indicator color is different then the border must change | ||
47 | update_container_border(focused); | ||
48 | swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT); | ||
49 | // schedule render to make changes take effect right away, | ||
50 | // otherwise we would have to wait for the view to render, | ||
51 | // which is unpredictable. | ||
52 | wlc_output_schedule_render(output->handle); | ||
53 | |||
54 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
55 | } | ||
56 | |||
57 | struct cmd_results *cmd_split(int argc, char **argv) { | ||
58 | struct cmd_results *error = NULL; | ||
59 | if (config->reading) return cmd_results_new(CMD_FAILURE, "split", "Can't be used in config file."); | ||
60 | if (!config->active) return cmd_results_new(CMD_FAILURE, "split", "Can only be used when sway is running."); | ||
61 | if ((error = checkarg(argc, "split", EXPECTED_EQUAL_TO, 1))) { | ||
62 | return error; | ||
63 | } | ||
64 | if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) { | ||
65 | _do_split(argc - 1, argv + 1, L_VERT); | ||
66 | } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) { | ||
67 | _do_split(argc - 1, argv + 1, L_HORIZ); | ||
68 | } else if (strcasecmp(argv[0], "t") == 0 || strcasecmp(argv[0], "toggle") == 0) { | ||
69 | swayc_t *focused = current_container; | ||
70 | if (focused->parent->layout == L_VERT) { | ||
71 | _do_split(argc - 1, argv + 1, L_HORIZ); | ||
72 | } else { | ||
73 | _do_split(argc - 1, argv + 1, L_VERT); | ||
74 | } | ||
75 | } else { | ||
76 | error = cmd_results_new(CMD_FAILURE, "split", | ||
77 | "Invalid split command (expected either horizontal or vertical)."); | ||
78 | return error; | ||
79 | } | ||
80 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
81 | } | ||
82 | |||
83 | struct cmd_results *cmd_splitv(int argc, char **argv) { | ||
84 | return _do_split(argc, argv, L_VERT); | ||
85 | } | ||
86 | |||
87 | struct cmd_results *cmd_splith(int argc, char **argv) { | ||
88 | return _do_split(argc, argv, L_HORIZ); | ||
89 | } | ||
90 | |||
91 | struct cmd_results *cmd_splitt(int argc, char **argv) { | ||
92 | swayc_t *focused = current_container; | ||
93 | if (focused->parent->layout == L_VERT) { | ||
94 | return _do_split(argc, argv, L_HORIZ); | ||
95 | } else { | ||
96 | return _do_split(argc, argv, L_VERT); | ||
97 | } | ||
98 | } | ||