diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/sway/commands.c b/sway/commands.c index cf3d5b3f..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 }, | 863 | { "bindsym", cmd_bindsym, CMD_ANYTIME }, |
864 | { "default_orientation", cmd_orientation }, | 864 | { "default_orientation", cmd_orientation, CMD_ANYTIME}, |
865 | { "exec", cmd_exec }, | 865 | { "exec", cmd_exec, CMD_COMPOSITOR_READY }, |
866 | { "exec_always", cmd_exec_always }, | 866 | { "exec_always", cmd_exec_always, CMD_COMPOSITOR_READY }, |
867 | { "exit", cmd_exit }, | 867 | { "exit", cmd_exit, CMD_KEYBIND }, |
868 | { "floating", cmd_floating }, | 868 | { "floating", cmd_floating, CMD_KEYBIND }, |
869 | { "floating_modifier", cmd_floating_mod }, | 869 | { "floating_modifier", cmd_floating_mod, CMD_ANYTIME }, |
870 | { "focus", cmd_focus }, | 870 | { "focus", cmd_focus, CMD_KEYBIND }, |
871 | { "focus_follows_mouse", cmd_focus_follows_mouse }, | 871 | { "focus_follows_mouse", cmd_focus_follows_mouse, CMD_ANYTIME }, |
872 | { "fullscreen", cmd_fullscreen }, | 872 | { "fullscreen", cmd_fullscreen, CMD_KEYBIND }, |
873 | { "gaps", cmd_gaps }, | 873 | { "gaps", cmd_gaps, CMD_ANYTIME }, |
874 | { "kill", cmd_kill }, | 874 | { "kill", cmd_kill, CMD_KEYBIND }, |
875 | { "layout", cmd_layout }, | 875 | { "layout", cmd_layout, CMD_KEYBIND }, |
876 | { "log_colors", cmd_log_colors }, | 876 | { "log_colors", cmd_log_colors, CMD_ANYTIME }, |
877 | { "move", cmd_move}, | 877 | { "move", cmd_move, CMD_KEYBIND }, |
878 | { "output", cmd_output}, | 878 | { "output", cmd_output, CMD_ANYTIME }, |
879 | { "reload", cmd_reload }, | 879 | { "reload", cmd_reload, CMD_KEYBIND }, |
880 | { "resize", cmd_resize }, | 880 | { "resize", cmd_resize, CMD_KEYBIND }, |
881 | { "scratchpad", cmd_scratchpad }, | 881 | { "scratchpad", cmd_scratchpad, CMD_KEYBIND }, |
882 | { "set", cmd_set }, | 882 | { "set", cmd_set, CMD_ANYTIME }, |
883 | { "split", cmd_split }, | 883 | { "split", cmd_split, CMD_KEYBIND }, |
884 | { "splith", cmd_splith }, | 884 | { "splith", cmd_splith, CMD_KEYBIND }, |
885 | { "splitv", cmd_splitv }, | 885 | { "splitv", cmd_splitv, CMD_KEYBIND }, |
886 | { "workspace", cmd_workspace }, | 886 | { "workspace", cmd_workspace, CMD_COMPOSITOR_READY }, |
887 | { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth } | 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) { |
@@ -945,9 +945,11 @@ static int handler_compare(const void *_a, const void *_b) { | |||
945 | return strcasecmp(a->command, b->command); | 945 | return strcasecmp(a->command, b->command); |
946 | } | 946 | } |
947 | 947 | ||
948 | static struct cmd_handler *find_handler(struct cmd_handler handlers[], int l, char *line) { | 948 | struct cmd_handler *find_handler(char *line) { |
949 | struct cmd_handler d = { .command=line }; | 949 | struct cmd_handler d = { .command=line }; |
950 | struct cmd_handler *res = bsearch(&d, handlers, l, sizeof(struct cmd_handler), handler_compare); | 950 | struct cmd_handler *res = bsearch(&d, handlers, |
951 | sizeof(handlers) / sizeof(struct cmd_handler), | ||
952 | sizeof(struct cmd_handler), handler_compare); | ||
951 | return res; | 953 | return res; |
952 | } | 954 | } |
953 | 955 | ||
@@ -964,7 +966,7 @@ bool handle_command(struct sway_config *config, char *exec) { | |||
964 | strncpy(cmd, exec, index); | 966 | strncpy(cmd, exec, index); |
965 | cmd[index] = '\0'; | 967 | cmd[index] = '\0'; |
966 | } | 968 | } |
967 | struct cmd_handler *handler = find_handler(handlers, sizeof(handlers) / sizeof(struct cmd_handler), cmd); | 969 | struct cmd_handler *handler = find_handler(cmd); |
968 | if (handler == NULL) { | 970 | if (handler == NULL) { |
969 | sway_log(L_ERROR, "Unknown command '%s'", cmd); | 971 | sway_log(L_ERROR, "Unknown command '%s'", cmd); |
970 | exec_success = false; // TODO: return error, probably | 972 | exec_success = false; // TODO: return error, probably |