aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-10-28 20:06:06 +0800
committerPo Lu2022-10-28 20:06:06 +0800
commit879c65a5fca4b543806c9b854e8a5ac3a99e172f (patch)
treef278f75a114b060887873c5054a311549a64ff52 /src
parent90caddc98605e6dbf46be721f4a9ac8a72e8d7ac (diff)
downloademacs-879c65a5fca4b543806c9b854e8a5ac3a99e172f.tar.gz
emacs-879c65a5fca4b543806c9b854e8a5ac3a99e172f.zip
Simplify scroll valuator reset handling
* src/xterm.c (xi_populate_device_from_info) (xi_reset_scroll_valuators_for_device_id, xi_handle_device_changed) (handle_one_xevent): * src/xterm.h (struct xi_scroll_valuator_t): Get rid of `pending_enter_reset', which was extremely convoluted and kept hitting server bugs. Now, valuators are reset upon all crossing events.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c47
-rw-r--r--src/xterm.h23
2 files changed, 36 insertions, 34 deletions
diff --git a/src/xterm.c b/src/xterm.c
index f2d6be5d46b..f1bccddb6c3 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -5369,7 +5369,6 @@ xi_populate_device_from_info (struct xi_device_t *xi_device,
5369 valuator->emacs_value = DBL_MIN; 5369 valuator->emacs_value = DBL_MIN;
5370 valuator->increment = info->increment; 5370 valuator->increment = info->increment;
5371 valuator->number = info->number; 5371 valuator->number = info->number;
5372 valuator->pending_enter_reset = false;
5373 5372
5374 break; 5373 break;
5375 } 5374 }
@@ -5415,7 +5414,6 @@ xi_populate_device_from_info (struct xi_device_t *xi_device,
5415 { 5414 {
5416 xi_device->valuators[c].invalid_p = false; 5415 xi_device->valuators[c].invalid_p = false;
5417 xi_device->valuators[c].current_value = tem->current_value; 5416 xi_device->valuators[c].current_value = tem->current_value;
5418 xi_device->valuators[c].pending_enter_reset = true;
5419 } 5417 }
5420 } 5418 }
5421 } 5419 }
@@ -5609,8 +5607,8 @@ xi_find_touch_point (struct xi_device_t *device, int detail)
5609#ifdef HAVE_XINPUT2_1 5607#ifdef HAVE_XINPUT2_1
5610 5608
5611static void 5609static void
5612xi_reset_scroll_valuators_for_device_id (struct x_display_info *dpyinfo, int id, 5610xi_reset_scroll_valuators_for_device_id (struct x_display_info *dpyinfo,
5613 bool pending_only) 5611 int id)
5614{ 5612{
5615 struct xi_device_t *device = xi_device_from_id (dpyinfo, id); 5613 struct xi_device_t *device = xi_device_from_id (dpyinfo, id);
5616 struct xi_scroll_valuator_t *valuator; 5614 struct xi_scroll_valuator_t *valuator;
@@ -5624,11 +5622,6 @@ xi_reset_scroll_valuators_for_device_id (struct x_display_info *dpyinfo, int id,
5624 for (int i = 0; i < device->scroll_valuator_count; ++i) 5622 for (int i = 0; i < device->scroll_valuator_count; ++i)
5625 { 5623 {
5626 valuator = &device->valuators[i]; 5624 valuator = &device->valuators[i];
5627
5628 if (pending_only && !valuator->pending_enter_reset)
5629 continue;
5630
5631 valuator->pending_enter_reset = false;
5632 valuator->invalid_p = true; 5625 valuator->invalid_p = true;
5633 valuator->emacs_value = 0.0; 5626 valuator->emacs_value = 0.0;
5634 } 5627 }
@@ -13113,14 +13106,6 @@ xi_handle_device_changed (struct x_display_info *dpyinfo,
13113 { 13106 {
13114 valuator->invalid_p = false; 13107 valuator->invalid_p = false;
13115 valuator->current_value = valuator_info->value; 13108 valuator->current_value = valuator_info->value;
13116
13117 /* Make sure that this is reset if the pointer moves
13118 into a window of ours.
13119
13120 Otherwise the valuator state could be left
13121 invalid if the DeviceChange event happened with
13122 the pointer outside any Emacs frame. */
13123 valuator->pending_enter_reset = true;
13124 } 13109 }
13125 13110
13126 break; 13111 break;
@@ -21412,8 +21397,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
21412 && enter->mode != XINotifyGrab 21397 && enter->mode != XINotifyGrab
21413 && enter->mode != XINotifyPassiveGrab 21398 && enter->mode != XINotifyPassiveGrab
21414 && enter->mode != XINotifyPassiveUngrab) 21399 && enter->mode != XINotifyPassiveUngrab)
21415 xi_reset_scroll_valuators_for_device_id (dpyinfo, enter->deviceid, 21400 xi_reset_scroll_valuators_for_device_id (dpyinfo,
21416 true); 21401 enter->deviceid);
21417#endif 21402#endif
21418 21403
21419 { 21404 {
@@ -21526,13 +21511,18 @@ handle_one_xevent (struct x_display_info *dpyinfo,
21526 retrieve the value of a valuator outside of each motion 21511 retrieve the value of a valuator outside of each motion
21527 event. 21512 event.
21528 21513
21529 As such, to prevent wildly inaccurate results when the 21514 As such, to prevent wildly inaccurate results when
21530 valuators have changed outside Emacs, we reset our 21515 the valuators have changed outside Emacs, we reset
21531 records of each valuator's value whenever the pointer 21516 our records of each valuator's value whenever the
21532 moves out of a frame (and not into one of its 21517 pointer moves out of a frame. Ideally, this would
21533 children, which we know about). */ 21518 ignore events with a detail of XINotifyInferior, as
21519 the window the pointer moved to would be one known to
21520 Emacs, but the code to keep track of which valuators
21521 had to be reset upon the corresponding XI_Enter event
21522 was very complicated and kept running into server
21523 bugs. */
21534#ifdef HAVE_XINPUT2_1 21524#ifdef HAVE_XINPUT2_1
21535 if (leave->detail != XINotifyInferior && any 21525 if (any
21536 /* xfwm4 selects for button events on the frame 21526 /* xfwm4 selects for button events on the frame
21537 window, resulting in passive grabs being 21527 window, resulting in passive grabs being
21538 generated along with the delivery of emulated 21528 generated along with the delivery of emulated
@@ -21547,7 +21537,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
21547 && leave->mode != XINotifyPassiveUngrab 21537 && leave->mode != XINotifyPassiveUngrab
21548 && leave->mode != XINotifyPassiveGrab) 21538 && leave->mode != XINotifyPassiveGrab)
21549 xi_reset_scroll_valuators_for_device_id (dpyinfo, 21539 xi_reset_scroll_valuators_for_device_id (dpyinfo,
21550 leave->deviceid, false); 21540 leave->deviceid);
21551#endif 21541#endif
21552 21542
21553 x_display_set_last_user_time (dpyinfo, leave->time, 21543 x_display_set_last_user_time (dpyinfo, leave->time,
@@ -21584,13 +21574,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
21584 just looks up a top window on Xt builds. */ 21574 just looks up a top window on Xt builds. */
21585 21575
21586#ifdef HAVE_XINPUT2_1 21576#ifdef HAVE_XINPUT2_1
21587 if (leave->detail != XINotifyInferior && f 21577 if (f && leave->mode != XINotifyUngrab
21588 && leave->mode != XINotifyUngrab
21589 && leave->mode != XINotifyGrab 21578 && leave->mode != XINotifyGrab
21590 && leave->mode != XINotifyPassiveUngrab 21579 && leave->mode != XINotifyPassiveUngrab
21591 && leave->mode != XINotifyPassiveGrab) 21580 && leave->mode != XINotifyPassiveGrab)
21592 xi_reset_scroll_valuators_for_device_id (dpyinfo, 21581 xi_reset_scroll_valuators_for_device_id (dpyinfo,
21593 leave->deviceid, false); 21582 leave->deviceid);
21594#endif 21583#endif
21595 21584
21596 if (!f) 21585 if (!f)
diff --git a/src/xterm.h b/src/xterm.h
index 537cabc9577..1124dcceb4a 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -213,20 +213,32 @@ struct color_name_cache_entry
213#ifdef HAVE_XINPUT2 213#ifdef HAVE_XINPUT2
214 214
215#ifdef HAVE_XINPUT2_1 215#ifdef HAVE_XINPUT2_1
216
216struct xi_scroll_valuator_t 217struct xi_scroll_valuator_t
217{ 218{
218 bool invalid_p; 219 /* The ID of the valuator. */
219 bool pending_enter_reset; 220 int number;
221
222 /* Whether or not it represents X axis movement. */
223 bool_bf horizontal : 1;
224
225 /* Whether or not the value is currently invalid. */
226 bool_bf invalid_p : 1;
227
228 /* The current value. */
220 double current_value; 229 double current_value;
230
231 /* Value used to tally up deltas until a threshold is met. */
221 double emacs_value; 232 double emacs_value;
222 double increment;
223 233
224 int number; 234 /* The scroll increment. */
225 int horizontal; 235 double increment;
226}; 236};
237
227#endif 238#endif
228 239
229#ifdef HAVE_XINPUT2_2 240#ifdef HAVE_XINPUT2_2
241
230struct xi_touch_point_t 242struct xi_touch_point_t
231{ 243{
232 struct xi_touch_point_t *next; 244 struct xi_touch_point_t *next;
@@ -234,6 +246,7 @@ struct xi_touch_point_t
234 int number; 246 int number;
235 double x, y; 247 double x, y;
236}; 248};
249
237#endif 250#endif
238 251
239struct xi_device_t 252struct xi_device_t