aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-02-14 11:51:22 +0800
committerPo Lu2022-02-14 11:51:22 +0800
commit80f8dd654014aff065df76095aedfd09c21faf92 (patch)
treefd2c50f1f65b035473306614042a4e6ac93c9bc4 /src
parent1bf30718dd1e4284af285e4a92c336f512564f01 (diff)
downloademacs-80f8dd654014aff065df76095aedfd09c21faf92.tar.gz
emacs-80f8dd654014aff065df76095aedfd09c21faf92.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c64
1 files changed, 40 insertions, 24 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 198aaa69e5f..98c8a224080 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -631,16 +631,13 @@ x_init_master_valuators (struct x_display_info *dpyinfo)
631 (XIScrollClassInfo *) device->classes[c]; 631 (XIScrollClassInfo *) device->classes[c];
632 struct xi_scroll_valuator_t *valuator; 632 struct xi_scroll_valuator_t *valuator;
633 633
634 if (xi_device->master_p) 634 valuator = &xi_device->valuators[actual_valuator_count++];
635 { 635 valuator->horizontal
636 valuator = &xi_device->valuators[actual_valuator_count++]; 636 = (info->scroll_type == XIScrollTypeHorizontal);
637 valuator->horizontal 637 valuator->invalid_p = true;
638 = (info->scroll_type == XIScrollTypeHorizontal); 638 valuator->emacs_value = DBL_MIN;
639 valuator->invalid_p = true; 639 valuator->increment = info->increment;
640 valuator->emacs_value = DBL_MIN; 640 valuator->number = info->number;
641 valuator->increment = info->increment;
642 valuator->number = info->number;
643 }
644 641
645 break; 642 break;
646 } 643 }
@@ -11872,9 +11869,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
11872 { 11869 {
11873 struct xi_device_t *device; 11870 struct xi_device_t *device;
11874 struct xi_touch_point_t *tem, *last; 11871 struct xi_touch_point_t *tem, *last;
11875 int c; 11872 int c, i;
11876 11873
11877 device = xi_device_from_id (dpyinfo, device_changed->sourceid); 11874 device = xi_device_from_id (dpyinfo, device_changed->deviceid);
11878 11875
11879 if (!device) 11876 if (!device)
11880 emacs_abort (); 11877 emacs_abort ();
@@ -11894,20 +11891,18 @@ handle_one_xevent (struct x_display_info *dpyinfo,
11894#ifdef XIScrollClass 11891#ifdef XIScrollClass
11895 case XIScrollClass: 11892 case XIScrollClass:
11896 { 11893 {
11897 XIScrollClassInfo *info = 11894 XIScrollClassInfo *info;
11898 (XIScrollClassInfo *) device_changed->classes[c]; 11895
11896 info = (XIScrollClassInfo *) device_changed->classes[c];
11899 struct xi_scroll_valuator_t *valuator; 11897 struct xi_scroll_valuator_t *valuator;
11900 11898
11901 if (device->master_p) 11899 valuator = &device->valuators[device->scroll_valuator_count++];
11902 { 11900 valuator->horizontal
11903 valuator = &device->valuators[device->scroll_valuator_count++]; 11901 = (info->scroll_type == XIScrollTypeHorizontal);
11904 valuator->horizontal 11902 valuator->invalid_p = true;
11905 = (info->scroll_type == XIScrollTypeHorizontal); 11903 valuator->emacs_value = DBL_MIN;
11906 valuator->invalid_p = true; 11904 valuator->increment = info->increment;
11907 valuator->emacs_value = DBL_MIN; 11905 valuator->number = info->number;
11908 valuator->increment = info->increment;
11909 valuator->number = info->number;
11910 }
11911 11906
11912 break; 11907 break;
11913 } 11908 }
@@ -11927,6 +11922,27 @@ handle_one_xevent (struct x_display_info *dpyinfo,
11927 } 11922 }
11928 } 11923 }
11929 11924
11925#ifdef XIScrollClass
11926 for (c = 0; c < device_changed->num_classes; ++c)
11927 {
11928 if (device_changed->classes[c]->type == XIValuatorClass)
11929 {
11930 XIValuatorClassInfo *info;
11931
11932 info = (XIValuatorClassInfo *) device_changed->classes[c];
11933
11934 for (i = 0; i < device->scroll_valuator_count; ++i)
11935 {
11936 if (device->valuators[i].number == info->number)
11937 {
11938 device->valuators[i].invalid_p = false;
11939 device->valuators[i].current_value = info->value;
11940 }
11941 }
11942 }
11943 }
11944#endif
11945
11930 /* The device is no longer a DirectTouch device, so 11946 /* The device is no longer a DirectTouch device, so
11931 remove any touchpoints that we might have 11947 remove any touchpoints that we might have
11932 recorded. */ 11948 recorded. */