aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2000-01-29 23:16:55 +0000
committerGerd Moellmann2000-01-29 23:16:55 +0000
commitf5d11644696d1ae7add77ba3ffb3618249b76dbe (patch)
tree9f293780249b339980a976d6f0d02aa25ab2ebb3
parent16215eb016237d7ff7260e10a7a832a37249f79f (diff)
downloademacs-f5d11644696d1ae7add77ba3ffb3618249b76dbe.tar.gz
emacs-f5d11644696d1ae7add77ba3ffb3618249b76dbe.zip
(x_display_cursor): Set XIC pre-edit area only if window
is its frame's selected window. (xim_instantiate_callback): Likewise. (XTread_socket) [HAVE_X_I18N]: If event is for none of our frames, call XFilterEvent with 2nd parameter `None'. (XTread_socket) <KeyPress> [HAVE_X_I18N]: Handle XmbLookupString returning XBufferOverflow. (XTread_socket) <ConfigureNotify> [HAVE_X_I18N]: Set XIC status area. (x_display_cursor) [HAVE_X_I18N]: Set XIC pre-edit area. (x_new_fontset) [HAVE_X_I18N]: Create XIC status area fontset. (xim_destroy_callback, xim_open_dpy, xim_instantiate_callback) (xim_initialize, xim_close) [HAVE_X_I18N && HAVE_X11R6]: New functions. (x_destroy_window) [HAVE_X_I18N]: Call xic_destroy_frame. (x_term_init) [HAVE_X_I18N]: Call xim_initialize. (x_delete_display) [HAVE_X_I18N]: Call xim_close.
-rw-r--r--src/xterm.c265
1 files changed, 245 insertions, 20 deletions
diff --git a/src/xterm.c b/src/xterm.c
index ddcca1cb1a5..3a1652e10d0 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8818,9 +8818,6 @@ XTread_socket (sd, bufp, numchars, expected)
8818 struct frame *f; 8818 struct frame *f;
8819 int event_found = 0; 8819 int event_found = 0;
8820 struct x_display_info *dpyinfo; 8820 struct x_display_info *dpyinfo;
8821#ifdef HAVE_X_I18N
8822 Status status_return;
8823#endif
8824 8821
8825 if (interrupt_input_blocked) 8822 if (interrupt_input_blocked)
8826 { 8823 {
@@ -8901,11 +8898,9 @@ XTread_socket (sd, bufp, numchars, expected)
8901 consumed the event. We pass the frame's X window to 8898 consumed the event. We pass the frame's X window to
8902 XFilterEvent because that's the one for which the IC 8899 XFilterEvent because that's the one for which the IC
8903 was created. */ 8900 was created. */
8904 struct frame *f1 8901 struct frame *f1 = x_any_window_to_frame (dpyinfo,
8905 = x_any_window_to_frame (dpyinfo, event.xclient.window); 8902 event.xclient.window);
8906 if (f1 8903 if (XFilterEvent (&event, f1 ? FRAME_X_WINDOW (f1) : None))
8907 && FRAME_XIC (f1)
8908 && XFilterEvent (&event, FRAME_X_WINDOW (f1)))
8909 break; 8904 break;
8910 } 8905 }
8911#endif 8906#endif
@@ -9338,10 +9333,24 @@ XTread_socket (sd, bufp, numchars, expected)
9338#ifdef HAVE_X_I18N 9333#ifdef HAVE_X_I18N
9339 if (FRAME_XIC (f)) 9334 if (FRAME_XIC (f))
9340 { 9335 {
9336 unsigned char *copy_bufptr = copy_buffer;
9337 int copy_bufsiz = sizeof (copy_buffer);
9338 Status status_return;
9339
9341 nbytes = XmbLookupString (FRAME_XIC (f), 9340 nbytes = XmbLookupString (FRAME_XIC (f),
9342 &event.xkey, copy_buffer, 9341 &event.xkey, copy_bufptr,
9343 80, &keysym, 9342 copy_bufsiz, &keysym,
9344 &status_return); 9343 &status_return);
9344 if (status_return == XBufferOverflow)
9345 {
9346 copy_bufsiz = nbytes + 1;
9347 copy_bufptr = (char *) alloca (copy_bufsiz);
9348 nbytes = XmbLookupString (FRAME_XIC (f),
9349 &event.xkey, copy_bufptr,
9350 copy_bufsiz, &keysym,
9351 &status_return);
9352 }
9353
9345 if (status_return == XLookupNone) 9354 if (status_return == XLookupNone)
9346 break; 9355 break;
9347 else if (status_return == XLookupChars) 9356 else if (status_return == XLookupChars)
@@ -9483,6 +9492,9 @@ XTread_socket (sd, bufp, numchars, expected)
9483 } 9492 }
9484 goto OTHER; 9493 goto OTHER;
9485 9494
9495 case KeyRelease:
9496 goto OTHER;
9497
9486 /* Here's a possible interpretation of the whole 9498 /* Here's a possible interpretation of the whole
9487 FocusIn-EnterNotify FocusOut-LeaveNotify mess. If 9499 FocusIn-EnterNotify FocusOut-LeaveNotify mess. If
9488 you get a FocusIn event, you have to get a FocusOut 9500 you get a FocusIn event, you have to get a FocusOut
@@ -9712,6 +9724,11 @@ XTread_socket (sd, bufp, numchars, expected)
9712 x_real_positions (f, &f->output_data.x->left_pos, 9724 x_real_positions (f, &f->output_data.x->left_pos,
9713 &f->output_data.x->top_pos); 9725 &f->output_data.x->top_pos);
9714 9726
9727#ifdef HAVE_X_I18N
9728 if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea))
9729 xic_set_statusarea (f);
9730#endif
9731
9715 if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) 9732 if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window)
9716 { 9733 {
9717 /* Since the WM decorations come below top_pos now, 9734 /* Since the WM decorations come below top_pos now,
@@ -10392,6 +10409,17 @@ x_display_cursor (w, on, hpos, vpos, x, y)
10392{ 10409{
10393 BLOCK_INPUT; 10410 BLOCK_INPUT;
10394 x_display_and_set_cursor (w, on, hpos, vpos, x, y); 10411 x_display_and_set_cursor (w, on, hpos, vpos, x, y);
10412
10413#ifdef HAVE_X_I18N
10414 {
10415 struct frame *f = XFRAME (w->frame);
10416
10417 if (w == XWINDOW (f->selected_window))
10418 if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMPreeditPosition))
10419 xic_set_preeditarea (w, x, y);
10420 }
10421#endif
10422
10395 UNBLOCK_INPUT; 10423 UNBLOCK_INPUT;
10396} 10424}
10397 10425
@@ -10891,8 +10919,204 @@ x_new_fontset (f, fontsetname)
10891 FS_LOAD_FONT (f, FRAME_X_FONT_TABLE (f), 10919 FS_LOAD_FONT (f, FRAME_X_FONT_TABLE (f),
10892 CHARSET_ASCII, fontsetp->fontname[CHARSET_ASCII], fontset); 10920 CHARSET_ASCII, fontsetp->fontname[CHARSET_ASCII], fontset);
10893 10921
10922#ifdef HAVE_X_I18N
10923 if (FRAME_XIC (f)
10924 && (FRAME_XIC_STYLE (f) & (XIMPreeditPosition | XIMStatusArea)))
10925 xic_set_xfontset (f, fontsetp->fontname[CHARSET_ASCII]);
10926#endif
10927
10894 return build_string (fontsetname); 10928 return build_string (fontsetname);
10895} 10929}
10930
10931
10932/***********************************************************************
10933 X Input Methods
10934 ***********************************************************************/
10935
10936#ifdef HAVE_X_I18N
10937
10938#ifdef HAVE_X11R6
10939
10940/* XIM destroy callback function, which is called whenever the
10941 connection to input method XIM dies. CLIENT_DATA contains a
10942 pointer to the x_display_info structure corresponding to XIM. */
10943
10944static void
10945xim_destroy_callback (xim, client_data, call_data)
10946 XIM xim;
10947 XPointer client_data;
10948 XPointer call_data;
10949{
10950 struct x_display_info *dpyinfo = (struct x_display_info *) client_data;
10951 Lisp_Object frame, tail;
10952
10953 BLOCK_INPUT;
10954
10955 /* No need to call XDestroyIC.. */
10956 FOR_EACH_FRAME (tail, frame)
10957 {
10958 struct frame *f = XFRAME (frame);
10959 if (FRAME_X_DISPLAY_INFO (f) == dpyinfo)
10960 {
10961 FRAME_XIC (f) = NULL;
10962 if (FRAME_XIC_FONTSET (f))
10963 {
10964 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
10965 FRAME_XIC_FONTSET (f) = NULL;
10966 }
10967 }
10968 }
10969
10970 /* No need to call XCloseIM. */
10971 dpyinfo->xim = NULL;
10972 XFree (dpyinfo->xim_styles);
10973 UNBLOCK_INPUT;
10974}
10975
10976#endif /* HAVE_X11R6 */
10977
10978/* Open the connection to the XIM server on display DPYINFO.
10979 RESOURCE_NAME is the resource name Emacs uses. */
10980
10981static void
10982xim_open_dpy (dpyinfo, resource_name)
10983 struct x_display_info *dpyinfo;
10984 char *resource_name;
10985{
10986 XIM xim;
10987
10988 xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name, EMACS_CLASS);
10989 dpyinfo->xim = xim;
10990
10991 if (xim)
10992 {
10993 XIMValuesList *xim_values_list;
10994#ifdef HAVE_X11R6
10995 XIMCallback destroy;
10996#endif
10997
10998 /* Get supported styles and XIM values. */
10999 XGetIMValues (xim, XNQueryInputStyle, &dpyinfo->xim_styles, NULL);
11000
11001#ifdef HAVE_X11R6
11002 destroy.callback = xim_destroy_callback;
11003 destroy.client_data = (XPointer)dpyinfo;
11004 XSetIMValues (xim, XNDestroyCallback, &destroy, NULL);
11005#endif
11006 }
11007}
11008
11009
11010#ifdef HAVE_X11R6
11011
11012struct xim_inst_t
11013{
11014 struct x_display_info *dpyinfo;
11015 char *resource_name;
11016};
11017
11018/* XIM instantiate callback function, which is called whenever an XIM
11019 server is available. DISPLAY is teh display of the XIM.
11020 CLIENT_DATA contains a pointer to an xim_inst_t structure created
11021 when the callback was registered. */
11022
11023static void
11024xim_instantiate_callback (display, client_data, call_data)
11025 Display *display;
11026 XPointer client_data;
11027 XPointer call_data;
11028{
11029 struct xim_inst_t *xim_inst = (struct xim_inst_t *) client_data;
11030 struct x_display_info *dpyinfo = xim_inst->dpyinfo;
11031
11032 /* We don't support multiple XIM connections. */
11033 if (dpyinfo->xim)
11034 return;
11035
11036 xim_open_dpy (dpyinfo, xim_inst->resource_name);
11037
11038 /* Create XIC for the existing frames on the same display, as long
11039 as they have no XIC. */
11040 if (dpyinfo->xim && dpyinfo->reference_count > 0)
11041 {
11042 Lisp_Object tail, frame;
11043
11044 BLOCK_INPUT;
11045 FOR_EACH_FRAME (tail, frame)
11046 {
11047 struct frame *f = XFRAME (frame);
11048
11049 if (FRAME_X_DISPLAY_INFO (f) == xim_inst->dpyinfo)
11050 if (FRAME_XIC (f) == NULL)
11051 {
11052 create_frame_xic (f);
11053 if (FRAME_XIC_STYLE (f) & XIMStatusArea)
11054 xic_set_statusarea (f);
11055 if (FRAME_XIC_STYLE (f) & XIMPreeditPosition)
11056 {
11057 struct window *w = XWINDOW (f->selected_window);
11058 xic_set_preeditarea (w, w->cursor.x, w->cursor.y);
11059 }
11060 }
11061 }
11062
11063 UNBLOCK_INPUT;
11064 }
11065}
11066
11067#endif /* HAVE_X11R6 */
11068
11069
11070/* Open a connection to the XIM server on display DPYINFO.
11071 RESOURCE_NAME is the resource name for Emacs. On X11R5, open the
11072 connection only at the first time. On X11R6, open the connection
11073 in the XIM instantiate callback function. */
11074
11075static void
11076xim_initialize (dpyinfo, resource_name)
11077 struct x_display_info *dpyinfo;
11078 char *resource_name;
11079{
11080#ifdef HAVE_X11R6
11081 struct xim_inst_t *xim_inst;
11082 int len;
11083
11084 dpyinfo->xim = NULL;
11085 xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t));
11086 xim_inst->dpyinfo = dpyinfo;
11087 len = strlen (resource_name);
11088 xim_inst->resource_name = (char *) xmalloc (len + 1);
11089 bcopy (resource_name, xim_inst->resource_name, len + 1);
11090 XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
11091 resource_name, EMACS_CLASS,
11092 xim_instantiate_callback,
11093 (XPointer)xim_inst);
11094#else /* not HAVE_X11R6 */
11095 dpyinfo->xim = NULL;
11096 xim_open_dpy (dpyinfo, resource_name);
11097#endif /* not HAVE_X11R6 */
11098}
11099
11100
11101/* Close the connection to the XIM server on display DPYINFO. */
11102
11103static void
11104xim_close_dpy (dpyinfo)
11105 struct x_display_info *dpyinfo;
11106{
11107#ifdef HAVE_X11R6
11108 XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
11109 NULL, EMACS_CLASS,
11110 xim_instantiate_callback, NULL);
11111#endif /* HAVE_X11R6 */
11112 XCloseIM (dpyinfo->xim);
11113 dpyinfo->xim = NULL;
11114 XFree (dpyinfo->xim_styles);
11115}
11116
11117#endif /* HAVE_X_I18N */
11118
11119
10896 11120
10897/* Calculate the absolute position in frame F 11121/* Calculate the absolute position in frame F
10898 from its current recorded position values and gravity. */ 11122 from its current recorded position values and gravity. */
@@ -11606,16 +11830,8 @@ x_destroy_window (f)
11606 if (f->output_data.x->icon_desc != 0) 11830 if (f->output_data.x->icon_desc != 0)
11607 XDestroyWindow (FRAME_X_DISPLAY (f), f->output_data.x->icon_desc); 11831 XDestroyWindow (FRAME_X_DISPLAY (f), f->output_data.x->icon_desc);
11608#ifdef HAVE_X_I18N 11832#ifdef HAVE_X_I18N
11609 if (FRAME_XIM (f)) 11833 if (FRAME_XIC (f))
11610 { 11834 free_frame_xic (f);
11611 XDestroyIC (FRAME_XIC (f));
11612#if ! defined (SOLARIS2) || defined (HAVE_X11R6)
11613 /* This line causes crashes on Solaris with Openwin,
11614 due to an apparent bug in XCloseIM.
11615 X11R6 seems not to have the bug. */
11616 XCloseIM (FRAME_XIM (f));
11617#endif
11618 }
11619#endif 11835#endif
11620 XDestroyWindow (FRAME_X_DISPLAY (f), f->output_data.x->window_desc); 11836 XDestroyWindow (FRAME_X_DISPLAY (f), f->output_data.x->window_desc);
11621#ifdef USE_X_TOOLKIT 11837#ifdef USE_X_TOOLKIT
@@ -12861,6 +13077,10 @@ x_term_init (display_name, xrm_option, resource_name)
12861 (unsigned long) 1, (unsigned long) 0, 1); 13077 (unsigned long) 1, (unsigned long) 0, 1);
12862 } 13078 }
12863 13079
13080#ifdef HAVE_X_I18N
13081 xim_initialize (dpyinfo, resource_name);
13082#endif
13083
12864#ifdef subprocesses 13084#ifdef subprocesses
12865 /* This is only needed for distinguishing keyboard and process input. */ 13085 /* This is only needed for distinguishing keyboard and process input. */
12866 if (connection != 0) 13086 if (connection != 0)
@@ -12964,6 +13184,11 @@ x_delete_display (dpyinfo)
12964 if (--dpyinfo->kboard->reference_count == 0) 13184 if (--dpyinfo->kboard->reference_count == 0)
12965 delete_kboard (dpyinfo->kboard); 13185 delete_kboard (dpyinfo->kboard);
12966#endif 13186#endif
13187#ifdef HAVE_X_I18N
13188 if (dpyinfo->xim)
13189 xim_close_dpy (dpyinfo);
13190#endif
13191
12967 xfree (dpyinfo->font_table); 13192 xfree (dpyinfo->font_table);
12968 xfree (dpyinfo->x_id_name); 13193 xfree (dpyinfo->x_id_name);
12969 xfree (dpyinfo); 13194 xfree (dpyinfo);