aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2021-11-23 09:01:33 +0800
committerPo Lu2021-11-23 09:04:40 +0800
commit919cb31cf7f2aec2d8134783b0a5bb93a621fcaf (patch)
tree994ebd957902098c7e35244089fe9653bde68723 /src
parent9ceb3070e34ad8a54184fd0deda477bf5ff77000 (diff)
downloademacs-919cb31cf7f2aec2d8134783b0a5bb93a621fcaf.tar.gz
emacs-919cb31cf7f2aec2d8134783b0a5bb93a621fcaf.zip
Fix XI2 keysym translation
* src/xterm.c (handle_one_xevent): Handle XI_KeyPress events that can't be translated into strings.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c53
1 files changed, 19 insertions, 34 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 197776ce316..11e7e602c09 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10324,7 +10324,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
10324 memset (&xkey, 0, sizeof xkey); 10324 memset (&xkey, 0, sizeof xkey);
10325 10325
10326 xkey.type = KeyPress; 10326 xkey.type = KeyPress;
10327 xkey.serial = 0; 10327 xkey.serial = xev->serial;
10328 xkey.send_event = xev->send_event; 10328 xkey.send_event = xev->send_event;
10329 xkey.display = xev->display; 10329 xkey.display = xev->display;
10330 xkey.window = xev->event; 10330 xkey.window = xev->event;
@@ -10439,53 +10439,38 @@ handle_one_xevent (struct x_display_info *dpyinfo,
10439 emacs_abort (); 10439 emacs_abort ();
10440 } 10440 }
10441 else 10441 else
10442 {
10443#endif 10442#endif
10443 {
10444#ifdef HAVE_XKB 10444#ifdef HAVE_XKB
10445 int overflow = 0; 10445 int overflow = 0;
10446 KeySym sym = keysym; 10446 KeySym sym = keysym;
10447 10447
10448 if (dpyinfo->xkb_desc) 10448 if (dpyinfo->xkb_desc)
10449 { 10449 {
10450 if (!(nbytes = XkbTranslateKeySym (dpyinfo->display, &sym, 10450 nbytes = XkbTranslateKeySym (dpyinfo->display, &sym,
10451 state & ~mods_rtrn, copy_bufptr, 10451 state & ~mods_rtrn, copy_bufptr,
10452 copy_bufsiz, &overflow))) 10452 copy_bufsiz, &overflow);
10453 goto XI_OTHER; 10453 if (overflow)
10454 }
10455 else
10456#else
10457 {
10458 block_input ();
10459 char *str = XKeysymToString (keysym);
10460 if (!str)
10461 { 10454 {
10462 unblock_input (); 10455 copy_bufptr = alloca ((copy_bufsiz += overflow)
10463 goto XI_OTHER; 10456 * sizeof *copy_bufptr);
10457 overflow = 0;
10458 nbytes = XkbTranslateKeySym (dpyinfo->display, &sym,
10459 state & ~mods_rtrn, copy_bufptr,
10460 copy_bufsiz, &overflow);
10461
10462 if (overflow)
10463 nbytes = 0;
10464 } 10464 }
10465 nbytes = strlen (str) + 1;
10466 copy_bufptr = alloca (nbytes);
10467 strcpy (copy_bufptr, str);
10468 unblock_input ();
10469 } 10465 }
10466 else
10470#endif 10467#endif
10471#ifdef HAVE_XKB
10472 if (overflow)
10473 { 10468 {
10474 overflow = 0; 10469 nbytes = XLookupString (&xkey, copy_bufptr,
10475 copy_bufptr = alloca (copy_bufsiz + overflow); 10470 copy_bufsiz, &keysym,
10476 keysym = sym; 10471 &compose_status);
10477 if (!(nbytes = XkbTranslateKeySym (dpyinfo->display, &sym,
10478 state & ~mods_rtrn, copy_bufptr,
10479 copy_bufsiz + overflow, &overflow)))
10480 goto XI_OTHER;
10481
10482 if (overflow)
10483 goto XI_OTHER;
10484 } 10472 }
10485#endif
10486#ifdef HAVE_X_I18N
10487 } 10473 }
10488#endif
10489 10474
10490 /* First deal with keysyms which have defined 10475 /* First deal with keysyms which have defined
10491 translations to characters. */ 10476 translations to characters. */