aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/scratchpad.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-07-23 20:27:56 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-07-23 20:31:11 -0400
commitf4b882475eee7a81c206c7825616cc4656b2f60b (patch)
tree38e6ebf81b235424f105dcbcbb194e5e9eac70c0 /sway/commands/scratchpad.c
parentImplement pid->workspace tracking (diff)
parentMerge pull request #2342 from RyanDwyer/update-cursor (diff)
downloadsway-f4b882475eee7a81c206c7825616cc4656b2f60b.tar.gz
sway-f4b882475eee7a81c206c7825616cc4656b2f60b.tar.zst
sway-f4b882475eee7a81c206c7825616cc4656b2f60b.zip
Merge branch 'master' into pid-workspaces
Diffstat (limited to 'sway/commands/scratchpad.c')
-rw-r--r--sway/commands/scratchpad.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c
new file mode 100644
index 00000000..ccc07c87
--- /dev/null
+++ b/sway/commands/scratchpad.c
@@ -0,0 +1,36 @@
1#include "log.h"
2#include "sway/commands.h"
3#include "sway/config.h"
4#include "sway/scratchpad.h"
5#include "sway/tree/container.h"
6
7struct cmd_results *cmd_scratchpad(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "scratchpad", EXPECTED_EQUAL_TO, 1))) {
10 return error;
11 }
12 if (strcmp(argv[0], "show") != 0) {
13 return cmd_results_new(CMD_INVALID, "scratchpad",
14 "Expected 'scratchpad show'");
15 }
16 if (!root_container.sway_root->scratchpad->length) {
17 return cmd_results_new(CMD_INVALID, "scratchpad",
18 "Scratchpad is empty");
19 }
20
21 if (config->handler_context.using_criteria) {
22 // If using criteria, this command is executed for every container which
23 // matches the criteria. If this container isn't in the scratchpad,
24 // we'll just silently return a success.
25 struct sway_container *con = config->handler_context.current_container;
26 wlr_log(WLR_INFO, "cmd_scratchpad(%s)", con->name);
27 if (!con->scratchpad) {
28 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
29 }
30 scratchpad_toggle_container(con);
31 } else {
32 scratchpad_toggle_auto();
33 }
34
35 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
36}