summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-11-08 19:59:47 +0800
committerPo Lu <luangruo@yahoo.com>2022-11-08 20:00:36 +0800
commit12e601f9811479d657f6abd8f63099dc73dda471 (patch)
tree5be2f382c7d1483110b36f1c2b065f27e6c338c0
parentb8134a7eba2e0334925e011e953044ea33408ec6 (diff)
downloademacs-12e601f9811479d657f6abd8f63099dc73dda471.tar.gz
Clean up some duplicate event group conversion code
* src/xterm.c (xi_convert_event_keyboard_state): New function. Move keyboard event state over. (handle_one_xevent): Use it where necessary.
-rw-r--r--src/xterm.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 84438e85909..861cf5da549 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -5245,7 +5245,9 @@ xi_convert_button_state (XIButtonState *in, unsigned int *out)
}
}
-/* Return the modifier state in XEV as a standard X modifier mask. */
+/* Return the modifier state in XEV as a standard X modifier mask.
+ This should be used for non-keyboard events, where the group does
+ not matter. */
#ifdef USE_GTK
static
@@ -5263,6 +5265,17 @@ xi_convert_event_state (XIDeviceEvent *xev)
return mods | buttons;
}
+/* Like the above. However, buttons are not converted, while the
+ group is. This should be used for key events being passed to the
+ likes of input methods and Xt. */
+
+static unsigned int
+xi_convert_event_keyboard_state (XIDeviceEvent *xev)
+{
+ return ((xev->mods.effective & ~(1 << 13 | 1 << 14))
+ | (xev->group.effective << 13));
+}
+
/* Free all XI2 devices on DPYINFO. */
static void
x_free_xi_devices (struct x_display_info *dpyinfo)
@@ -23092,8 +23105,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
copy.xkey.root = xev->root;
copy.xkey.subwindow = xev->child;
copy.xkey.time = xev->time;
- copy.xkey.state = ((xev->mods.effective & ~(1 << 13 | 1 << 14))
- | (xev->group.effective << 13));
+ copy.xkey.state = xi_convert_event_keyboard_state (xev);
xi_convert_button_state (&xev->buttons, &copy.xkey.state);
copy.xkey.x = lrint (xev->event_x);
@@ -23149,8 +23161,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
xkey.root = xev->root;
xkey.subwindow = xev->child;
xkey.time = xev->time;
- xkey.state = ((xev->mods.effective & ~(1 << 13 | 1 << 14))
- | (xev->group.effective << 13));
+ xkey.state = xi_convert_event_keyboard_state (xev);
xkey.x = lrint (xev->event_x);
xkey.y = lrint (xev->event_y);
@@ -23568,8 +23579,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
xkey.root = xev->root;
xkey.subwindow = xev->child;
xkey.time = xev->time;
- xkey.state = ((xev->mods.effective & ~(1 << 13 | 1 << 14))
- | (xev->group.effective << 13));
+ xkey.state = xi_convert_event_keyboard_state (xev);
xkey.x = lrint (xev->event_x);
xkey.y = lrint (xev->event_y);
xkey.x_root = lrint (xev->root_x);