aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-02-20 10:03:28 +0800
committerPo Lu2022-02-20 10:03:28 +0800
commit15910e5da34a084fe01e0fd96ecf394cb1030e25 (patch)
tree088cfb285b6d2ed3f176065adee75708f9bdd6ea /src
parent7a699e79f6e2616dbbc3acc2024f97c90caa485c (diff)
downloademacs-15910e5da34a084fe01e0fd96ecf394cb1030e25.tar.gz
emacs-15910e5da34a084fe01e0fd96ecf394cb1030e25.zip
Ignore modifier keys early when handling X key press events
* src/xterm.c (handle_one_xevent): Ignore modifier keys earlier without going through the usual key lookup. (x_delete_terminal): Free recorded modifier map. (x_find_modifier_meanings): Record modifier map. * src/xterm.h (struct x_display_info): New field `modmap'.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c51
-rw-r--r--src/xterm.h3
2 files changed, 53 insertions, 1 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 64bee110227..4c1c4312172 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6162,7 +6162,10 @@ x_find_modifier_meanings (struct x_display_info *dpyinfo)
6162 dpyinfo->hyper_mod_mask &= ~dpyinfo->super_mod_mask; 6162 dpyinfo->hyper_mod_mask &= ~dpyinfo->super_mod_mask;
6163 6163
6164 XFree (syms); 6164 XFree (syms);
6165 XFreeModifiermap (mods); 6165
6166 if (dpyinfo->modmap)
6167 XFreeModifiermap (dpyinfo->modmap);
6168 dpyinfo->modmap = mods;
6166} 6169}
6167 6170
6168/* Convert between the modifier bits X uses and the modifier bits 6171/* Convert between the modifier bits X uses and the modifier bits
@@ -9893,6 +9896,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
9893 /* `xkey' will be modified, but it's not important to modify 9896 /* `xkey' will be modified, but it's not important to modify
9894 `event' itself. */ 9897 `event' itself. */
9895 XKeyEvent xkey = event->xkey; 9898 XKeyEvent xkey = event->xkey;
9899 int i;
9896 9900
9897#ifdef USE_GTK 9901#ifdef USE_GTK
9898 /* Don't pass keys to GTK. A Tab will shift focus to the 9902 /* Don't pass keys to GTK. A Tab will shift focus to the
@@ -9924,6 +9928,27 @@ handle_one_xevent (struct x_display_info *dpyinfo,
9924 if (modifiers & dpyinfo->meta_mod_mask) 9928 if (modifiers & dpyinfo->meta_mod_mask)
9925 memset (&compose_status, 0, sizeof (compose_status)); 9929 memset (&compose_status, 0, sizeof (compose_status));
9926 9930
9931#ifdef HAVE_XKB
9932 if (FRAME_DISPLAY_INFO (f)->xkb_desc)
9933 {
9934 XkbDescRec *rec = FRAME_DISPLAY_INFO (f)->xkb_desc;
9935
9936 if (rec->map->modmap && rec->map->modmap[xkey.keycode])
9937 goto done_keysym;
9938 }
9939 else
9940#endif
9941 {
9942 if (dpyinfo->modmap)
9943 {
9944 for (i = 0; i < 8 * dpyinfo->modmap->max_keypermod; i++)
9945 {
9946 if (xkey.keycode == dpyinfo->modmap->modifiermap[i])
9947 goto done_keysym;
9948 }
9949 }
9950 }
9951
9927#ifdef HAVE_X_I18N 9952#ifdef HAVE_X_I18N
9928 if (FRAME_XIC (f)) 9953 if (FRAME_XIC (f))
9929 { 9954 {
@@ -11546,6 +11571,27 @@ handle_one_xevent (struct x_display_info *dpyinfo,
11546#endif 11571#endif
11547 11572
11548#ifdef HAVE_XKB 11573#ifdef HAVE_XKB
11574 if (FRAME_DISPLAY_INFO (f)->xkb_desc)
11575 {
11576 XkbDescRec *rec = FRAME_DISPLAY_INFO (f)->xkb_desc;
11577
11578 if (rec->map->modmap && rec->map->modmap[xev->detail])
11579 goto done_keysym;
11580 }
11581 else
11582#endif
11583 {
11584 if (dpyinfo->modmap)
11585 {
11586 for (i = 0; i < 8 * dpyinfo->modmap->max_keypermod; i++)
11587 {
11588 if (xkey.keycode == dpyinfo->modmap->modifiermap[xev->detail])
11589 goto done_keysym;
11590 }
11591 }
11592 }
11593
11594#ifdef HAVE_XKB
11549 if (dpyinfo->xkb_desc) 11595 if (dpyinfo->xkb_desc)
11550 { 11596 {
11551 uint xkb_state = state; 11597 uint xkb_state = state;
@@ -16743,6 +16789,9 @@ x_delete_terminal (struct terminal *terminal)
16743 XCloseDisplay (dpyinfo->display); 16789 XCloseDisplay (dpyinfo->display);
16744#endif 16790#endif
16745#endif /* ! USE_GTK */ 16791#endif /* ! USE_GTK */
16792
16793 if (dpyinfo->modmap)
16794 XFreeModifiermap (dpyinfo->modmap);
16746 /* Do not close the connection here because it's already closed 16795 /* Do not close the connection here because it's already closed
16747 by X(t)CloseDisplay (Bug#18403). */ 16796 by X(t)CloseDisplay (Bug#18403). */
16748 dpyinfo->display = NULL; 16797 dpyinfo->display = NULL;
diff --git a/src/xterm.h b/src/xterm.h
index f58fa0fe54d..14457b32cc2 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -526,6 +526,9 @@ struct x_display_info
526 Atom Xatom_Meta, Xatom_Super, Xatom_Hyper, Xatom_ShiftLock, Xatom_Alt; 526 Atom Xatom_Meta, Xatom_Super, Xatom_Hyper, Xatom_ShiftLock, Xatom_Alt;
527#endif 527#endif
528 528
529 /* Core modifier map when XKB is not present. */
530 XModifierKeymap *modmap;
531
529#ifdef HAVE_XRANDR 532#ifdef HAVE_XRANDR
530 int xrandr_major_version; 533 int xrandr_major_version;
531 int xrandr_minor_version; 534 int xrandr_minor_version;