aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/mode.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/mode.c')
-rw-r--r--sway/commands/mode.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/sway/commands/mode.c b/sway/commands/mode.c
index ef2c5d79..e5ddec4a 100644
--- a/sway/commands/mode.c
+++ b/sway/commands/mode.c
@@ -15,6 +15,9 @@ static struct cmd_handler mode_handlers[] = {
15 { "bindswitch", cmd_bindswitch }, 15 { "bindswitch", cmd_bindswitch },
16 { "bindsym", cmd_bindsym }, 16 { "bindsym", cmd_bindsym },
17 { "set", cmd_set }, 17 { "set", cmd_set },
18 { "unbindcode", cmd_unbindcode },
19 { "unbindswitch", cmd_unbindswitch },
20 { "unbindsym", cmd_unbindsym },
18}; 21};
19 22
20struct cmd_results *cmd_mode(int argc, char **argv) { 23struct cmd_results *cmd_mode(int argc, char **argv) {
@@ -23,10 +26,6 @@ struct cmd_results *cmd_mode(int argc, char **argv) {
23 return error; 26 return error;
24 } 27 }
25 28
26 if (argc > 1 && !config->reading) {
27 return cmd_results_new(CMD_FAILURE, "Can only be used in config file");
28 }
29
30 bool pango = strcmp(*argv, "--pango_markup") == 0; 29 bool pango = strcmp(*argv, "--pango_markup") == 0;
31 if (pango) { 30 if (pango) {
32 argc--; argv++; 31 argc--; argv++;
@@ -35,6 +34,10 @@ struct cmd_results *cmd_mode(int argc, char **argv) {
35 } 34 }
36 } 35 }
37 36
37 if (config->reading && argc == 1) {
38 return cmd_results_new(CMD_DEFER, NULL);
39 }
40
38 char *mode_name = *argv; 41 char *mode_name = *argv;
39 strip_quotes(mode_name); 42 strip_quotes(mode_name);
40 struct sway_mode *mode = NULL; 43 struct sway_mode *mode = NULL;
@@ -64,14 +67,12 @@ struct cmd_results *cmd_mode(int argc, char **argv) {
64 error = cmd_results_new(CMD_INVALID, "Unknown mode `%s'", mode_name); 67 error = cmd_results_new(CMD_INVALID, "Unknown mode `%s'", mode_name);
65 return error; 68 return error;
66 } 69 }
67 if ((config->reading && argc > 1) || (!config->reading && argc == 1)) {
68 sway_log(SWAY_DEBUG, "Switching to mode `%s' (pango=%d)",
69 mode->name, mode->pango);
70 }
71 // Set current mode 70 // Set current mode
72 config->current_mode = mode; 71 config->current_mode = mode;
73 if (argc == 1) { 72 if (argc == 1) {
74 // trigger IPC mode event 73 // trigger IPC mode event
74 sway_log(SWAY_DEBUG, "Switching to mode `%s' (pango=%d)",
75 mode->name, mode->pango);
75 ipc_event_mode(config->current_mode->name, 76 ipc_event_mode(config->current_mode->name,
76 config->current_mode->pango); 77 config->current_mode->pango);
77 return cmd_results_new(CMD_SUCCESS, NULL); 78 return cmd_results_new(CMD_SUCCESS, NULL);