[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 8874cd908c: Coalesce duplicate scroll valuator handling code
From: |
Po Lu |
Subject: |
master 8874cd908c: Coalesce duplicate scroll valuator handling code |
Date: |
Sun, 20 Nov 2022 08:03:28 -0500 (EST) |
branch: master
commit 8874cd908c0ea0e2200f6f4f596bf645e76a0c0c
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Coalesce duplicate scroll valuator handling code
Also, write more commentary.
* src/xterm.c (xi_populate_scroll_valuator): New function.
Describe the meaning of each field in xi_scroll_valuator_t.
(xi_populate_device_from_info, xi_handle_new_classes): Factor
out duplicate code to that function.
---
src/xterm.c | 62 ++++++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 45 insertions(+), 17 deletions(-)
diff --git a/src/xterm.c b/src/xterm.c
index 500d80cad7..af652a0d85 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -5323,6 +5323,46 @@ struct xi_known_valuator
struct xi_known_valuator *next;
};
+/* Populate the scroll valuator at INDEX in DEVICE with the scroll
+ valuator information provided in INFO.
+
+ The information consists of:
+
+ - whether or not the valuator is horizontal.
+
+ - whether or not the valuator's value is currently unknown,
+ until the next XI_Motion event is received or the valuator's
+ value is restored by the caller upon encountering valuator
+ class data.
+
+ - what the current value of the valuator is. This is set to
+ DBL_MIN for debugging purposes, but can be any value, as
+ invalid_p is currently true.
+
+ - the increment, which defines the amount of movement equal to a
+ single unit of scrolling. For example, if the increment is
+ 2.0, then a WHEEL_DOWN or WHEEL_UP event will be sent every
+ time the valuator value changes by 2.0, unless
+ mwheel-coalesce-scroll-events is nil.
+
+ - the number used in XI_Motion events and elsewhere to identify
+ the valuator. */
+
+static void
+xi_populate_scroll_valuator (struct xi_device_t *device,
+ int index, XIScrollClassInfo *info)
+{
+ struct xi_scroll_valuator_t *valuator;
+
+ valuator = &device->valuators[index];
+ valuator->horizontal
+ = (info->scroll_type == XIScrollTypeHorizontal);
+ valuator->invalid_p = true;
+ valuator->emacs_value = DBL_MIN;
+ valuator->increment = info->increment;
+ valuator->number = info->number;
+}
+
#endif
static void
@@ -5331,7 +5371,6 @@ xi_populate_device_from_info (struct x_display_info
*dpyinfo,
XIDeviceInfo *device)
{
#ifdef HAVE_XINPUT2_1
- struct xi_scroll_valuator_t *valuator;
struct xi_known_valuator *values, *tem;
int actual_valuator_count, c;
XIScrollClassInfo *info;
@@ -5432,15 +5471,8 @@ xi_populate_device_from_info (struct x_display_info
*dpyinfo,
case XIScrollClass:
{
info = (XIScrollClassInfo *) device->classes[c];
-
- valuator = &xi_device->valuators[actual_valuator_count++];
- valuator->horizontal
- = (info->scroll_type == XIScrollTypeHorizontal);
- valuator->invalid_p = true;
- valuator->emacs_value = DBL_MIN;
- valuator->increment = info->increment;
- valuator->number = info->number;
-
+ xi_populate_scroll_valuator (xi_device, actual_valuator_count++,
+ info);
break;
}
@@ -13164,13 +13196,9 @@ xi_handle_new_classes (struct x_display_info *dpyinfo,
struct xi_device_t *devic
case XIScrollClass:
scroll = (XIScrollClassInfo *) classes[i];
- valuator = &device->valuators[device->scroll_valuator_count++];
- valuator->horizontal = (scroll->scroll_type
- == XIScrollTypeHorizontal);
- valuator->invalid_p = true;
- valuator->emacs_value = 0;
- valuator->increment = scroll->increment;
- valuator->number = scroll->number;
+ xi_populate_scroll_valuator (device,
+ device->scroll_valuator_count++,
+ scroll);
break;
#ifdef HAVE_XINPUT2_2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 8874cd908c: Coalesce duplicate scroll valuator handling code,
Po Lu <=