aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-11-10 13:25:28 +0800
committerPo Lu2022-11-10 13:25:28 +0800
commit0047bdeb3393d5d7acbdffd7444370fc3e4d2384 (patch)
tree6216acf1fe1b51bbca1789ef61c6c77ea7f75445 /src
parentef3627508a65ee750054622fc4557c42c6589e89 (diff)
downloademacs-0047bdeb3393d5d7acbdffd7444370fc3e4d2384.tar.gz
emacs-0047bdeb3393d5d7acbdffd7444370fc3e4d2384.zip
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')
-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,
5339 struct xi_known_valuator *values, *tem; 5339 struct xi_known_valuator *values, *tem;
5340 int actual_valuator_count, c; 5340 int actual_valuator_count, c;
5341 XIScrollClassInfo *info; 5341 XIScrollClassInfo *info;
5342 XIValuatorClassInfo *val_info; 5342 XIValuatorClassInfo *valuator_info;
5343#endif 5343#endif
5344#ifdef HAVE_XINPUT2_2 5344#ifdef HAVE_XINPUT2_2
5345 XITouchClassInfo *touch_info; 5345 XITouchClassInfo *touch_info;
@@ -5450,12 +5450,23 @@ xi_populate_device_from_info (struct x_display_info *dpyinfo,
5450 5450
5451 case XIValuatorClass: 5451 case XIValuatorClass:
5452 { 5452 {
5453 val_info = (XIValuatorClassInfo *) device->classes[c]; 5453 valuator_info = (XIValuatorClassInfo *) device->classes[c];
5454 tem = SAFE_ALLOCA (sizeof *tem); 5454 tem = SAFE_ALLOCA (sizeof *tem);
5455 5455
5456 /* Avoid restoring bogus values if some driver
5457 accidentally specifies relative values in scroll
5458 valuator classes how the input extension spec says they
5459 should be, but allow restoring values when a value is
5460 set, which is how the input extension actually
5461 behaves. */
5462
5463 if (valuator_info->value == 0.0
5464 && valuator_info->mode != XIModeAbsolute)
5465 continue;
5466
5456 tem->next = values; 5467 tem->next = values;
5457 tem->number = val_info->number; 5468 tem->number = valuator_info->number;
5458 tem->current_value = val_info->value; 5469 tem->current_value = valuator_info->value;
5459 5470
5460 values = tem; 5471 values = tem;
5461 break; 5472 break;
@@ -13182,22 +13193,32 @@ xi_handle_new_classes (struct x_display_info *dpyinfo, struct xi_device_t *devic
13182 13193
13183 for (i = 0; i < num_classes; ++i) 13194 for (i = 0; i < num_classes; ++i)
13184 { 13195 {
13185 switch (classes[i]->type) 13196 if (classes[i]->type != XIValuatorClass)
13186 { 13197 continue;
13187 case XIValuatorClass:
13188 valuator_info = (XIValuatorClassInfo *) classes[i];
13189 13198
13190 valuator = xi_get_scroll_valuator (device, 13199 valuator_info = (XIValuatorClassInfo *) classes[i];
13191 valuator_info->number);
13192 if (valuator)
13193 {
13194 valuator->invalid_p = false;
13195 valuator->current_value = valuator_info->value;
13196 valuator->emacs_value = 0;
13197 }
13198 13200
13199 break; 13201 /* Avoid restoring bogus values if some driver accidentally
13200 } 13202 specifies relative values in scroll valuator classes how the
13203 input extension spec says they should be, but allow restoring
13204 values when a value is set, which is how the input extension
13205 actually behaves. */
13206
13207 if (valuator_info->value == 0.0
13208 && valuator_info->mode != XIModeAbsolute)
13209 continue;
13210
13211 valuator = xi_get_scroll_valuator (device,
13212 valuator_info->number);
13213
13214 if (!valuator)
13215 continue;
13216
13217 valuator->invalid_p = false;
13218 valuator->current_value = valuator_info->value;
13219 valuator->emacs_value = 0;
13220
13221 break;
13201 } 13222 }
13202} 13223}
13203 13224