Merge pull request #523 from meeeee3/scroll-factor

feat: add wheel scroll factor
This commit is contained in:
DreamMaoMao
2025-12-19 16:43:50 +08:00
committed by GitHub
3 changed files with 13 additions and 4 deletions

View File

@@ -265,6 +265,8 @@ typedef struct {
uint32_t send_events_mode; uint32_t send_events_mode;
uint32_t button_map; uint32_t button_map;
double axis_scroll_factor;
int blur; int blur;
int blur_layer; int blur_layer;
int blur_optimized; int blur_optimized;
@@ -1504,6 +1506,8 @@ void parse_option(Config *config, char *key, char *value) {
config->send_events_mode = atoi(value); config->send_events_mode = atoi(value);
} else if (strcmp(key, "button_map") == 0) { } else if (strcmp(key, "button_map") == 0) {
config->button_map = atoi(value); config->button_map = atoi(value);
} else if (strcmp(key, "axis_scroll_factor") == 0) {
config->axis_scroll_factor = atof(value);
} else if (strcmp(key, "gappih") == 0) { } else if (strcmp(key, "gappih") == 0) {
config->gappih = atoi(value); config->gappih = atoi(value);
} else if (strcmp(key, "gappiv") == 0) { } else if (strcmp(key, "gappiv") == 0) {
@@ -2780,6 +2784,7 @@ void override_config(void) {
click_method = CLAMP_INT(config.click_method, 0, 2); click_method = CLAMP_INT(config.click_method, 0, 2);
send_events_mode = CLAMP_INT(config.send_events_mode, 0, 2); send_events_mode = CLAMP_INT(config.send_events_mode, 0, 2);
button_map = CLAMP_INT(config.button_map, 0, 1); button_map = CLAMP_INT(config.button_map, 0, 1);
axis_scroll_factor = CLAMP_FLOAT(config.axis_scroll_factor, 0.1f, 10.0f);
// 外观设置 // 外观设置
gappih = CLAMP_INT(config.gappih, 0, 1000); gappih = CLAMP_INT(config.gappih, 0, 1000);
@@ -2907,6 +2912,7 @@ void set_value_default() {
config.exchange_cross_monitor = exchange_cross_monitor; config.exchange_cross_monitor = exchange_cross_monitor;
config.scratchpad_cross_monitor = scratchpad_cross_monitor; config.scratchpad_cross_monitor = scratchpad_cross_monitor;
config.focus_cross_tag = focus_cross_tag; config.focus_cross_tag = focus_cross_tag;
config.axis_scroll_factor = axis_scroll_factor;
config.view_current_to_back = view_current_to_back; config.view_current_to_back = view_current_to_back;
config.single_scratchpad = single_scratchpad; config.single_scratchpad = single_scratchpad;
config.xwayland_persistence = xwayland_persistence; config.xwayland_persistence = xwayland_persistence;

View File

@@ -178,6 +178,8 @@ LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER
enum libinput_config_click_method click_method = enum libinput_config_click_method click_method =
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
double axis_scroll_factor = 1.0;
/* You can choose between: /* You can choose between:
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED LIBINPUT_CONFIG_SEND_EVENTS_DISABLED

View File

@@ -1711,10 +1711,11 @@ axisnotify(struct wl_listener *listener, void *data) {
* implemented checking the event's orientation and the delta of the event * implemented checking the event's orientation and the delta of the event
*/ */
/* Notify the client with pointer focus of the axis event. */ /* Notify the client with pointer focus of the axis event. */
wlr_seat_pointer_notify_axis(seat, // 滚轮事件发送给客户端也就是窗口 wlr_seat_pointer_notify_axis(
event->time_msec, event->orientation, seat, // 滚轮事件发送给客户端也就是窗口
event->delta, event->delta_discrete, event->time_msec, event->orientation, event->delta * axis_scroll_factor,
event->source, event->relative_direction); roundf(event->delta_discrete * axis_scroll_factor), event->source,
event->relative_direction);
} }
int ongesture(struct wlr_pointer_swipe_end_event *event) { int ongesture(struct wlr_pointer_swipe_end_event *event) {