diff options
-rw-r--r-- | include/commands.h | 6 | ||||
-rw-r--r-- | sway/commands.c | 50 | ||||
-rw-r--r-- | sway/config.c | 4 |
3 files changed, 32 insertions, 28 deletions
diff --git a/include/commands.h b/include/commands.h index 31bc0b0b..62f8166e 100644 --- a/include/commands.h +++ b/include/commands.h | |||
@@ -9,7 +9,11 @@ struct cmd_handler { | |||
9 | // if <0 command is deffered until compositor is ready. | 9 | // if <0 command is deffered until compositor is ready. |
10 | // if =0 command can be called anytime. | 10 | // if =0 command can be called anytime. |
11 | // if >0 command can only be called via keybind, ignored in config | 11 | // if >0 command can only be called via keybind, ignored in config |
12 | int config_type; | 12 | enum { |
13 | CMD_COMPOSITOR_READY, | ||
14 | CMD_KEYBIND, | ||
15 | CMD_ANYTIME | ||
16 | } config_type; | ||
13 | }; | 17 | }; |
14 | 18 | ||
15 | struct cmd_handler *find_handler(char *line); | 19 | struct cmd_handler *find_handler(char *line); |
diff --git a/sway/commands.c b/sway/commands.c index fe480f0c..0fc98538 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -860,31 +860,31 @@ static bool cmd_ws_auto_back_and_forth(struct sway_config *config, int argc, cha | |||
860 | 860 | ||
861 | /* Keep alphabetized */ | 861 | /* Keep alphabetized */ |
862 | static struct cmd_handler handlers[] = { | 862 | static struct cmd_handler handlers[] = { |
863 | { "bindsym", cmd_bindsym, 0 }, | 863 | { "bindsym", cmd_bindsym, CMD_ANYTIME }, |
864 | { "default_orientation", cmd_orientation, 0}, | 864 | { "default_orientation", cmd_orientation, CMD_ANYTIME}, |
865 | { "exec", cmd_exec, -1 }, | 865 | { "exec", cmd_exec, CMD_COMPOSITOR_READY }, |
866 | { "exec_always", cmd_exec_always, -1 }, | 866 | { "exec_always", cmd_exec_always, CMD_COMPOSITOR_READY }, |
867 | { "exit", cmd_exit, 1 }, | 867 | { "exit", cmd_exit, CMD_KEYBIND }, |
868 | { "floating", cmd_floating, 1 }, | 868 | { "floating", cmd_floating, CMD_KEYBIND }, |
869 | { "floating_modifier", cmd_floating_mod, 0 }, | 869 | { "floating_modifier", cmd_floating_mod, CMD_ANYTIME }, |
870 | { "focus", cmd_focus, 1 }, | 870 | { "focus", cmd_focus, CMD_KEYBIND }, |
871 | { "focus_follows_mouse", cmd_focus_follows_mouse, 0 }, | 871 | { "focus_follows_mouse", cmd_focus_follows_mouse, CMD_ANYTIME }, |
872 | { "fullscreen", cmd_fullscreen, 1 }, | 872 | { "fullscreen", cmd_fullscreen, CMD_KEYBIND }, |
873 | { "gaps", cmd_gaps, 0 }, | 873 | { "gaps", cmd_gaps, CMD_ANYTIME }, |
874 | { "kill", cmd_kill, 1 }, | 874 | { "kill", cmd_kill, CMD_KEYBIND }, |
875 | { "layout", cmd_layout, 1 }, | 875 | { "layout", cmd_layout, CMD_KEYBIND }, |
876 | { "log_colors", cmd_log_colors, 0 }, | 876 | { "log_colors", cmd_log_colors, CMD_ANYTIME }, |
877 | { "move", cmd_move, 1 }, | 877 | { "move", cmd_move, CMD_KEYBIND }, |
878 | { "output", cmd_output, 0 }, | 878 | { "output", cmd_output, CMD_ANYTIME }, |
879 | { "reload", cmd_reload, 1 }, | 879 | { "reload", cmd_reload, CMD_KEYBIND }, |
880 | { "resize", cmd_resize, 1 }, | 880 | { "resize", cmd_resize, CMD_KEYBIND }, |
881 | { "scratchpad", cmd_scratchpad, 1 }, | 881 | { "scratchpad", cmd_scratchpad, CMD_KEYBIND }, |
882 | { "set", cmd_set, 0 }, | 882 | { "set", cmd_set, CMD_ANYTIME }, |
883 | { "split", cmd_split, 1 }, | 883 | { "split", cmd_split, CMD_KEYBIND }, |
884 | { "splith", cmd_splith, 1 }, | 884 | { "splith", cmd_splith, CMD_KEYBIND }, |
885 | { "splitv", cmd_splitv, 1 }, | 885 | { "splitv", cmd_splitv, CMD_KEYBIND }, |
886 | { "workspace", cmd_workspace, -1 }, | 886 | { "workspace", cmd_workspace, CMD_COMPOSITOR_READY }, |
887 | { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth, 0 } | 887 | { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth, CMD_ANYTIME }, |
888 | }; | 888 | }; |
889 | 889 | ||
890 | static char **split_directive(char *line, int *argc) { | 890 | static char **split_directive(char *line, int *argc) { |
diff --git a/sway/config.c b/sway/config.c index cbaab11e..90f6529a 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -220,9 +220,9 @@ bool read_config(FILE *file, bool is_active) { | |||
220 | list_t *args = split_string(line, " "); | 220 | list_t *args = split_string(line, " "); |
221 | struct cmd_handler *handler; | 221 | struct cmd_handler *handler; |
222 | if ((handler = find_handler(args->items[0]))) { | 222 | if ((handler = find_handler(args->items[0]))) { |
223 | if (handler->config_type > 0) { | 223 | if (handler->config_type == CMD_KEYBIND) { |
224 | sway_log(L_ERROR, "Invalid command during config ``%s''", line); | 224 | sway_log(L_ERROR, "Invalid command during config ``%s''", line); |
225 | } else if (handler->config_type < 0 && !is_active) { | 225 | } else if (handler->config_type == CMD_COMPOSITOR_READY && !is_active) { |
226 | sway_log(L_DEBUG, "Deferring command ``%s''", line); | 226 | sway_log(L_DEBUG, "Deferring command ``%s''", line); |
227 | char *cmd = malloc(strlen(line) + 1); | 227 | char *cmd = malloc(strlen(line) + 1); |
228 | strcpy(cmd, line); | 228 | strcpy(cmd, line); |