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/scratchpad.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/scratchpad.c')
-rw-r--r-- | sway/commands/scratchpad.c | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c deleted file mode 100644 index 6c5c92df..00000000 --- a/sway/commands/scratchpad.c +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | #include <string.h> | ||
2 | #include <strings.h> | ||
3 | #include <wlc/wlc.h> | ||
4 | #include "sway/commands.h" | ||
5 | #include "sway/container.h" | ||
6 | #include "sway/focus.h" | ||
7 | #include "sway/layout.h" | ||
8 | |||
9 | static swayc_t *fetch_view_from_scratchpad() { | ||
10 | sp_index = (sp_index + 1) % scratchpad->length; | ||
11 | swayc_t *view = scratchpad->items[sp_index]; | ||
12 | |||
13 | if (wlc_view_get_output(view->handle) != swayc_active_output()->handle) { | ||
14 | wlc_view_set_output(view->handle, swayc_active_output()->handle); | ||
15 | } | ||
16 | if (!view->is_floating) { | ||
17 | view->width = swayc_active_workspace()->width * 0.5; | ||
18 | view->height = swayc_active_workspace()->height * 0.75; | ||
19 | view->x = (swayc_active_workspace()->width - view->width)/2; | ||
20 | view->y = (swayc_active_workspace()->height - view->height)/2; | ||
21 | } | ||
22 | if (swayc_active_workspace()->width < view->x + 20 || view->x + view->width < 20) { | ||
23 | view->x = (swayc_active_workspace()->width - view->width)/2; | ||
24 | } | ||
25 | if (swayc_active_workspace()->height < view->y + 20 || view->y + view->height < 20) { | ||
26 | view->y = (swayc_active_workspace()->height - view->height)/2; | ||
27 | } | ||
28 | |||
29 | add_floating(swayc_active_workspace(), view); | ||
30 | wlc_view_set_mask(view->handle, VISIBLE); | ||
31 | view->visible = true; | ||
32 | arrange_windows(swayc_active_workspace(), -1, -1); | ||
33 | set_focused_container(view); | ||
34 | return view; | ||
35 | } | ||
36 | |||
37 | struct cmd_results *cmd_scratchpad(int argc, char **argv) { | ||
38 | struct cmd_results *error = NULL; | ||
39 | if (config->reading) return cmd_results_new(CMD_FAILURE, "scratchpad", "Can't be used in config file."); | ||
40 | if (!config->active) return cmd_results_new(CMD_FAILURE, "scratchpad", "Can only be used when sway is running."); | ||
41 | if ((error = checkarg(argc, "scratchpad", EXPECTED_EQUAL_TO, 1))) { | ||
42 | return error; | ||
43 | } | ||
44 | |||
45 | if (strcasecmp(argv[0], "show") == 0 && scratchpad->length > 0) { | ||
46 | if (!sp_view) { | ||
47 | if (current_container) { | ||
48 | // Haxor the scratchpad index if criteria'd | ||
49 | for (int i = 0; i < scratchpad->length; ++i) { | ||
50 | if (scratchpad->items[i] == current_container) { | ||
51 | sp_index = (i - 1) % scratchpad->length; | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | sp_view = fetch_view_from_scratchpad(); | ||
56 | } else { | ||
57 | if (swayc_active_workspace() != sp_view->parent) { | ||
58 | hide_view_in_scratchpad(sp_view); | ||
59 | if (sp_index == 0) { | ||
60 | sp_index = scratchpad->length; | ||
61 | } | ||
62 | sp_index--; | ||
63 | sp_view = fetch_view_from_scratchpad(); | ||
64 | } else { | ||
65 | hide_view_in_scratchpad(sp_view); | ||
66 | sp_view = NULL; | ||
67 | } | ||
68 | } | ||
69 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
70 | } | ||
71 | return cmd_results_new(CMD_FAILURE, "scratchpad", "Expected 'scratchpad show' when scratchpad is not empty."); | ||
72 | } | ||