emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/xterm.c


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/src/xterm.c
Date: Tue, 16 Apr 2002 11:07:47 -0400

Index: emacs/src/xterm.c
diff -c emacs/src/xterm.c:1.721 emacs/src/xterm.c:1.722
*** emacs/src/xterm.c:1.721     Fri Apr 12 05:33:52 2002
--- emacs/src/xterm.c   Tue Apr 16 11:07:46 2002
***************
*** 394,399 ****
--- 394,400 ----
  static Lisp_Object Qalt, Qhyper, Qmeta, Qsuper, Qmodifier_value;
  
  static Lisp_Object Qvendor_specific_keysyms;
+ static Lisp_Object Qlatin_1, Qutf_8;
  
  extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *));
  extern Lisp_Object x_icon_type P_ ((struct frame *));
***************
*** 9935,9952 ****
  
    ++handling_signal;
    
-   /* The input should be decoded if it is from XIM.  Currently the
-      locale of XIM is the same as that of the system.  So, we can use
-      Vlocale_coding_system which is initialized properly at Emacs
-      startup time.  */
-   setup_coding_system (Vlocale_coding_system, &coding);
-   coding.src_multibyte = 0;
-   coding.dst_multibyte = 1;
-   /* The input is converted to events, thus we can't handle
-      composition.  Anyway, there's no XIM that gives us composition
-      information.  */
-   coding.composing = COMPOSITION_DISABLED;
- 
    /* Find the display we are supposed to read input for.
       It's the one communicating on descriptor SD.  */
    for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
--- 9936,9941 ----
***************
*** 10457,10462 ****
--- 10446,10452 ----
                  unsigned char *copy_bufptr = copy_buffer;
                  int copy_bufsiz = sizeof (copy_buffer);
                  int modifiers;
+                 Lisp_Object coding_system = Qlatin_1;
  
                  event.xkey.state
                    |= x_emacs_to_x_modifiers (FRAME_X_DISPLAY_INFO (f),
***************
*** 10486,10491 ****
--- 10476,10482 ----
                    {
                      Status status_return;
  
+                     coding_system = Vlocale_coding_system;
                      nbytes = XmbLookupString (FRAME_XIC (f),
                                                &event.xkey, copy_bufptr,
                                                copy_bufsiz, &keysym,
***************
*** 10499,10504 ****
--- 10490,10515 ----
                                                    copy_bufsiz, &keysym,
                                                    &status_return);
                        }
+ #ifdef X_HAVE_UTF8_STRING
+                     else if (status_return == XLookupKeySym)
+                       {  /* Try again but with utf-8.  */
+                         coding_system = Qutf_8;
+                         nbytes = Xutf8LookupString (FRAME_XIC (f),
+                                                     &event.xkey, copy_bufptr,
+                                                     copy_bufsiz, &keysym,
+                                                     &status_return);
+                         if (status_return == XBufferOverflow)
+                           {
+                             copy_bufsiz = nbytes + 1;
+                             copy_bufptr = (char *) alloca (copy_bufsiz);
+                             nbytes = Xutf8LookupString (FRAME_XIC (f),
+                                                         &event.xkey,
+                                                         copy_bufptr,
+                                                         copy_bufsiz, &keysym,
+                                                         &status_return);
+                           }
+                       }
+ #endif
  
                      if (status_return == XLookupNone)
                        break;
***************
*** 10625,10630 ****
--- 10636,10652 ----
                          register int c;
                          int nchars, len;
  
+                         /* The input should be decoded with `coding_system'
+                            which depends on which X*LookupString function
+                            we used just above and the locale.  */
+                         setup_coding_system (coding_system, &coding);
+                         coding.src_multibyte = 0;
+                         coding.dst_multibyte = 1;
+                         /* The input is converted to events, thus we can't
+                            handle composition.  Anyway, there's no XIM that
+                            gives us composition information.  */
+                         coding.composing = COMPOSITION_DISABLED;
+ 
                          for (i = 0; i < nbytes; i++)
                            {
                              if (temp_index == (sizeof temp_buffer
***************
*** 10633,10663 ****
                              temp_buffer[temp_index++] = copy_bufptr[i];
                            }
  
!                         if (/* If the event is not from XIM, */
!                             event.xkey.keycode != 0
!                             /* or the current locale doesn't request
!                                decoding of the intup data, ... */
!                             || coding.type == coding_type_raw_text
!                             || coding.type == coding_type_no_conversion)
!                           {
!                             /* ... we can use the input data as is.  */
!                             nchars = nbytes;
!                           }
!                         else
!                           { 
!                             /* We have to decode the input data.  */
!                             int require;
!                             unsigned char *p;
! 
!                             require = decoding_buffer_size (&coding, nbytes);
!                             p = (unsigned char *) alloca (require);
!                             coding.mode |= CODING_MODE_LAST_BLOCK;
!                             decode_coding (&coding, copy_bufptr, p,
!                                            nbytes, require);
!                             nbytes = coding.produced;
!                             nchars = coding.produced_char;
!                             copy_bufptr = p;
!                           }
  
                          /* Convert the input data to a sequence of
                             character events.  */
--- 10655,10674 ----
                              temp_buffer[temp_index++] = copy_bufptr[i];
                            }
  
!                         {
!                           /* Decode the input data.  */
!                           int require;
!                           unsigned char *p;
! 
!                           require = decoding_buffer_size (&coding, nbytes);
!                           p = (unsigned char *) alloca (require);
!                           coding.mode |= CODING_MODE_LAST_BLOCK;
!                           decode_coding (&coding, copy_bufptr, p,
!                                          nbytes, require);
!                           nbytes = coding.produced;
!                           nchars = coding.produced_char;
!                           copy_bufptr = p;
!                         }
  
                          /* Convert the input data to a sequence of
                             character events.  */
***************
*** 15079,15084 ****
--- 15090,15100 ----
  
    staticpro (&Qvendor_specific_keysyms);
    Qvendor_specific_keysyms = intern ("vendor-specific-keysyms");
+ 
+   staticpro (&Qutf_8);
+   Qutf_8 = intern ("utf-8");
+   staticpro (&Qlatin_1);
+   Qlatin_1 = intern ("latin-1");
  
    staticpro (&last_mouse_press_frame);
    last_mouse_press_frame = Qnil;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]