Add scrolldistance option, allowing scroll distance to be configured in

the config file
This commit is contained in:
Jacob 2023-07-22 18:30:27 +02:00
parent 10ed06bac8
commit c9292de59d
4 changed files with 17 additions and 5 deletions

View file

@ -269,7 +269,10 @@ spmenu = {
{ click = "None"; button = "Scroll Up"; function = "moveprev"; argument = "0"; }, // Scroll Up: Move to the previous page
{ click = "None"; button = "Scroll Down"; function = "movenext"; argument = "0"; }, // Scroll Down: Move to the next page
{ ignoreglobalmouse = 1; } ); // Ignore hardcoded mouse binds (0/1)
{
scrolldistance = 512; // Distance to scroll for a scroll action to count (num)
ignoreglobalmouse = 1; // Ignore hardcoded mouse binds (0/1)
} );
/* Keys
*

View file

@ -968,6 +968,7 @@ void conf_init(void) {
}
config_setting_lookup_int(conf, "ignoreglobalmouse", &sp.ignoreglobalmouse);
config_setting_lookup_int(conf, "scrolldistance", &scrolldistance);
}
}

View file

@ -11,6 +11,9 @@ static int loadtheme = 1; /* Load theme (~/.config/spmenu/them
static int loadbinds = 1; /* Load keybind file (~/.config/spmenu/binds.conf) on runtime */
static int mon = -1; /* Monitor to run spmenu on */
/* Wayland options */
static int scrolldistance = 512; /* Distance to scroll for a scroll action to count */
/* Config file options */
#if USECONFIG
static char *configfile = NULL; /* Config file path. Default is ~/.config/spmenu/spmenu.conf */

View file

@ -382,14 +382,19 @@ void pointer_motion_handler(void *data, struct wl_pointer *pointer, uint32_t tim
}
void pointer_axis_handler(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value) {
mouse_scroll = 1;
if (value > 0) {
if (value > scrolldistance) {
mouse_scroll_direction = 0;
} else {
} else if (value < -scrolldistance) {
mouse_scroll_direction = 1;
} else {
mouse_scroll = 0;
mouse_scroll_direction = -1;
return;
}
mouse_scroll = 1;
buttonpress_wl(mouse_scroll_direction, mouse_x, mouse_y);
mouse_scroll = 0;