aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-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
4 files changed, 30 insertions, 6 deletions
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) {
} else {
config->floating_scroll_down_cmd = join_args(argv + 1, argc - 1);
}
+ } else if (!strcasecmp("left", argv[0])) {
+ free(config->floating_scroll_left_cmd);
+ if (argc < 2) {
+ config->floating_scroll_left_cmd = strdup("");
+ } else {
+ config->floating_scroll_left_cmd = join_args(argv + 1, argc - 1);
+ }
+ } else if (!strcasecmp("right", argv[0])) {
+ free(config->floating_scroll_right_cmd);
+ if (argc < 2) {
+ config->floating_scroll_right_cmd = strdup("");
+ } else {
+ config->floating_scroll_right_cmd = join_args(argv + 1, argc - 1);
+ }
} else {
error = cmd_results_new(CMD_INVALID, "floating_scroll", "Unknown command: '%s'", argv[0]);
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) {
free(config->font);
free(config->floating_scroll_up_cmd);
free(config->floating_scroll_down_cmd);
+ free(config->floating_scroll_left_cmd);
+ free(config->floating_scroll_right_cmd);
free(config);
}
@@ -163,6 +165,8 @@ static void config_defaults(struct sway_config *config) {
config->resizing_key = M_RIGHT_CLICK;
config->floating_scroll_up_cmd = strdup("");
config->floating_scroll_down_cmd = strdup("");
+ config->floating_scroll_left_cmd = strdup("");
+ config->floating_scroll_right_cmd = strdup("");
config->default_layout = L_NONE;
config->default_orientation = L_NONE;
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
bool handle_pointer_scroll(wlc_handle view, uint32_t time, const struct wlc_modifiers* modifiers,
uint8_t axis_bits, double _amount[2]) {
if (!(modifiers->mods ^ config->floating_mod)) {
- int amount = (int)_amount[0];
- if (amount > 0) {
+ int x_amount = (int)_amount[0];
+ int y_amount = (int)_amount[1];
+ if (x_amount > 0) {
handle_command(config->floating_scroll_up_cmd);
- } else if (amount < 0) {
+ } else if (x_amount < 0) {
handle_command(config->floating_scroll_down_cmd);
}
+ if (y_amount > 0) {
+ handle_command(config->floating_scroll_right_cmd);
+ } else if (y_amount < 0) {
+ handle_command(config->floating_scroll_left_cmd);
+ }
}
return EVENT_PASSTHROUGH;
}
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.
enabled, left click is used for resizing and right click for dragging. The
mode paramenter is optional and defaults to _normal_ if it isn't defined.
-**floating_scroll** <up|down> [command]::
- Sets the command to be executed on scrolling up and down
- (respectively) while holding the floating modifier. Resets the
+**floating_scroll** <up|down|left|right> [command]::
+ Sets the command to be executed on scrolling in the specified
+ direction while holding the floating modifier. Resets the
command, when given no arguments.
**focus_follows_mouse** <yes|no>::