Support floating_scroll sideways

This commit is contained in:
Mykyta Holubakha 2016-05-14 23:42:02 +03:00
parent 2c9553a6fd
commit e73dde3b10
5 changed files with 32 additions and 6 deletions

View File

@ -186,6 +186,8 @@ struct sway_config {
uint32_t resizing_key; uint32_t resizing_key;
char *floating_scroll_up_cmd; char *floating_scroll_up_cmd;
char *floating_scroll_down_cmd; char *floating_scroll_down_cmd;
char *floating_scroll_left_cmd;
char *floating_scroll_right_cmd;
enum swayc_layouts default_orientation; enum swayc_layouts default_orientation;
enum swayc_layouts default_layout; enum swayc_layouts default_layout;
char *font; char *font;

View File

@ -726,6 +726,20 @@ static struct cmd_results *cmd_floating_scroll(int argc, char **argv) {
} else { } else {
config->floating_scroll_down_cmd = join_args(argv + 1, argc - 1); 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 { } else {
error = cmd_results_new(CMD_INVALID, "floating_scroll", "Unknown command: '%s'", argv[0]); error = cmd_results_new(CMD_INVALID, "floating_scroll", "Unknown command: '%s'", argv[0]);
return error; return error;

View File

@ -133,6 +133,8 @@ void free_config(struct sway_config *config) {
free(config->font); free(config->font);
free(config->floating_scroll_up_cmd); free(config->floating_scroll_up_cmd);
free(config->floating_scroll_down_cmd); free(config->floating_scroll_down_cmd);
free(config->floating_scroll_left_cmd);
free(config->floating_scroll_right_cmd);
free(config); free(config);
} }
@ -163,6 +165,8 @@ static void config_defaults(struct sway_config *config) {
config->resizing_key = M_RIGHT_CLICK; config->resizing_key = M_RIGHT_CLICK;
config->floating_scroll_up_cmd = strdup(""); config->floating_scroll_up_cmd = strdup("");
config->floating_scroll_down_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_layout = L_NONE;
config->default_orientation = L_NONE; config->default_orientation = L_NONE;
config->font = strdup("monospace 10"); config->font = strdup("monospace 10");

View File

@ -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, bool handle_pointer_scroll(wlc_handle view, uint32_t time, const struct wlc_modifiers* modifiers,
uint8_t axis_bits, double _amount[2]) { uint8_t axis_bits, double _amount[2]) {
if (!(modifiers->mods ^ config->floating_mod)) { if (!(modifiers->mods ^ config->floating_mod)) {
int amount = (int)_amount[0]; int x_amount = (int)_amount[0];
if (amount > 0) { int y_amount = (int)_amount[1];
if (x_amount > 0) {
handle_command(config->floating_scroll_up_cmd); handle_command(config->floating_scroll_up_cmd);
} else if (amount < 0) { } else if (x_amount < 0) {
handle_command(config->floating_scroll_down_cmd); 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; return EVENT_PASSTHROUGH;
} }

View File

@ -156,9 +156,9 @@ or triggered at runtime.
enabled, left click is used for resizing and right click for dragging. The 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. mode paramenter is optional and defaults to _normal_ if it isn't defined.
**floating_scroll** <up|down> [command]:: **floating_scroll** <up|down|left|right> [command]::
Sets the command to be executed on scrolling up and down Sets the command to be executed on scrolling in the specified
(respectively) while holding the floating modifier. Resets the direction while holding the floating modifier. Resets the
command, when given no arguments. command, when given no arguments.
**focus_follows_mouse** <yes|no>:: **focus_follows_mouse** <yes|no>::