aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2022-11-05 13:12:32 +0200
committerEli Zaretskii2022-11-05 13:12:32 +0200
commit656cc127f2e16fd40585ddc9646b1cb8d552d9dd (patch)
treed05e9c03c20c363f659813ce781db7bce30dfb34 /src
parent22fb5397defc14c3dbdb48ba7f2f06cb7329be9d (diff)
parent154ecf61972fa7277bf9412f2bf34b496338b57d (diff)
downloademacs-656cc127f2e16fd40585ddc9646b1cb8d552d9dd.tar.gz
emacs-656cc127f2e16fd40585ddc9646b1cb8d552d9dd.zip
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c224
1 files changed, 94 insertions, 130 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 4178526c318..545a95f7b24 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -5301,6 +5301,7 @@ x_free_xi_devices (struct x_display_info *dpyinfo)
5301} 5301}
5302 5302
5303#ifdef HAVE_XINPUT2_1 5303#ifdef HAVE_XINPUT2_1
5304
5304struct xi_known_valuator 5305struct xi_known_valuator
5305{ 5306{
5306 /* The current value of this valuator. */ 5307 /* The current value of this valuator. */
@@ -5312,6 +5313,7 @@ struct xi_known_valuator
5312 /* The next valuator whose value we already know. */ 5313 /* The next valuator whose value we already know. */
5313 struct xi_known_valuator *next; 5314 struct xi_known_valuator *next;
5314}; 5315};
5316
5315#endif 5317#endif
5316 5318
5317static void 5319static void
@@ -5321,11 +5323,10 @@ xi_populate_device_from_info (struct xi_device_t *xi_device,
5321#ifdef HAVE_XINPUT2_1 5323#ifdef HAVE_XINPUT2_1
5322 struct xi_scroll_valuator_t *valuator; 5324 struct xi_scroll_valuator_t *valuator;
5323 struct xi_known_valuator *values, *tem; 5325 struct xi_known_valuator *values, *tem;
5324 int actual_valuator_count; 5326 int actual_valuator_count, c;
5325 XIScrollClassInfo *info; 5327 XIScrollClassInfo *info;
5326 XIValuatorClassInfo *val_info; 5328 XIValuatorClassInfo *val_info;
5327#endif 5329#endif
5328 int c;
5329#ifdef HAVE_XINPUT2_2 5330#ifdef HAVE_XINPUT2_2
5330 XITouchClassInfo *touch_info; 5331 XITouchClassInfo *touch_info;
5331#endif 5332#endif
@@ -5339,8 +5340,8 @@ xi_populate_device_from_info (struct xi_device_t *xi_device,
5339 5340
5340#ifdef HAVE_XINPUT2_1 5341#ifdef HAVE_XINPUT2_1
5341 actual_valuator_count = 0; 5342 actual_valuator_count = 0;
5342 xi_device->valuators = xmalloc (sizeof *xi_device->valuators 5343 xi_device->valuators = xnmalloc (device->num_classes,
5343 * device->num_classes); 5344 sizeof *xi_device->valuators);
5344 values = NULL; 5345 values = NULL;
5345#endif 5346#endif
5346 5347
@@ -5353,11 +5354,11 @@ xi_populate_device_from_info (struct xi_device_t *xi_device,
5353 xi_device->direct_p = false; 5354 xi_device->direct_p = false;
5354#endif 5355#endif
5355 5356
5357#ifdef HAVE_XINPUT2_1
5356 for (c = 0; c < device->num_classes; ++c) 5358 for (c = 0; c < device->num_classes; ++c)
5357 { 5359 {
5358 switch (device->classes[c]->type) 5360 switch (device->classes[c]->type)
5359 { 5361 {
5360#ifdef HAVE_XINPUT2_1
5361 case XIScrollClass: 5362 case XIScrollClass:
5362 { 5363 {
5363 info = (XIScrollClassInfo *) device->classes[c]; 5364 info = (XIScrollClassInfo *) device->classes[c];
@@ -5385,7 +5386,6 @@ xi_populate_device_from_info (struct xi_device_t *xi_device,
5385 values = tem; 5386 values = tem;
5386 break; 5387 break;
5387 } 5388 }
5388#endif
5389 5389
5390#ifdef HAVE_XINPUT2_2 5390#ifdef HAVE_XINPUT2_2
5391 case XITouchClass: 5391 case XITouchClass:
@@ -5399,7 +5399,6 @@ xi_populate_device_from_info (struct xi_device_t *xi_device,
5399 } 5399 }
5400 } 5400 }
5401 5401
5402#ifdef HAVE_XINPUT2_1
5403 xi_device->scroll_valuator_count = actual_valuator_count; 5402 xi_device->scroll_valuator_count = actual_valuator_count;
5404 5403
5405 /* Now look through all the valuators whose values are already known 5404 /* Now look through all the valuators whose values are already known
@@ -13043,97 +13042,117 @@ xi_has_scroll_valuators (XIDeviceChangedEvent *event)
13043 return false; 13042 return false;
13044} 13043}
13045 13044
13046#endif 13045/* Repopulate the information (touchpoint tracking information, scroll
13046 valuators, etc) in DEVICE with the device classes provided in
13047 CLASSES. This is called upon receiving a DeviceChanged event.
13047 13048
13048/* Handle EVENT, a DeviceChanged event. Look up the device that 13049 This function is not present on XI 2.0 as there are no worthwhile
13049 changed, and update its information with the data in EVENT. */ 13050 classes there. */
13050 13051
13051static void 13052static void
13052xi_handle_device_changed (struct x_display_info *dpyinfo, 13053xi_handle_new_classes (struct x_display_info *dpyinfo, struct xi_device_t *device,
13053 struct xi_device_t *device, 13054 XIAnyClassInfo **classes, int num_classes)
13054 XIDeviceChangedEvent *event)
13055{ 13055{
13056#ifdef HAVE_XINPUT2_1
13057 XIDeviceInfo *info;
13058 XIScrollClassInfo *scroll; 13056 XIScrollClassInfo *scroll;
13059 int i, ndevices;
13060 struct xi_scroll_valuator_t *valuator; 13057 struct xi_scroll_valuator_t *valuator;
13061 XIValuatorClassInfo *valuator_info; 13058 XIValuatorClassInfo *valuator_info;
13062#endif 13059 int i;
13063#ifdef HAVE_XINPUT2_2 13060#ifdef HAVE_XINPUT2_2
13064 struct xi_touch_point_t *tem, *last;
13065 XITouchClassInfo *touch; 13061 XITouchClassInfo *touch;
13066#endif 13062#endif
13067 13063
13068#ifdef HAVE_XINPUT2_1 13064 if (dpyinfo->xi2_version < 1)
13069 if (xi_has_scroll_valuators (event)) 13065 /* Emacs is connected to an XI 2.0 server, which reports no
13070 { 13066 classes of interest. */
13071 /* Scroll valuators are provided by this event. Use the values 13067 return;
13072 provided in this event to populate the device's new scroll 13068
13073 valuator list, as if this event's is a SlaveSwitch event 13069 device->valuators = xnmalloc (num_classes,
13074 caused by wheel movement, querying for the device info will 13070 sizeof *device->valuators);
13075 probably return newer values, leading to a delta of 0 being 13071 device->scroll_valuator_count = 0;
13076 computed when handling the subsequent XI_Motion event.
13077 (bug#58980) */
13078
13079 device->valuators = xrealloc (device->valuators,
13080 (event->num_classes
13081 * sizeof *device->valuators));
13082 device->scroll_valuator_count = 0;
13083#ifdef HAVE_XINPUT2_2 13072#ifdef HAVE_XINPUT2_2
13084 device->direct_p = false; 13073 device->direct_p = false;
13085#endif 13074#endif
13086 13075
13087 for (i = 0; i < event->num_classes; ++i) 13076 for (i = 0; i < num_classes; ++i)
13077 {
13078 switch (classes[i]->type)
13088 { 13079 {
13089 switch (event->classes[i]->type) 13080 case XIScrollClass:
13090 { 13081 scroll = (XIScrollClassInfo *) classes[i];
13091 case XIScrollClass: 13082
13092 scroll = (XIScrollClassInfo *) event->classes[i]; 13083 valuator = &device->valuators[device->scroll_valuator_count++];
13093 13084 valuator->horizontal = (scroll->scroll_type
13094 valuator = &device->valuators[device->scroll_valuator_count++]; 13085 == XIScrollTypeHorizontal);
13095 valuator->horizontal = (scroll->scroll_type 13086 valuator->invalid_p = true;
13096 == XIScrollTypeHorizontal); 13087 valuator->emacs_value = 0;
13097 valuator->invalid_p = true; 13088 valuator->increment = scroll->increment;
13098 valuator->emacs_value = 0; 13089 valuator->number = scroll->number;
13099 valuator->increment = scroll->increment; 13090 break;
13100 valuator->number = scroll->number;
13101 break;
13102 13091
13103#ifdef HAVE_XINPUT2_2 13092#ifdef HAVE_XINPUT2_2
13104 case XITouchClass: 13093 case XITouchClass:
13105 touch = (XITouchClassInfo *) event->classes[i]; 13094 touch = (XITouchClassInfo *) classes[i];
13106 13095
13107 if (touch->mode == XIDirectTouch) 13096 if (touch->mode == XIDirectTouch)
13108 device->direct_p = true; 13097 device->direct_p = true;
13109 break; 13098 break;
13110#endif 13099#endif
13111 }
13112 } 13100 }
13101 }
13113 13102
13114 /* Restore the values of any scroll valuators that we already 13103 /* Restore the values of any scroll valuators that we already
13115 know about. */ 13104 know about. */
13116 13105
13117 for (i = 0; i < event->num_classes; ++i) 13106 for (i = 0; i < num_classes; ++i)
13107 {
13108 switch (classes[i]->type)
13118 { 13109 {
13119 switch (event->classes[i]->type) 13110 case XIValuatorClass:
13120 { 13111 valuator_info = (XIValuatorClassInfo *) classes[i];
13121 case XIValuatorClass:
13122 valuator_info = (XIValuatorClassInfo *) event->classes[i];
13123
13124 valuator = xi_get_scroll_valuator (device,
13125 valuator_info->number);
13126 if (valuator)
13127 {
13128 valuator->invalid_p = false;
13129 valuator->current_value = valuator_info->value;
13130 valuator->emacs_value = 0;
13131 }
13132 13112
13133 break; 13113 valuator = xi_get_scroll_valuator (device,
13114 valuator_info->number);
13115 if (valuator)
13116 {
13117 valuator->invalid_p = false;
13118 valuator->current_value = valuator_info->value;
13119 valuator->emacs_value = 0;
13134 } 13120 }
13121
13122 break;
13135 } 13123 }
13136 } 13124 }
13125}
13126
13127#endif
13128
13129/* Handle EVENT, a DeviceChanged event. Look up the device that
13130 changed, and update its information with the data in EVENT. */
13131
13132static void
13133xi_handle_device_changed (struct x_display_info *dpyinfo,
13134 struct xi_device_t *device,
13135 XIDeviceChangedEvent *event)
13136{
13137#ifdef HAVE_XINPUT2_1
13138 int ndevices;
13139 XIDeviceInfo *info;
13140#endif
13141#ifdef HAVE_XINPUT2_2
13142 struct xi_touch_point_t *tem, *last;
13143#endif
13144
13145#ifdef HAVE_XINPUT2_1
13146 if (xi_has_scroll_valuators (event))
13147 /* Scroll valuators are provided by this event. Use the values
13148 provided in this event to populate the device's new scroll
13149 valuator list: if this event is a SlaveSwitch event caused by
13150 wheel movement, then querying for the device info will probably
13151 return the value after the wheel movement, leading to a delta
13152 of 0 being computed upon handling the subsequent XI_Motion
13153 event. (bug#58980) */
13154 xi_handle_new_classes (dpyinfo, device, event->classes,
13155 event->num_classes);
13137 else 13156 else
13138 { 13157 {
13139 /* When a DeviceChange event is received for a master device, 13158 /* When a DeviceChange event is received for a master device,
@@ -13153,65 +13172,10 @@ xi_handle_device_changed (struct x_display_info *dpyinfo,
13153 if (!info) 13172 if (!info)
13154 return; 13173 return;
13155 13174
13156 device->valuators = xrealloc (device->valuators, 13175 /* info contains the classes currently associated with the
13157 (info->num_classes 13176 event. Apply them. */
13158 * sizeof *device->valuators)); 13177 xi_handle_new_classes (dpyinfo, device, info->classes,
13159 device->scroll_valuator_count = 0; 13178 info->num_classes);
13160#ifdef HAVE_XINPUT2_2
13161 device->direct_p = false;
13162#endif
13163
13164 for (i = 0; i < info->num_classes; ++i)
13165 {
13166 switch (info->classes[i]->type)
13167 {
13168 case XIScrollClass:
13169 scroll = (XIScrollClassInfo *) info->classes[i];
13170
13171 valuator = &device->valuators[device->scroll_valuator_count++];
13172 valuator->horizontal = (scroll->scroll_type
13173 == XIScrollTypeHorizontal);
13174 valuator->invalid_p = true;
13175 valuator->emacs_value = 0;
13176 valuator->increment = scroll->increment;
13177 valuator->number = scroll->number;
13178 break;
13179
13180#ifdef HAVE_XINPUT2_2
13181 case XITouchClass:
13182 touch = (XITouchClassInfo *) info->classes[i];
13183
13184 if (touch->mode == XIDirectTouch)
13185 device->direct_p = true;
13186 break;
13187#endif
13188 }
13189 }
13190
13191 /* Restore the values of any scroll valuators that we already
13192 know about. */
13193
13194 for (i = 0; i < info->num_classes; ++i)
13195 {
13196 switch (info->classes[i]->type)
13197 {
13198 case XIValuatorClass:
13199 valuator_info = (XIValuatorClassInfo *) info->classes[i];
13200
13201 valuator = xi_get_scroll_valuator (device,
13202 valuator_info->number);
13203 if (valuator)
13204 {
13205 valuator->invalid_p = false;
13206 valuator->current_value = valuator_info->value;
13207 valuator->emacs_value = 0;
13208 }
13209
13210 break;
13211 }
13212 }
13213
13214 XIFreeDeviceInfo (info);
13215 } 13179 }
13216#endif 13180#endif
13217 13181