aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
authorStefan Monnier2002-04-16 15:08:20 +0000
committerStefan Monnier2002-04-16 15:08:20 +0000
commitc997eae589ab6c5ea0b0d445009a4d745b460a90 (patch)
tree18b554c4e8406a703873787fdfcdf026f5fe9889 /src/xterm.c
parentbf36a6d3d111954c4ff755725e1ed3efba626408 (diff)
downloademacs-c997eae589ab6c5ea0b0d445009a4d745b460a90.tar.gz
emacs-c997eae589ab6c5ea0b0d445009a4d745b460a90.zip
(Qlatin_1, Qutf_8): New vars.
(syms_of_xterm): Initialize them. (XTread_socket): Eliminate incorrect optimization that tried to avoid decoding the output of X*LookupString. Always use latin-1 to decode the output of XLookupString. Try Xutf8LookupString if XmbLookupString failed.
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c90
1 files changed, 53 insertions, 37 deletions
diff --git a/src/xterm.c b/src/xterm.c
index aae8114dda0..13ee72ec8de 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -394,6 +394,7 @@ Lisp_Object Vx_alt_keysym, Vx_hyper_keysym, Vx_meta_keysym, Vx_super_keysym;
394static Lisp_Object Qalt, Qhyper, Qmeta, Qsuper, Qmodifier_value; 394static Lisp_Object Qalt, Qhyper, Qmeta, Qsuper, Qmodifier_value;
395 395
396static Lisp_Object Qvendor_specific_keysyms; 396static Lisp_Object Qvendor_specific_keysyms;
397static Lisp_Object Qlatin_1, Qutf_8;
397 398
398extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *)); 399extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *));
399extern Lisp_Object x_icon_type P_ ((struct frame *)); 400extern Lisp_Object x_icon_type P_ ((struct frame *));
@@ -9935,18 +9936,6 @@ XTread_socket (sd, bufp, numchars, expected)
9935 9936
9936 ++handling_signal; 9937 ++handling_signal;
9937 9938
9938 /* The input should be decoded if it is from XIM. Currently the
9939 locale of XIM is the same as that of the system. So, we can use
9940 Vlocale_coding_system which is initialized properly at Emacs
9941 startup time. */
9942 setup_coding_system (Vlocale_coding_system, &coding);
9943 coding.src_multibyte = 0;
9944 coding.dst_multibyte = 1;
9945 /* The input is converted to events, thus we can't handle
9946 composition. Anyway, there's no XIM that gives us composition
9947 information. */
9948 coding.composing = COMPOSITION_DISABLED;
9949
9950 /* Find the display we are supposed to read input for. 9939 /* Find the display we are supposed to read input for.
9951 It's the one communicating on descriptor SD. */ 9940 It's the one communicating on descriptor SD. */
9952 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) 9941 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
@@ -10457,6 +10446,7 @@ XTread_socket (sd, bufp, numchars, expected)
10457 unsigned char *copy_bufptr = copy_buffer; 10446 unsigned char *copy_bufptr = copy_buffer;
10458 int copy_bufsiz = sizeof (copy_buffer); 10447 int copy_bufsiz = sizeof (copy_buffer);
10459 int modifiers; 10448 int modifiers;
10449 Lisp_Object coding_system = Qlatin_1;
10460 10450
10461 event.xkey.state 10451 event.xkey.state
10462 |= x_emacs_to_x_modifiers (FRAME_X_DISPLAY_INFO (f), 10452 |= x_emacs_to_x_modifiers (FRAME_X_DISPLAY_INFO (f),
@@ -10486,6 +10476,7 @@ XTread_socket (sd, bufp, numchars, expected)
10486 { 10476 {
10487 Status status_return; 10477 Status status_return;
10488 10478
10479 coding_system = Vlocale_coding_system;
10489 nbytes = XmbLookupString (FRAME_XIC (f), 10480 nbytes = XmbLookupString (FRAME_XIC (f),
10490 &event.xkey, copy_bufptr, 10481 &event.xkey, copy_bufptr,
10491 copy_bufsiz, &keysym, 10482 copy_bufsiz, &keysym,
@@ -10499,6 +10490,26 @@ XTread_socket (sd, bufp, numchars, expected)
10499 copy_bufsiz, &keysym, 10490 copy_bufsiz, &keysym,
10500 &status_return); 10491 &status_return);
10501 } 10492 }
10493#ifdef X_HAVE_UTF8_STRING
10494 else if (status_return == XLookupKeySym)
10495 { /* Try again but with utf-8. */
10496 coding_system = Qutf_8;
10497 nbytes = Xutf8LookupString (FRAME_XIC (f),
10498 &event.xkey, copy_bufptr,
10499 copy_bufsiz, &keysym,
10500 &status_return);
10501 if (status_return == XBufferOverflow)
10502 {
10503 copy_bufsiz = nbytes + 1;
10504 copy_bufptr = (char *) alloca (copy_bufsiz);
10505 nbytes = Xutf8LookupString (FRAME_XIC (f),
10506 &event.xkey,
10507 copy_bufptr,
10508 copy_bufsiz, &keysym,
10509 &status_return);
10510 }
10511 }
10512#endif
10502 10513
10503 if (status_return == XLookupNone) 10514 if (status_return == XLookupNone)
10504 break; 10515 break;
@@ -10625,6 +10636,17 @@ XTread_socket (sd, bufp, numchars, expected)
10625 register int c; 10636 register int c;
10626 int nchars, len; 10637 int nchars, len;
10627 10638
10639 /* The input should be decoded with `coding_system'
10640 which depends on which X*LookupString function
10641 we used just above and the locale. */
10642 setup_coding_system (coding_system, &coding);
10643 coding.src_multibyte = 0;
10644 coding.dst_multibyte = 1;
10645 /* The input is converted to events, thus we can't
10646 handle composition. Anyway, there's no XIM that
10647 gives us composition information. */
10648 coding.composing = COMPOSITION_DISABLED;
10649
10628 for (i = 0; i < nbytes; i++) 10650 for (i = 0; i < nbytes; i++)
10629 { 10651 {
10630 if (temp_index == (sizeof temp_buffer 10652 if (temp_index == (sizeof temp_buffer
@@ -10633,31 +10655,20 @@ XTread_socket (sd, bufp, numchars, expected)
10633 temp_buffer[temp_index++] = copy_bufptr[i]; 10655 temp_buffer[temp_index++] = copy_bufptr[i];
10634 } 10656 }
10635 10657
10636 if (/* If the event is not from XIM, */ 10658 {
10637 event.xkey.keycode != 0 10659 /* Decode the input data. */
10638 /* or the current locale doesn't request 10660 int require;
10639 decoding of the intup data, ... */ 10661 unsigned char *p;
10640 || coding.type == coding_type_raw_text 10662
10641 || coding.type == coding_type_no_conversion) 10663 require = decoding_buffer_size (&coding, nbytes);
10642 { 10664 p = (unsigned char *) alloca (require);
10643 /* ... we can use the input data as is. */ 10665 coding.mode |= CODING_MODE_LAST_BLOCK;
10644 nchars = nbytes; 10666 decode_coding (&coding, copy_bufptr, p,
10645 } 10667 nbytes, require);
10646 else 10668 nbytes = coding.produced;
10647 { 10669 nchars = coding.produced_char;
10648 /* We have to decode the input data. */ 10670 copy_bufptr = p;
10649 int require; 10671 }
10650 unsigned char *p;
10651
10652 require = decoding_buffer_size (&coding, nbytes);
10653 p = (unsigned char *) alloca (require);
10654 coding.mode |= CODING_MODE_LAST_BLOCK;
10655 decode_coding (&coding, copy_bufptr, p,
10656 nbytes, require);
10657 nbytes = coding.produced;
10658 nchars = coding.produced_char;
10659 copy_bufptr = p;
10660 }
10661 10672
10662 /* Convert the input data to a sequence of 10673 /* Convert the input data to a sequence of
10663 character events. */ 10674 character events. */
@@ -15080,6 +15091,11 @@ syms_of_xterm ()
15080 staticpro (&Qvendor_specific_keysyms); 15091 staticpro (&Qvendor_specific_keysyms);
15081 Qvendor_specific_keysyms = intern ("vendor-specific-keysyms"); 15092 Qvendor_specific_keysyms = intern ("vendor-specific-keysyms");
15082 15093
15094 staticpro (&Qutf_8);
15095 Qutf_8 = intern ("utf-8");
15096 staticpro (&Qlatin_1);
15097 Qlatin_1 = intern ("latin-1");
15098
15083 staticpro (&last_mouse_press_frame); 15099 staticpro (&last_mouse_press_frame);
15084 last_mouse_press_frame = Qnil; 15100 last_mouse_press_frame = Qnil;
15085 15101