From d65e67face1f826ea7dec06a9d56b1a0c46c22b8 Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+erikreider@users.noreply.github.com> Date: Wed, 5 May 2021 19:23:15 +0200 Subject: [PATCH] Added scroll_factor input variable to ipc output --- sway/ipc-json.c | 12 ++++++++++++ sway/sway-ipc.7.scd | 3 +++ 2 files changed, 15 insertions(+) diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 2c4c52a39..34adfc74b 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -1002,6 +1003,17 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { } } + if (device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { + struct input_config *ic = input_device_get_config(device); + float scroll_factor = 1.0f; + if (ic != NULL && !isnan(ic->scroll_factor) && + ic->scroll_factor != FLT_MIN) { + scroll_factor = ic->scroll_factor; + } + json_object_object_add(object, "scroll_factor", + json_object_new_double(scroll_factor)); + } + if (wlr_input_device_is_libinput(device->wlr_device)) { struct libinput_device *libinput_dev; libinput_dev = wlr_libinput_get_device_handle(device->wlr_device); diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd index 1b855959c..373e9dce1 100644 --- a/sway/sway-ipc.7.scd +++ b/sway/sway-ipc.7.scd @@ -1131,6 +1131,9 @@ following properties: |- xkb_active_layout_index : integer : (Only keyboards) The index of the active keyboard layout in use +|- scroll_factor +: floating +: (Only pointers) Multiplier applied on scroll event values. |- libinput : object : (Only libinput devices) An object describing the current device settings.