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/workspace.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/workspace.c')
-rw-r--r-- | sway/commands/workspace.c | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c deleted file mode 100644 index a7839746..00000000 --- a/sway/commands/workspace.c +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | #define _XOPEN_SOURCE 500 | ||
2 | #include <string.h> | ||
3 | #include <strings.h> | ||
4 | #include "sway/commands.h" | ||
5 | #include "sway/config.h" | ||
6 | #include "sway/input_state.h" | ||
7 | #include "sway/workspace.h" | ||
8 | #include "list.h" | ||
9 | #include "log.h" | ||
10 | #include "stringop.h" | ||
11 | |||
12 | struct cmd_results *cmd_workspace(int argc, char **argv) { | ||
13 | struct cmd_results *error = NULL; | ||
14 | if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST, 1))) { | ||
15 | return error; | ||
16 | } | ||
17 | |||
18 | int output_location = -1; | ||
19 | |||
20 | for (int i = 0; i < argc; ++i) { | ||
21 | if (strcasecmp(argv[i], "output") == 0) { | ||
22 | output_location = i; | ||
23 | break; | ||
24 | } | ||
25 | } | ||
26 | if (output_location >= 0) { | ||
27 | if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, output_location + 2))) { | ||
28 | return error; | ||
29 | } | ||
30 | struct workspace_output *wso = calloc(1, sizeof(struct workspace_output)); | ||
31 | if (!wso) { | ||
32 | return cmd_results_new(CMD_FAILURE, "workspace output", | ||
33 | "Unable to allocate workspace output"); | ||
34 | } | ||
35 | wso->workspace = join_args(argv, argc - 2); | ||
36 | wso->output = strdup(argv[output_location + 1]); | ||
37 | int i = -1; | ||
38 | if ((i = list_seq_find(config->workspace_outputs, workspace_output_cmp_workspace, wso)) != -1) { | ||
39 | struct workspace_output *old = config->workspace_outputs->items[i]; | ||
40 | free(old); // workspaces can only be assigned to a single output | ||
41 | list_del(config->workspace_outputs, i); | ||
42 | } | ||
43 | sway_log(L_DEBUG, "Assigning workspace %s to output %s", wso->workspace, wso->output); | ||
44 | list_add(config->workspace_outputs, wso); | ||
45 | } else { | ||
46 | if (config->reading || !config->active) { | ||
47 | return cmd_results_new(CMD_DEFER, "workspace", NULL); | ||
48 | } | ||
49 | swayc_t *ws = NULL; | ||
50 | if (strcasecmp(argv[0], "number") == 0) { | ||
51 | if (!(ws = workspace_by_number(argv[1]))) { | ||
52 | char *name = join_args(argv + 1, argc - 1); | ||
53 | ws = workspace_create(name); | ||
54 | free(name); | ||
55 | } | ||
56 | } else if (strcasecmp(argv[0], "next") == 0) { | ||
57 | ws = workspace_next(); | ||
58 | } else if (strcasecmp(argv[0], "prev") == 0) { | ||
59 | ws = workspace_prev(); | ||
60 | } else if (strcasecmp(argv[0], "next_on_output") == 0) { | ||
61 | ws = workspace_output_next(); | ||
62 | } else if (strcasecmp(argv[0], "prev_on_output") == 0) { | ||
63 | ws = workspace_output_prev(); | ||
64 | } else if (strcasecmp(argv[0], "back_and_forth") == 0) { | ||
65 | // if auto_back_and_forth is enabled, workspace_switch will swap | ||
66 | // the workspaces. If we created prev_workspace here, workspace_switch | ||
67 | // would put us back on original workspace. | ||
68 | if (config->auto_back_and_forth) { | ||
69 | ws = swayc_active_workspace(); | ||
70 | } else if (prev_workspace_name && !(ws = workspace_by_name(prev_workspace_name))) { | ||
71 | ws = workspace_create(prev_workspace_name); | ||
72 | } | ||
73 | } else { | ||
74 | char *name = join_args(argv, argc); | ||
75 | if (!(ws = workspace_by_name(name))) { | ||
76 | ws = workspace_create(name); | ||
77 | } | ||
78 | free(name); | ||
79 | } | ||
80 | swayc_t *old_output = swayc_active_output(); | ||
81 | workspace_switch(ws); | ||
82 | swayc_t *new_output = swayc_active_output(); | ||
83 | |||
84 | if (config->mouse_warping && old_output != new_output) { | ||
85 | swayc_t *focused = get_focused_view(ws); | ||
86 | if (focused && focused->type == C_VIEW) { | ||
87 | center_pointer_on(focused); | ||
88 | } | ||
89 | } | ||
90 | } | ||
91 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
92 | } | ||