emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 879c65a5fc 2/2: Simplify scroll valuator reset handling


From: Po Lu
Subject: master 879c65a5fc 2/2: Simplify scroll valuator reset handling
Date: Fri, 28 Oct 2022 08:06:24 -0400 (EDT)

branch: master
commit 879c65a5fca4b543806c9b854e8a5ac3a99e172f
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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.
---
 src/xterm.c | 47 ++++++++++++++++++-----------------------------
 src/xterm.h | 23 ++++++++++++++++++-----
 2 files changed, 36 insertions(+), 34 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index f2d6be5d46..f1bccddb6c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -5369,7 +5369,6 @@ xi_populate_device_from_info (struct xi_device_t 
*xi_device,
            valuator->emacs_value = DBL_MIN;
            valuator->increment = info->increment;
            valuator->number = info->number;
-           valuator->pending_enter_reset = false;
 
            break;
          }
@@ -5415,7 +5414,6 @@ xi_populate_device_from_info (struct xi_device_t 
*xi_device,
            {
              xi_device->valuators[c].invalid_p = false;
              xi_device->valuators[c].current_value = tem->current_value;
-             xi_device->valuators[c].pending_enter_reset = true;
            }
        }
     }
@@ -5609,8 +5607,8 @@ xi_find_touch_point (struct xi_device_t *device, int 
detail)
 #ifdef HAVE_XINPUT2_1
 
 static void
-xi_reset_scroll_valuators_for_device_id (struct x_display_info *dpyinfo, int 
id,
-                                        bool pending_only)
+xi_reset_scroll_valuators_for_device_id (struct x_display_info *dpyinfo,
+                                        int id)
 {
   struct xi_device_t *device = xi_device_from_id (dpyinfo, id);
   struct xi_scroll_valuator_t *valuator;
@@ -5624,11 +5622,6 @@ xi_reset_scroll_valuators_for_device_id (struct 
x_display_info *dpyinfo, int id,
   for (int i = 0; i < device->scroll_valuator_count; ++i)
     {
       valuator = &device->valuators[i];
-
-      if (pending_only && !valuator->pending_enter_reset)
-       continue;
-
-      valuator->pending_enter_reset = false;
       valuator->invalid_p = true;
       valuator->emacs_value = 0.0;
     }
@@ -13113,14 +13106,6 @@ xi_handle_device_changed (struct x_display_info 
*dpyinfo,
                {
                  valuator->invalid_p = false;
                  valuator->current_value = valuator_info->value;
-
-                 /* Make sure that this is reset if the pointer moves
-                    into a window of ours.
-
-                    Otherwise the valuator state could be left
-                    invalid if the DeviceChange event happened with
-                    the pointer outside any Emacs frame. */
-                 valuator->pending_enter_reset = true;
                }
 
              break;
@@ -21412,8 +21397,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                  && enter->mode != XINotifyGrab
                  && enter->mode != XINotifyPassiveGrab
                  && enter->mode != XINotifyPassiveUngrab)
-               xi_reset_scroll_valuators_for_device_id (dpyinfo, 
enter->deviceid,
-                                                        true);
+               xi_reset_scroll_valuators_for_device_id (dpyinfo,
+                                                        enter->deviceid);
 #endif
 
              {
@@ -21526,13 +21511,18 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 retrieve the value of a valuator outside of each motion
                 event.
 
-                As such, to prevent wildly inaccurate results when the
-                valuators have changed outside Emacs, we reset our
-                records of each valuator's value whenever the pointer
-                moves out of a frame (and not into one of its
-                children, which we know about).  */
+                As such, to prevent wildly inaccurate results when
+                the valuators have changed outside Emacs, we reset
+                our records of each valuator's value whenever the
+                pointer moves out of a frame.  Ideally, this would
+                ignore events with a detail of XINotifyInferior, as
+                the window the pointer moved to would be one known to
+                Emacs, but the code to keep track of which valuators
+                had to be reset upon the corresponding XI_Enter event
+                was very complicated and kept running into server
+                bugs.  */
 #ifdef HAVE_XINPUT2_1
-             if (leave->detail != XINotifyInferior && any
+             if (any
                  /* xfwm4 selects for button events on the frame
                     window, resulting in passive grabs being
                     generated along with the delivery of emulated
@@ -21547,7 +21537,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                  && leave->mode != XINotifyPassiveUngrab
                  && leave->mode != XINotifyPassiveGrab)
                xi_reset_scroll_valuators_for_device_id (dpyinfo,
-                                                        leave->deviceid, 
false);
+                                                        leave->deviceid);
 #endif
 
              x_display_set_last_user_time (dpyinfo, leave->time,
@@ -21584,13 +21574,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 just looks up a top window on Xt builds.  */
 
 #ifdef HAVE_XINPUT2_1
-             if (leave->detail != XINotifyInferior && f
-                 && leave->mode != XINotifyUngrab
+             if (f && leave->mode != XINotifyUngrab
                  && leave->mode != XINotifyGrab
                  && leave->mode != XINotifyPassiveUngrab
                  && leave->mode != XINotifyPassiveGrab)
                xi_reset_scroll_valuators_for_device_id (dpyinfo,
-                                                        leave->deviceid, 
false);
+                                                        leave->deviceid);
 #endif
 
              if (!f)
diff --git a/src/xterm.h b/src/xterm.h
index 537cabc957..1124dcceb4 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -213,20 +213,32 @@ struct color_name_cache_entry
 #ifdef HAVE_XINPUT2
 
 #ifdef HAVE_XINPUT2_1
+
 struct xi_scroll_valuator_t
 {
-  bool invalid_p;
-  bool pending_enter_reset;
+  /* The ID of the valuator.  */
+  int number;
+
+  /* Whether or not it represents X axis movement.  */
+  bool_bf horizontal : 1;
+
+  /* Whether or not the value is currently invalid.  */
+  bool_bf invalid_p : 1;
+
+  /* The current value.  */
   double current_value;
+
+  /* Value used to tally up deltas until a threshold is met.  */
   double emacs_value;
-  double increment;
 
-  int number;
-  int horizontal;
+  /* The scroll increment.  */
+  double increment;
 };
+
 #endif
 
 #ifdef HAVE_XINPUT2_2
+
 struct xi_touch_point_t
 {
   struct xi_touch_point_t *next;
@@ -234,6 +246,7 @@ struct xi_touch_point_t
   int number;
   double x, y;
 };
+
 #endif
 
 struct xi_device_t



reply via email to

[Prev in Thread] Current Thread [Next in Thread]