emacs-diffs
[Top][All Lists]
Advanced

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

master 80f8dd6540: Restore valuator values after receiving a DeviceChang


From: Po Lu
Subject: master 80f8dd6540: Restore valuator values after receiving a DeviceChanged event
Date: Sun, 13 Feb 2022 22:52:54 -0500 (EST)

branch: master
commit 80f8dd654014aff065df76095aedfd09c21faf92
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Restore valuator values after receiving a DeviceChanged event
    
    * src/xterm.c (x_init_master_valuators): Generate valuators for
    both master and slave devices.
    (handle_one_xevent): Find current valuator info and use that to
    populate scroll valuators after a device changed.
---
 src/xterm.c | 64 ++++++++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 40 insertions(+), 24 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 198aaa69e5..98c8a22408 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -631,16 +631,13 @@ x_init_master_valuators (struct x_display_info *dpyinfo)
                      (XIScrollClassInfo *) device->classes[c];
                    struct xi_scroll_valuator_t *valuator;
 
-                   if (xi_device->master_p)
-                     {
-                       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;
-                     }
+                   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;
 
                    break;
                  }
@@ -11872,9 +11869,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
            {
              struct xi_device_t *device;
              struct xi_touch_point_t *tem, *last;
-             int c;
+             int c, i;
 
-             device = xi_device_from_id (dpyinfo, device_changed->sourceid);
+             device = xi_device_from_id (dpyinfo, device_changed->deviceid);
 
              if (!device)
                emacs_abort ();
@@ -11894,20 +11891,18 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 #ifdef XIScrollClass
                    case XIScrollClass:
                      {
-                       XIScrollClassInfo *info =
-                         (XIScrollClassInfo *) device_changed->classes[c];
+                       XIScrollClassInfo *info;
+
+                       info = (XIScrollClassInfo *) device_changed->classes[c];
                        struct xi_scroll_valuator_t *valuator;
 
-                       if (device->master_p)
-                         {
-                           valuator = 
&device->valuators[device->scroll_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;
-                         }
+                       valuator = 
&device->valuators[device->scroll_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;
 
                        break;
                      }
@@ -11927,6 +11922,27 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                    }
                }
 
+#ifdef XIScrollClass
+             for (c = 0; c < device_changed->num_classes; ++c)
+               {
+                 if (device_changed->classes[c]->type == XIValuatorClass)
+                   {
+                     XIValuatorClassInfo *info;
+
+                     info = (XIValuatorClassInfo *) device_changed->classes[c];
+
+                     for (i = 0; i < device->scroll_valuator_count; ++i)
+                       {
+                         if (device->valuators[i].number == info->number)
+                           {
+                             device->valuators[i].invalid_p = false;
+                             device->valuators[i].current_value = info->value;
+                           }
+                       }
+                   }
+               }
+#endif
+
              /* The device is no longer a DirectTouch device, so
                 remove any touchpoints that we might have
                 recorded.  */



reply via email to

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