diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2016-05-07 20:49:51 +0300 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2016-05-07 20:49:51 +0300 |
commit | 0423c41a0f9f8f84bde80e664e59e33e3b05e3d4 (patch) | |
tree | 0f168f873158653f9d42fb94c591b1d2e6450cd7 /sway/commands.c | |
parent | Merge pull request #638 from neosilky/memleak (diff) | |
download | sway-0423c41a0f9f8f84bde80e664e59e33e3b05e3d4.tar.gz sway-0423c41a0f9f8f84bde80e664e59e33e3b05e3d4.tar.zst sway-0423c41a0f9f8f84bde80e664e59e33e3b05e3d4.zip |
Implemented configurable floating scroll behavior
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sway/commands.c b/sway/commands.c index 9b0356c4..a4fcde78 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -58,6 +58,7 @@ static sway_cmd cmd_exec_always; | |||
58 | static sway_cmd cmd_exit; | 58 | static sway_cmd cmd_exit; |
59 | static sway_cmd cmd_floating; | 59 | static sway_cmd cmd_floating; |
60 | static sway_cmd cmd_floating_mod; | 60 | static sway_cmd cmd_floating_mod; |
61 | static sway_cmd cmd_floating_scroll; | ||
61 | static sway_cmd cmd_focus; | 62 | static sway_cmd cmd_focus; |
62 | static sway_cmd cmd_focus_follows_mouse; | 63 | static sway_cmd cmd_focus_follows_mouse; |
63 | static sway_cmd cmd_font; | 64 | static sway_cmd cmd_font; |
@@ -705,6 +706,47 @@ static struct cmd_results *cmd_floating_mod(int argc, char **argv) { | |||
705 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 706 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
706 | } | 707 | } |
707 | 708 | ||
709 | static struct cmd_results *cmd_floating_scroll(int argc, char **argv) { | ||
710 | struct cmd_results *error = NULL; | ||
711 | if ((error = checkarg(argc, "floating_scroll", EXPECTED_AT_LEAST, 1))) { | ||
712 | return error; | ||
713 | } | ||
714 | if (!strcasecmp("behavior", argv[0])) { | ||
715 | if (argc < 2) { | ||
716 | error = cmd_results_new(CMD_INVALID, "floating_scroll", "Insufficient parameters given"); | ||
717 | return error; | ||
718 | } | ||
719 | if (!strcasecmp("gaps_inner", argv[1])) { | ||
720 | config->floating_scroll = FSB_GAPS_INNER; | ||
721 | } else if (!strcasecmp("gaps_outer", argv[1])) { | ||
722 | config->floating_scroll = FSB_GAPS_OUTER; | ||
723 | } else if (!strcasecmp("custom", argv[1])) { | ||
724 | config->floating_scroll = FSB_CUSTOM; | ||
725 | } else { | ||
726 | error = cmd_results_new(CMD_INVALID, "floating_scroll", "Unknown behavior: '%s'", argv[1]); | ||
727 | return error; | ||
728 | } | ||
729 | } else if (!strcasecmp("up", argv[0])) { | ||
730 | free(config->fsb_up); | ||
731 | if (argc < 2) { | ||
732 | config->fsb_up = strdup(""); | ||
733 | } else { | ||
734 | config->fsb_up = join_args(argv + 1, argc - 1); | ||
735 | } | ||
736 | } else if (!strcasecmp("down", argv[0])) { | ||
737 | free(config->fsb_down); | ||
738 | if (argc < 2) { | ||
739 | config->fsb_down = strdup(""); | ||
740 | } else { | ||
741 | config->fsb_down = join_args(argv + 1, argc - 1); | ||
742 | } | ||
743 | } else { | ||
744 | error = cmd_results_new(CMD_INVALID, "floating_scroll", "Unknown command: '%s'", argv[0]); | ||
745 | return error; | ||
746 | } | ||
747 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
748 | } | ||
749 | |||
708 | static struct cmd_results *cmd_focus(int argc, char **argv) { | 750 | static struct cmd_results *cmd_focus(int argc, char **argv) { |
709 | if (config->reading) return cmd_results_new(CMD_FAILURE, "focus", "Can't be used in config file."); | 751 | if (config->reading) return cmd_results_new(CMD_FAILURE, "focus", "Can't be used in config file."); |
710 | struct cmd_results *error = NULL; | 752 | struct cmd_results *error = NULL; |
@@ -2377,6 +2419,7 @@ static struct cmd_handler handlers[] = { | |||
2377 | { "exit", cmd_exit }, | 2419 | { "exit", cmd_exit }, |
2378 | { "floating", cmd_floating }, | 2420 | { "floating", cmd_floating }, |
2379 | { "floating_modifier", cmd_floating_mod }, | 2421 | { "floating_modifier", cmd_floating_mod }, |
2422 | { "floating_scroll", cmd_floating_scroll }, | ||
2380 | { "focus", cmd_focus }, | 2423 | { "focus", cmd_focus }, |
2381 | { "focus_follows_mouse", cmd_focus_follows_mouse }, | 2424 | { "focus_follows_mouse", cmd_focus_follows_mouse }, |
2382 | { "font", cmd_font }, | 2425 | { "font", cmd_font }, |