summaryrefslogtreecommitdiff
path: root/src/xterm.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-11-10 13:25:28 +0800
committerPo Lu <luangruo@yahoo.com>2022-11-10 13:25:28 +0800
commit0047bdeb3393d5d7acbdffd7444370fc3e4d2384 (patch)
tree6216acf1fe1b51bbca1789ef61c6c77ea7f75445 /src/xterm.c
parentef3627508a65ee750054622fc4557c42c6589e89 (diff)
downloademacs-0047bdeb3393d5d7acbdffd7444370fc3e4d2384.tar.gz
Be a little more paranoid about XI 2.0 implementations
* src/xterm.c (xi_populate_device_from_info): (xi_disable_devices): Do not restore valuator values if the valuator info has a mode of Relative and a value of 0.0.
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c57
1 files changed, 39 insertions, 18 deletions
diff --git a/src/xterm.c b/src/xterm.c
index fd04061436a..a175a4a6bbb 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -5339,7 +5339,7 @@ xi_populate_device_from_info (struct x_display_info *dpyinfo,
struct xi_known_valuator *values, *tem;
int actual_valuator_count, c;
XIScrollClassInfo *info;
- XIValuatorClassInfo *val_info;
+ XIValuatorClassInfo *valuator_info;
#endif
#ifdef HAVE_XINPUT2_2
XITouchClassInfo *touch_info;
@@ -5450,12 +5450,23 @@ xi_populate_device_from_info (struct x_display_info *dpyinfo,
case XIValuatorClass:
{
- val_info = (XIValuatorClassInfo *) device->classes[c];
+ valuator_info = (XIValuatorClassInfo *) device->classes[c];
tem = SAFE_ALLOCA (sizeof *tem);
+ /* Avoid restoring bogus values if some driver
+ accidentally specifies relative values in scroll
+ valuator classes how the input extension spec says they
+ should be, but allow restoring values when a value is
+ set, which is how the input extension actually
+ behaves. */
+
+ if (valuator_info->value == 0.0
+ && valuator_info->mode != XIModeAbsolute)
+ continue;
+
tem->next = values;
- tem->number = val_info->number;
- tem->current_value = val_info->value;
+ tem->number = valuator_info->number;
+ tem->current_value = valuator_info->value;
values = tem;
break;
@@ -13182,22 +13193,32 @@ xi_handle_new_classes (struct x_display_info *dpyinfo, struct xi_device_t *devic
for (i = 0; i < num_classes; ++i)
{
- switch (classes[i]->type)
- {
- case XIValuatorClass:
- valuator_info = (XIValuatorClassInfo *) classes[i];
+ if (classes[i]->type != XIValuatorClass)
+ continue;
- valuator = xi_get_scroll_valuator (device,
- valuator_info->number);
- if (valuator)
- {
- valuator->invalid_p = false;
- valuator->current_value = valuator_info->value;
- valuator->emacs_value = 0;
- }
+ valuator_info = (XIValuatorClassInfo *) classes[i];
- break;
- }
+ /* Avoid restoring bogus values if some driver accidentally
+ specifies relative values in scroll valuator classes how the
+ input extension spec says they should be, but allow restoring
+ values when a value is set, which is how the input extension
+ actually behaves. */
+
+ if (valuator_info->value == 0.0
+ && valuator_info->mode != XIModeAbsolute)
+ continue;
+
+ valuator = xi_get_scroll_valuator (device,
+ valuator_info->number);
+
+ if (!valuator)
+ continue;
+
+ valuator->invalid_p = false;
+ valuator->current_value = valuator_info->value;
+ valuator->emacs_value = 0;
+
+ break;
}
}