summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/config.h2
-rw-r--r--sway/commands.c14
-rw-r--r--sway/config.c4
-rw-r--r--sway/handlers.c12
-rw-r--r--sway/sway.5.txt6
5 files changed, 32 insertions, 6 deletions
diff --git a/include/config.h b/include/config.h
index e15ba311..3c1957b6 100644
--- a/include/config.h
+++ b/include/config.h
@@ -186,6 +186,8 @@ struct sway_config {
186 uint32_t resizing_key; 186 uint32_t resizing_key;
187 char *floating_scroll_up_cmd; 187 char *floating_scroll_up_cmd;
188 char *floating_scroll_down_cmd; 188 char *floating_scroll_down_cmd;
189 char *floating_scroll_left_cmd;
190 char *floating_scroll_right_cmd;
189 enum swayc_layouts default_orientation; 191 enum swayc_layouts default_orientation;
190 enum swayc_layouts default_layout; 192 enum swayc_layouts default_layout;
191 char *font; 193 char *font;
diff --git a/sway/commands.c b/sway/commands.c
index 22621453..9c5309f9 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -726,6 +726,20 @@ static struct cmd_results *cmd_floating_scroll(int argc, char **argv) {
726 } else { 726 } else {
727 config->floating_scroll_down_cmd = join_args(argv + 1, argc - 1); 727 config->floating_scroll_down_cmd = join_args(argv + 1, argc - 1);
728 } 728 }
729 } else if (!strcasecmp("left", argv[0])) {
730 free(config->floating_scroll_left_cmd);
731 if (argc < 2) {
732 config->floating_scroll_left_cmd = strdup("");
733 } else {
734 config->floating_scroll_left_cmd = join_args(argv + 1, argc - 1);
735 }
736 } else if (!strcasecmp("right", argv[0])) {
737 free(config->floating_scroll_right_cmd);
738 if (argc < 2) {
739 config->floating_scroll_right_cmd = strdup("");
740 } else {
741 config->floating_scroll_right_cmd = join_args(argv + 1, argc - 1);
742 }
729 } else { 743 } else {
730 error = cmd_results_new(CMD_INVALID, "floating_scroll", "Unknown command: '%s'", argv[0]); 744 error = cmd_results_new(CMD_INVALID, "floating_scroll", "Unknown command: '%s'", argv[0]);
731 return error; 745 return error;
diff --git a/sway/config.c b/sway/config.c
index 6c1d21c8..14b657ef 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -133,6 +133,8 @@ void free_config(struct sway_config *config) {
133 free(config->font); 133 free(config->font);
134 free(config->floating_scroll_up_cmd); 134 free(config->floating_scroll_up_cmd);
135 free(config->floating_scroll_down_cmd); 135 free(config->floating_scroll_down_cmd);
136 free(config->floating_scroll_left_cmd);
137 free(config->floating_scroll_right_cmd);
136 free(config); 138 free(config);
137} 139}
138 140
@@ -163,6 +165,8 @@ static void config_defaults(struct sway_config *config) {
163 config->resizing_key = M_RIGHT_CLICK; 165 config->resizing_key = M_RIGHT_CLICK;
164 config->floating_scroll_up_cmd = strdup(""); 166 config->floating_scroll_up_cmd = strdup("");
165 config->floating_scroll_down_cmd = strdup(""); 167 config->floating_scroll_down_cmd = strdup("");
168 config->floating_scroll_left_cmd = strdup("");
169 config->floating_scroll_right_cmd = strdup("");
166 config->default_layout = L_NONE; 170 config->default_layout = L_NONE;
167 config->default_orientation = L_NONE; 171 config->default_orientation = L_NONE;
168 config->font = strdup("monospace 10"); 172 config->font = strdup("monospace 10");
diff --git a/sway/handlers.c b/sway/handlers.c
index 67275575..931e1340 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -723,12 +723,18 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
723bool handle_pointer_scroll(wlc_handle view, uint32_t time, const struct wlc_modifiers* modifiers, 723bool handle_pointer_scroll(wlc_handle view, uint32_t time, const struct wlc_modifiers* modifiers,
724 uint8_t axis_bits, double _amount[2]) { 724 uint8_t axis_bits, double _amount[2]) {
725 if (!(modifiers->mods ^ config->floating_mod)) { 725 if (!(modifiers->mods ^ config->floating_mod)) {
726 int amount = (int)_amount[0]; 726 int x_amount = (int)_amount[0];
727 if (amount > 0) { 727 int y_amount = (int)_amount[1];
728 if (x_amount > 0) {
728 handle_command(config->floating_scroll_up_cmd); 729 handle_command(config->floating_scroll_up_cmd);
729 } else if (amount < 0) { 730 } else if (x_amount < 0) {
730 handle_command(config->floating_scroll_down_cmd); 731 handle_command(config->floating_scroll_down_cmd);
731 } 732 }
733 if (y_amount > 0) {
734 handle_command(config->floating_scroll_right_cmd);
735 } else if (y_amount < 0) {
736 handle_command(config->floating_scroll_left_cmd);
737 }
732 } 738 }
733 return EVENT_PASSTHROUGH; 739 return EVENT_PASSTHROUGH;
734} 740}
diff --git a/sway/sway.5.txt b/sway/sway.5.txt
index 25229033..32ff79d8 100644
--- a/sway/sway.5.txt
+++ b/sway/sway.5.txt
@@ -156,9 +156,9 @@ or triggered at runtime.
156 enabled, left click is used for resizing and right click for dragging. The 156 enabled, left click is used for resizing and right click for dragging. The
157 mode paramenter is optional and defaults to _normal_ if it isn't defined. 157 mode paramenter is optional and defaults to _normal_ if it isn't defined.
158 158
159**floating_scroll** <up|down> [command]:: 159**floating_scroll** <up|down|left|right> [command]::
160 Sets the command to be executed on scrolling up and down 160 Sets the command to be executed on scrolling in the specified
161 (respectively) while holding the floating modifier. Resets the 161 direction while holding the floating modifier. Resets the
162 command, when given no arguments. 162 command, when given no arguments.
163 163
164**focus_follows_mouse** <yes|no>:: 164**focus_follows_mouse** <yes|no>::