annotate src/input-method-xlib.c @ 359:8e84bee8ddd0 r21-1-9

Import from CVS: tag r21-1-9
author cvs
date Mon, 13 Aug 2007 10:57:55 +0200
parents 19dcec799385
children cc15677e0335
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1 /* Various functions for X11R5+ input methods, using the Xlib interface.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
2 Copyright (C) 1996 Sun Microsystems.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
3
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
4 This file is part of XEmacs.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
5
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
9 later version.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
10
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
14 for more details.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
15
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
20
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
22
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
23 /* Written by Martin Buchholz. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
24
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
25 /* This file implements an interface to X input methods, available
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
26 with X11R5 and above. See O'Reilly, Xlib programmer's guide,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
27 and X11 R6 release guide chapters on internationalized input,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
28 for further details */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
29
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
30 /*
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
31 Policy:
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
32
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
33 The XIM is of the device, by the device, for the device.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
34 The XIC is of each frame, by each frame, for each frame.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
35 The exceptions are:
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
36 1. Activate XICs on poor frames when the XIM is back.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
37 2. Deactivate all the XICs when the XIM go down.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
38
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
39 Methods:
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
40
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
41 - Register a callback for an XIM when the X device is being initialized.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
42 XIM_init_device (d) { XRegisterIMInstantiateCallback (); }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
43 The "XRegisterIMInstantiateCallback" is called when an XIM become
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
44 available on the X display.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
45
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
46 - Catch the XIC when the frame is being initialized if XIM was available.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
47 XIM_init_frame (f) { ... XCreateIC (); ... }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
48
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
49 - Release the XIC when the frame is being closed.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
50 XIM_delete_frame (f) { ... FRAME_X_XIC (f) = NULL; ... }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
51 "XIM_delete_frame" is a "DestroyCallback" function declared in
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
52 XIM_init_frame ();
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
53
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
54 - Release all the XICs when the XIM was down accidentally.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
55 In IMDestroyCallback:
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
56 DEVICE_FRAME_LOOP (...) { FRAME_X_XIC (f) = NULL; }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
57
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
58 - Re-enable XIC for all the frames which doesn't have XIC when the XIM
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
59 is back.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
60 In IMInstantiateCallback:
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
61 DEVICE_FRAME_LOOP (...) { XIM_init_frame (f); }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
62
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
63
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
64 Note:
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
65
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
66 - Currently, we don't use XDestroyIC because of _XimProtoCloseIM
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
67 (internally registered as im->methods->close) does "Xfree (ic)".
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
68
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
69 */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
70
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
71 #include <config.h>
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
72 #include "lisp.h"
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
73 #include <X11/Xlocale.h> /* More portable than <locale.h> ? */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
74 #include "frame.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
75 #include "device.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
76 #include "window.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
77 #include "buffer.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
78 #include "console-x.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
79 #include "EmacsFrame.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
80 #include "events.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
81
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
82 #ifdef THIS_IS_X11R6
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
83 #include <X11/IntrinsicP.h>
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
84 #include <X11/Xaw/XawImP.h>
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
85 #endif
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
86
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
87 #ifndef XIM_XLIB
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
88 #error XIM_XLIB is not defined??
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
89 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
90
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
91 Lisp_Object Qxim_xlib;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
92 #define xim_warn(str) warn_when_safe (Qxim_xlib, Qwarning, str);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
93 #define xim_warn1(fmt, str) warn_when_safe (Qxim_xlib, Qwarning, fmt, str);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
94 #define xim_info(str) warn_when_safe (Qxim_xlib, Qinfo, str);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
95
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
96 /* Get/Set IC values for just one attribute */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
97 #ifdef DEBUG_XEMACS
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
98 #define XIC_Value(Get_Set, xic, name, attr, value) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
99 do { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
100 char *bad_arg; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
101 XVaNestedList list = XVaCreateNestedList (0, attr, value, NULL); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
102 if ((bad_arg = X##Get_Set##ICValues (xic, name, list, NULL)) != NULL) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
103 stderr_out ("X" #Get_Set "ICValues " "bad Arg: %s\n", bad_arg); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
104 XFree (list); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
105 } while (0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
106 #else /* ! DEBUG_XEMACS */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
107 #define XIC_Value(Get_Set, xic, name, attr, value) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
108 do { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
109 XVaNestedList list = XVaCreateNestedList (0, attr, value, NULL); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
110 X##Get_Set##ICValues (xic, name, list, NULL); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
111 XFree (list); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
112 } while (0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
113 #endif /* DEBUG_XEMACS */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
114
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
115 static char DefaultXIMStyles[] =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
116 "XIMPreeditPosition|XIMStatusArea\n"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
117 "XIMPreeditPosition|XIMStatusNone\n"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
118 "XIMPreeditPosition|XIMStatusNothing\n"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
119 "XIMPreeditNothing|XIMStatusArea\n"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
120 "XIMPreeditNothing|XIMStatusNothing\n"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
121 "XIMPreeditNothing|XIMStatusNone\n"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
122 "XIMPreeditNone|XIMStatusArea\n"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
123 "XIMPreeditNone|XIMStatusNothing\n"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
124 "XIMPreeditNone|XIMStatusNone";
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
125
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
126 static Boolean xim_initted = False;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
127
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
128 static XIMStyle best_style (XIMStyles *user, XIMStyles *xim);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
129
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
130 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
131 Initialize_Locale (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
132 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
133 char *locale;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
134
321
19dcec799385 Import from CVS: tag r21-0-58
cvs
parents: 280
diff changeset
135 /* dverna - Nov. 98: ### DON'T DO THIS !!! The default XtLanguageProc
19dcec799385 Import from CVS: tag r21-0-58
cvs
parents: 280
diff changeset
136 routine calls setlocale(LC_ALL, lang) which fucks up our lower-level
19dcec799385 Import from CVS: tag r21-0-58
cvs
parents: 280
diff changeset
137 locale management, and especially the value of LC_NUMERIC. Anyway, since
19dcec799385 Import from CVS: tag r21-0-58
cvs
parents: 280
diff changeset
138 at this point, we don't know yet whether we're gonna need an X11 frame,
19dcec799385 Import from CVS: tag r21-0-58
cvs
parents: 280
diff changeset
139 we should really do it manually and not use Xlib's dumb default routine */
19dcec799385 Import from CVS: tag r21-0-58
cvs
parents: 280
diff changeset
140 /*XtSetLanguageProc (NULL, (XtLanguageProc) NULL, NULL);*/
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
141 if ((locale = setlocale (LC_ALL, "")) == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
142 {
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
143 xim_warn ("Can't set locale.\n"
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
144 "Using C locale instead.\n");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
145 putenv ("LANG=C");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
146 putenv ("LC_ALL=C");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
147 if ((locale = setlocale (LC_ALL, "C")) == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
148 {
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
149 xim_warn ("Can't even set locale to `C'!\n");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
150 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
151 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
152 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
153
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
154 if (!XSupportsLocale ())
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
155 {
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
156 xim_warn1 ("X Windows does not support locale `%s'\n"
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
157 "Using C Locale instead\n", locale);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
158 putenv ("LANG=C");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
159 putenv ("LC_ALL=C");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
160 if ((locale = setlocale (LC_ALL, "C")) == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
161 {
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
162 xim_warn ("Can't even set locale to `C'!\n");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
163 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
164 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
165 if (!XSupportsLocale ())
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
166 {
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
167 xim_warn ("X Windows does not even support locale `C'!\n");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
168 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
169 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
170 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
171
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 207
diff changeset
172 setlocale(LC_NUMERIC, "C");
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 207
diff changeset
173
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
174 if (XSetLocaleModifiers ("") == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
175 {
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
176 xim_warn ("XSetLocaleModifiers(\"\") failed\n"
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
177 "Check the value of the XMODIFIERS environment variable.\n");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
178 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
179 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
180
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
181 #ifdef THIS_IS_X11R6 /* Callbacks for IM are supported from X11R6 or later. */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
182 /* Called from when XIM is destroying.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
183 Clear all the XIC when the XIM was destroying... */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
184 static void
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
185 IMDestroyCallback (XIM im, XPointer client_data, XPointer call_data)
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
186 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
187 struct device *d = (struct device *)client_data;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
188 Lisp_Object tail;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
189
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
190 DEVICE_FRAME_LOOP (tail, d)
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
191 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
192 struct frame *target_frame = XFRAME (XCAR (tail));
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
193 if (FRAME_X_P (target_frame) && FRAME_X_XIC (target_frame))
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
194 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
195 /* XDestroyIC (FRAME_X_XIC (target_frame)); */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
196 FRAME_X_XIC (target_frame) = NULL;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
197 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
198 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
199
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
200 DEVICE_X_XIM (d) = NULL;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
201 xim_initted = False;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
202 return;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
203 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
204
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
205 /* This is registered in XIM_init_device (when DEVICE is initializing).
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
206 This activates XIM when XIM becomes available. */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
207 static void
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
208 IMInstantiateCallback (Display *dpy, XPointer client_data, XPointer call_data)
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
209 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
210 struct device *d = (struct device *)client_data;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
211 XIM xim;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
212 char *name, *class;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
213 XIMCallback ximcallback;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
214 Lisp_Object tail;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
215
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
216 /* if no xim is presented, initialize xim ... */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
217 if ( xim_initted == False )
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
218 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
219 xim_initted = True;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
220 XtGetApplicationNameAndClass (dpy, &name, &class);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
221 DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
222
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
223 /* destroy callback for im */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
224 ximcallback.callback = IMDestroyCallback;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
225 ximcallback.client_data = (XPointer) d;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
226 XSetIMValues (xim, XNDestroyCallback, &ximcallback, NULL);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
227 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
228
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
229 /* activate XIC on all the X frames... */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
230 DEVICE_FRAME_LOOP (tail, d)
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
231 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
232 struct frame *target_frame = XFRAME (XCAR (tail));
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
233 if (FRAME_X_P (target_frame) && !FRAME_X_XIC (target_frame))
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
234 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
235 XIM_init_frame (target_frame);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
236 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
237 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
238 return;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
239 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
240 #endif /* if THIS_IS_X11R6 */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
241
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
242 /* Initialize XIM for X device.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
243 Register the use of XIM using XRegisterIMInstantiateCallback. */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
244 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
245 XIM_init_device (struct device *d)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
246 {
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
247 #ifdef THIS_IS_X11R6
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
248 DEVICE_X_XIM (d) = NULL;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
249 XRegisterIMInstantiateCallback (DEVICE_X_DISPLAY (d), NULL, NULL, NULL,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
250 IMInstantiateCallback, (XPointer) d);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
251 return;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
252 #else
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
253 Display *dpy = DEVICE_X_DISPLAY (d);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
254 char *name, *class;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
255 XIM xim;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
256
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
257 XtGetApplicationNameAndClass (dpy, &name, &class);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
258 DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
259 if (xim == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
260 {
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
261 xim_warn ("XOpenIM() failed...no input server available\n");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
262 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
263 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
264 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
265 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
266 XGetIMValues (xim, XNQueryInputStyle, &DEVICE_X_XIM_STYLES (d), NULL);
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
267 return;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
268 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
269 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
270 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
271
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
272
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
273 /*
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
274 * For the frames
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
275 */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
276
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
277 /* Callback for the deleting frame. */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
278 static void
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
279 XIM_delete_frame (Widget w, XtPointer client_data, XtPointer call_data)
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
280 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
281 struct frame *f = (struct frame *) client_data;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
282 struct device *d = XDEVICE (FRAME_DEVICE (f));
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
283
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
284 if (DEVICE_X_XIM (d))
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
285 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
286 if (FRAME_X_XIC (f))
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
287 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
288 XDestroyIC (FRAME_X_XIC (f));
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
289 FRAME_X_XIC (f) = NULL;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
290 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
291 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
292 return;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
293 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
294
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
295 /* Initialize XIC for new frame.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
296 Create an X input context (XIC) for this frame. */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
297 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
298 XIM_init_frame (struct frame *f)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
299 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
300 struct device *d = XDEVICE (FRAME_DEVICE (f));
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
301 XIM xim;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
302 Widget w = FRAME_X_TEXT_WIDGET (f);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
303 Window win = XtWindow (w);
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
304 XRectangle p_area = {0,0,1,1}, s_area = {0,0,1,1};
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
305 XPoint spot = {0,0};
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
306 XIMStyle style;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
307 XVaNestedList p_list, s_list;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
308 typedef struct
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
309 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
310 XIMStyles styles;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
311 XFontSet fontset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
312 Pixel fg;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
313 Pixel bg;
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
314 char *inputmethod;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
315 } xic_vars_t;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
316 xic_vars_t xic_vars;
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
317 XIC xic;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
318
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
319 #define res(name, class, representation, field, default_value) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
320 { name, class, representation, sizeof(xic_vars.field), \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
321 XtOffsetOf(xic_vars_t, field), XtRString, default_value }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
322
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
323 static XtResource resources[] =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
324 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
325 /* name class represent'n field default value */
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
326 #ifdef THIS_IS_X11R6
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
327 res(XtNinputMethod, XtCInputMethod, XtRString, inputmethod, (XtPointer) NULL),
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
328 #endif
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
329 res(XtNximStyles, XtCXimStyles, XtRXimStyles, styles, (XtPointer) DefaultXIMStyles),
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
330 res(XtNfontSet, XtCFontSet, XtRFontSet, fontset, (XtPointer) XtDefaultFontSet),
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
331 res(XtNximForeground, XtCForeground, XtRPixel, fg, (XtPointer) XtDefaultForeground),
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
332 res(XtNximBackground, XtCBackground, XtRPixel, bg, (XtPointer) XtDefaultBackground)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
333 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
334
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
335
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
336 xim = DEVICE_X_XIM (d);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
337
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
338 if (!xim)
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
339 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
340 xim_info ("X Input Method open failed. Waiting for an XIM to be enabled.\n");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
341 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
342 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
343
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
344 w = FRAME_X_TEXT_WIDGET (f);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
345
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
346 /*
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
347 * initialize XIC
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
348 */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
349 if (FRAME_X_XIC (f)) return;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
350 XtGetApplicationResources (w, &xic_vars,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
351 resources, XtNumber (resources),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
352 NULL, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
353 if (!xic_vars.fontset)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
354 {
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
355 xim_warn ("Can't get fontset resource for Input Method\n");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
356 FRAME_X_XIC (f) = NULL;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
357 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
358 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
359
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
360 /* construct xic */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
361 XGetIMValues (xim, XNQueryInputStyle, &DEVICE_X_XIM_STYLES(d), NULL);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
362 FRAME_X_XIC_STYLE (f) = style =
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
363 best_style (&xic_vars.styles, (XIMStyles *)DEVICE_X_XIM_STYLES(d));
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
364
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
365 p_list = XVaCreateNestedList (0,
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
366 XNArea, &p_area,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
367 XNSpotLocation, &spot,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
368 XNForeground, xic_vars.fg,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
369 XNBackground, xic_vars.bg,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
370 XNFontSet, xic_vars.fontset,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
371 NULL);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
372
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
373 s_list = XVaCreateNestedList (0,
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
374 XNArea, &s_area,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
375 XNForeground, xic_vars.fg,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
376 XNBackground, xic_vars.bg,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
377 XNFontSet, xic_vars.fontset,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
378 NULL);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
379
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
380 FRAME_X_XIC (f) = xic =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
381 XCreateIC (xim,
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
382 XNInputStyle, style,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
383 XNClientWindow, win,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
384 XNFocusWindow, win,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
385 XNPreeditAttributes, p_list,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
386 XNStatusAttributes, s_list,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
387 NULL);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
388 XFree (p_list);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
389 XFree (s_list);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
390
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
391 if (!xic)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
392 {
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
393 xim_warn ("Warning: XCreateIC failed.\n");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
394 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
395 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
396
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
397 if (style & XIMPreeditPosition)
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
398 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
399 XPoint *frame_spot = &(FRAME_X_XIC_SPOT(f));
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 267
diff changeset
400 frame_spot->x = frame_spot->y = -1;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
401 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
402
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
403 XIM_SetGeometry (f);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
404
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
405 XSetICFocus (xic);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
406
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
407 #ifdef THIS_IS_X11R6
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
408 /* when frame is going to be destroyed (closed) */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
409 XtAddCallback (FRAME_X_TEXT_WIDGET(f), XNDestroyCallback,
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
410 XIM_delete_frame, (XtPointer)f);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
411 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
412 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
413
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
414
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
415 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
416 XIM_SetGeometry (struct frame *f)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
417 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
418 XIC xic = FRAME_X_XIC (f);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
419 XIMStyle style = FRAME_X_XIC_STYLE (f);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
420 XRectangle area;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
421
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
422 if (!xic || !f)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
423 return;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
424
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
425 if (style & XIMStatusArea)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
426 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
427 /* Place Status Area in bottom right corner */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
428 /* Negotiate geometry of status area */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
429 /* See O'Reilly Xlib XIM chapter (but beware, it's buggy) */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
430 XRectangle *needed;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
431
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
432 /* If input method has existing status area, use its current size */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
433 /* The following at least works for Sun's htt */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
434 area.x = area.y = area.width = area.height = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
435 XIC_Value (Set, xic, XNStatusAttributes, XNAreaNeeded, &area);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
436 XIC_Value (Get, xic, XNStatusAttributes, XNAreaNeeded, &needed);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
437 if (needed->width == 0) /* Use XNArea instead of XNAreaNeeded */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
438 XIC_Value (Get, xic, XNStatusAttributes, XNArea, &needed);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
439
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
440 area.width = needed->width;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
441 area.height = needed->height;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
442 area.x = FRAME_RIGHT_BORDER_START (f) - area.width;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
443 area.y = FRAME_BOTTOM_BORDER_START (f) - area.height;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
444
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
445 #ifdef DEBUG_XIM
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
446 stderr_out ("Putting StatusArea in x=%d y=%d w=%d h=%d\n",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
447 area.x, area.y, area.width, area.height);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
448 #endif /* DEBUG_XIM */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
449
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
450 XIC_Value (Set, xic, XNStatusAttributes, XNArea, &area);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
451 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
452
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
453 if (style & XIMPreeditPosition)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
454 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
455 /* Set Preedit Area to whole frame size (sans border) */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
456 /* We include the border because Preedit window might be larger
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
457 than display line at edge. #### FIX: we should adjust to make
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
458 sure that there is always room for the spot sub-window */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
459 area.x = FRAME_LEFT_BORDER_START (f);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
460 area.y = FRAME_TOP_BORDER_START (f);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
461 area.width = FRAME_RIGHT_BORDER_END (f) - area.x;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
462 area.height = FRAME_BOTTOM_BORDER_END (f) - area.y;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
463 XIC_Value(Set, xic, XNPreeditAttributes, XNArea, &area);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
464 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
465
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
466 #ifdef DEBUG_XIM
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
467 describe_XIC (xic);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
468 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
469 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
470
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
471 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
472 XIM_SetSpotLocation (struct frame *f, int x, int y)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
473 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
474 XIC xic = FRAME_X_XIC (f);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
475 XPoint *spot = &(FRAME_X_XIC_SPOT (f));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
476
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
477 /* Only care if we have a valid XIC using Over the Spot in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
478 * a different location */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
479 if (!xic ||
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
480 !(FRAME_X_XIC_STYLE (f) & XIMPreeditPosition) ||
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
481 (spot->x == (short) x &&
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
482 spot->y == (short) y))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
483 return;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
484
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
485 spot->x = (short) x;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
486 spot->y = (short) y;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
487
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
488 /* ### FIX: Must make sure spot fits within Preedit Area */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
489 XIC_Value (Set, xic, XNPreeditAttributes, XNSpotLocation, spot);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
490 #ifdef DEBUG_XIM
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
491 stderr_out ("Spot: %d %d\n", spot->x, spot->y);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
492 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
493 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
494
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
495 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
496 XIM_focus_event (struct frame *f, int in_p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
497 {
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
498 if (FRAME_X_XIC (f) /* && FRAME_X_XIM_REGISTERED(f) */)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
499 (in_p ? XSetICFocus : XUnsetICFocus) (FRAME_X_XIC (f));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
500 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
501
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
502 #if 0
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
503 #define XIM_Composed_Text_BUFSIZE 64
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
504 typedef struct XIM_Composed_Text
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
505 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
506 int size;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
507 wchar_t data [XIM_Composed_Text_BUFSIZE];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
508 } XIM_Composed_Text;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
509
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
510 static XIM_Composed_Text composed_input_buf = {XIM_Composed_Text_BUFSIZE, {0}};
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
511 Window main_window;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
512
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
513 /* get_XIM_input -- Process results of input method composition.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
514
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
515 This function copies the results of the input method composition to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
516 composed_input_buf. Then for each character, a custom event of type
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
517 wc_atom is sent with the character as its data.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
518
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
519 It is probably more efficient to copy the composition results to some
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
520 allocated memory and send a single event pointing to that memory.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
521 That would cut down on the event processing as well as allow quick
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
522 insertion into the buffer of the whole string. It might require some
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
523 care, though, to avoid fragmenting memory through the allocation and
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
524 freeing of many small chunks. Maybe the existing system for
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
525 (single-byte) string allocation can be used, multiplying the length by
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
526 sizeof (wchar_t) to get the right size.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
527 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
528 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
529 get_XIM_input (XKeyPressedEvent *x_key_event, XIC ic, Display *dpy)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
530 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
531 KeySym keysym;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
532 Status status;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
533 int len;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
534 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
535 XClientMessageEvent new_event;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
536
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
537 retry:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
538 len = XwcLookupString (ic, x_key_event, composed_input_buf.data,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
539 composed_input_buf.size, &keysym, &status);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
540 switch (status)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
541 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
542 case XBufferOverflow:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
543 /* GROW_WC_STRING (&composed_input_buf, 32); mrb */
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
544 goto retry;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
545 case XLookupChars:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
546 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
547 default:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
548 abort ();
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
549 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
550
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
551 new_event.type = ClientMessage;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
552 new_event.display = x_key_event->display;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
553 new_event.window = x_key_event->window;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
554 new_event.message_type = wc_atom;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
555 new_event.format = 32; /* 32-bit wide data */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
556 new_event.data.l[2] = new_event.data.l[3] = new_event.data.l[4] = 0L;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
557 new_event.data.l[0] = x_key_event->time;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
558 for (i = 0; i < len; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
559 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
560 new_event.data.l[1] = ((wchar_t *) composed_input_buf.data)[i];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
561 XSendEvent (display, main_window, False, 0L, (XEvent *) &new_event);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
562 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
563 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
564 #endif /* 0 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
565
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
566 /* ============================================================== */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
567 /* X input method style determination */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
568 /* ============================================================== */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
569
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
570 #if 0
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
571 #define done(type, value) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
572 if (toVal->addr != NULL) { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
573 if (toVal->size < sizeof(type)) { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
574 toVal->size = sizeof(type); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
575 return False; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
576 } \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
577 *(type*)toVal->addr = (value); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
578 } else { \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
579 static type static_val; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
580 static_val = (value); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
581 toVal->addr = (XPointer)&static_val; \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
582 } \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
583 toVal->size = sizeof(type); \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
584 return True /* Caller supplies `;' */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
585 #endif /* 0 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
586
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
587 /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
588 * This is a standard Xt type converter, except that the caller MUST
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
589 * supply a proper non-NULL toVal XIMStyles structure that we will
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
590 * fill in.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
591 *
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
592 * fromVal points to a string like
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
593 *
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
594 "XIMPreeditPosition|XIMStatusArea,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
595 XIMPreeditPosition|XIMStatusNothing
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
596 XIMPreeditNothing|XIMStatusNothing"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
597 *
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
598 * This is converted in the obvious way to a XIMStyles structure.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
599 *
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
600 * mrb: #### Fix this to handle Motif-style specifications for
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
601 * XIMStyles as well: overTheSpot, rootWindow, none */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
602
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
603 /* XtTypeConverter */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
604 Boolean
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
605 EmacsXtCvtStringToXIMStyles (
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
606 Display *dpy,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
607 XrmValuePtr args,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
608 Cardinal *num_args,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
609 XrmValuePtr fromVal,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
610 XrmValuePtr toVal,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
611 XtPointer *converter_data)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
612 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
613 #define STYLE_INFO(style) { style, #style, sizeof(#style) }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
614 static struct XIMStyleInfo
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
615 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
616 CONST XIMStyle style;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
617 CONST char * CONST name;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
618 CONST int namelen;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
619 } emacs_XIMStyleInfo[] = {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
620 STYLE_INFO (XIMPreeditPosition|XIMStatusArea),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
621 STYLE_INFO (XIMPreeditPosition|XIMStatusNothing),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
622 STYLE_INFO (XIMPreeditPosition|XIMStatusNone),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
623 STYLE_INFO (XIMPreeditNothing|XIMStatusArea),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
624 STYLE_INFO (XIMPreeditNothing|XIMStatusNothing),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
625 STYLE_INFO (XIMPreeditNothing|XIMStatusNone),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
626 STYLE_INFO (XIMPreeditNone|XIMStatusArea),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
627 STYLE_INFO (XIMPreeditNone|XIMStatusNothing),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
628 STYLE_INFO (XIMPreeditNone|XIMStatusNone)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
629 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
630 #undef STYLE_INFO
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
631
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 267
diff changeset
632 char *s = (char *) fromVal->addr;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 267
diff changeset
633 char *end = s + fromVal->size;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
634 XIMStyles * CONST p = (XIMStyles *) toVal->addr;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
635 CONST char * CONST delimiter = " \t\n\r:;," ;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
636 CONST int max_styles = XtNumber(emacs_XIMStyleInfo);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
637 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
638 char *c;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
639
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
640 #ifdef DEBUG_XIM
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
641 stderr_out ("EmacsCvtStringToXIMStyles called with size=%d, string=\"%s\"\n",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
642 fromVal->size, (char *) fromVal->addr);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
643 #endif /* DEBUG_XIM */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
644
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
645 if (*num_args != 0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
646 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
647 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
648 XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
649 "XtToolkitError",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
650 "String to XIMStyle conversion requires exactly 0 parameters",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
651 (String *)NULL, (Cardinal *)NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
652 return False;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
653 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
654
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
655 #ifdef DEBUG_XEMACS
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
656 /* Make sure caller is giving us good data */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
657 assert (fromVal->addr != NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
658 assert (fromVal->size == strlen(fromVal->addr)+1);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
659 assert (toVal->addr != NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
660 assert (toVal->size == sizeof(XIMStyles));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
661 #endif /* DEBUG_XEMACS */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
662
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
663 p->count_styles = 0;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
664 p->supported_styles = xnew_array (XIMStyle, max_styles);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
665
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
666 /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
667 * The following routine assumes that the style name resource is
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
668 * identical with the programmatic name of style. For example,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
669 * "XIMPreeditPosition|XIMStatusArea" means the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
670 * XIMPreeditPosition|XIMStatusArea value is specified. If the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
671 * style name is changed, such as "OverTheSpot|imDisplaysInClient",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
672 * the parsing logic below should be modified as well. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
673
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
674 if ((c = strtok(s, delimiter)) == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
675 c = end;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
676
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
677 while (c < end)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
678 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
679 for(i=0 ; i<max_styles ; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
680 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
681 struct XIMStyleInfo *rec = emacs_XIMStyleInfo + i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
682 if(!strncmp(c, rec->name, rec->namelen - 1)) {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
683 p->supported_styles[p->count_styles] = rec->style;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
684 p->count_styles++;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
685 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
686 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
687 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
688 if((c = strtok(NULL, delimiter)) == NULL) {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
689 break ;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
690 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
691 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
692
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
693 if (p->count_styles == 0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
694 { /* No valid styles? */
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 223
diff changeset
695 char *buf = (char *)alloca (strlen (fromVal->addr)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 223
diff changeset
696 + strlen (DefaultXIMStyles)
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 223
diff changeset
697 + 100);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
698 XrmValue new_from;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
699 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
700
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
701 sprintf(buf, "Cannot convert string \"%s\" to type XIMStyles.\n"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
702 "Using default string \"%s\" instead.\n",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
703 fromVal->addr, DefaultXIMStyles);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
704 XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
705 "XtToolkitError",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
706 buf, (String *)NULL, (Cardinal *)NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
707 new_from.addr = DefaultXIMStyles;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
708 new_from.size = sizeof(DefaultXIMStyles);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
709 return EmacsXtCvtStringToXIMStyles (dpy, args, num_args,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
710 &new_from, toVal, converter_data);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
711 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
712 XREALLOC_ARRAY (p->supported_styles, XIMStyle, p->count_styles);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
713 *converter_data = (char *) True;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
714 return True;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
715 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
716
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
717 /* XtDestructor */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
718 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
719 EmacsFreeXIMStyles (
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
720 XtAppContext app,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
721 XrmValuePtr toVal,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
722 XtPointer converter_data,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
723 XrmValuePtr args,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
724 Cardinal *num_args)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
725 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
726 #ifdef DEBUG_XIM
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
727 stderr_out ("Converter data: %x\n", converter_data);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
728 stderr_out ("EmacsFreeXIMStyles called\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
729 #endif /* DEBUG_XIM */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
730
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
731 if (*num_args != 0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
732 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
733 XtAppWarningMsg(app, "wrongParameters","freeXIMStyles","XtToolkitError",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
734 "Freeing an XIMStyles requires that zero arguments be passwd",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
735 (String *)NULL, (Cardinal *)NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
736 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
737 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
738
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
739 if (converter_data)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
740 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
741 Boolean free_p = (Boolean) (int) converter_data;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
742 XIMStyles *styles = (XIMStyles *) toVal->addr;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
743 if (free_p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
744 XFree ( styles->supported_styles );
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
745 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
746 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
747
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
748 #if 0
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
749 /* O'Reilly XLib Programming Manual, pg. 371 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
750 /* Much nicer implementation than O'Reilly */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
751 /* Choose the more `complicated', hence nicer, XIM input style */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
752 static XIMStyle
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
753 BetterStyle (XIMStyle s, XIMStyle t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
754 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
755 #define CHECK_XIMStyle_BIT(bit) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
756 if ((s ^ t) & bit) { return (s & bit) ? s : t; }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
757
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
758 CHECK_XIMStyle_BIT (XIMPreeditCallbacks);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
759 CHECK_XIMStyle_BIT (XIMPreeditPosition);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
760 CHECK_XIMStyle_BIT (XIMPreeditArea);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
761 CHECK_XIMStyle_BIT (XIMPreeditNothing);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
762 CHECK_XIMStyle_BIT (XIMStatusCallbacks);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
763 CHECK_XIMStyle_BIT (XIMStatusArea);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
764 CHECK_XIMStyle_BIT (XIMStatusNothing);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
765 #undef CHECK_XIMStyle_BIT
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
766 return s ? s : t ;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
767 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
768 #endif /* 0 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
769
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
770 /* Choose the best style, given:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
771 * - user preferences (already checked to be supported by XEmacs)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
772 * - styles supported by the input method */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
773 #define DEFAULTStyle (XIMPreeditNothing|XIMStatusNothing)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
774 static XIMStyle
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
775 best_style (XIMStyles *user, XIMStyles *xim)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
776 {
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 185
diff changeset
777 REGISTER int i, j;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
778 for (i=0 ; i<user->count_styles ; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
779 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
780 for (j=0 ; j<xim->count_styles ; j++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
781 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
782 if (user->supported_styles[i] == xim->supported_styles[j])
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
783 return user->supported_styles[i];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
784 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
785 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
786 return DEFAULTStyle; /* Default Style */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
787 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
788
359
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
789 /* These lisp-callable functions will be sealed until xim-leim is needed.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
790 Oct 22 1999 - kazz */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
791 #if 0
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
792 /*
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
793 * External callable function for XIM
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
794 */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
795 DEFUN ("x-open-xim", Fx_open_xim, 1, 1, 0, /*
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
796 Open the XIC on the frame if XIM is available.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
797 Commonly, use this as \(x-open-xim \(selected-frame)).
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
798 If the frame is not on X device, return signal.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
799 If XIC is created successfully return t. If not return nil.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
800 */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
801 (frame))
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
802 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
803 struct frame *f;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
804
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
805 CHECK_LIVE_FRAME (frame);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
806 f = XFRAME (frame);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
807 if (!FRAME_X_P (f))
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
808 return signal_simple_error ("This frame is not on X device", frame);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
809
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
810 XIM_init_frame (f);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
811 return FRAME_X_XIC (f) ? Qt : Qnil;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
812 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
813
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
814 DEFUN ("x-close-xim", Fx_close_xim, 1, 1, 0, /*
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
815 Close the XIC on the frame if it exists.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
816 Commonly, use this as \(x-close-xim \(selected-frame)).
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
817 If the frame is not on X device, return signal.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
818 Otherwise, it destroys the XIC if it exists, then returns t anyway.
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
819 */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
820 (frame))
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
821 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
822 struct frame *f;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
823 struct device *d;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
824
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
825 CHECK_LIVE_FRAME (frame);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
826 f = XFRAME (frame);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
827 if (!FRAME_X_P (f))
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
828 return signal_simple_error ("This frame is not on X device", frame);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
829
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
830 d = XDEVICE (FRAME_DEVICE (f));
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
831 if (DEVICE_X_XIM (d)) {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
832 /* XDestroyIC (FRAME_X_XIC (XFRAME (f))); */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
833 FRAME_X_XIC (XFRAME (f)) = NULL;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
834 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
835 return Qt;
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
836 }
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
837 #endif /* if 0 */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
838
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
839 void
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
840 syms_of_input_method_xlib (void)
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
841 {
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
842 defsymbol (&Qxim_xlib, "xim-xlib");
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
843 #if 0 /* see above */
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
844 DEFSUBR (Fx_open_xim);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
845 DEFSUBR (Fx_close_xim);
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
846 #endif
8e84bee8ddd0 Import from CVS: tag r21-1-9
cvs
parents: 321
diff changeset
847 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
848
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
849 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
850 vars_of_input_method_xlib (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
851 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
852 Fprovide (intern ("xim"));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
853 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
854
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
855
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
856 /* ====================================================================== */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
857 /* Internal Debugging Routines */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
858 /* ====================================================================== */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
859 #ifdef DEBUG_XEMACS
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
860
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
861 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
862 describe_XIM (XIM xim)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
863 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
864 XIMStyles *styles;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
865
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
866 /* Print locale of XIM */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
867 stderr_out ("\nXIM Locale of IM: %s\n", XLocaleOfIM(xim));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
868
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
869 /* List supported input method styles */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
870 XGetIMValues(xim, XNQueryInputStyle, &styles, NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
871
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
872 stderr_out ("\n%d input style(s) supported by input method.\n",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
873 styles->count_styles);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
874
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
875 #ifdef DEBUG_XIM
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
876 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
877 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
878 for (i=0; i < styles->count_styles; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
879 describe_XIMStyle (styles->supported_styles[i]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
880 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
881 #endif /* DEBUG_XIM */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
882 XFree(styles);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
883 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
884
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
885 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
886 describe_XFontSet (XFontSet fontset)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
887 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
888 XFontStruct **font_struct_list;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
889 char **font_name_list;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
890 int count, i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
891
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
892 if (fontset == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
893 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
894 stderr_out ("NULL\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
895 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
896 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
897
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
898 count = XFontsOfFontSet (fontset, &font_struct_list, &font_name_list);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
899 stderr_out ( "%d font(s) available:\n", count);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
900 for (i=0 ; i < count ; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
901 stderr_out ("Font: %s\n", *(font_name_list+i));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
902 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
903
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
904 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
905 describe_Status (Status status)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
906 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
907 #define DESCRIBE_STATUS(value) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
908 if (status == value) stderr_out ("Status: " #value "\n")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
909
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
910 DESCRIBE_STATUS (XBufferOverflow);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
911 DESCRIBE_STATUS (XLookupNone);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
912 DESCRIBE_STATUS (XLookupKeySym);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
913 DESCRIBE_STATUS (XLookupBoth);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
914 DESCRIBE_STATUS (XLookupChars);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
915 #undef DESCRIBE_STATUS
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
916 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
917
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
918 void
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
919 describe_Window (Window win)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
920 {
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 223
diff changeset
921 char xwincmd[128];
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
922 sprintf (xwincmd, "xwininfo -id 0x%x >&2; xwininfo -events -id 0x%x >&2",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
923 (int) win, (int) win);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
924 system (xwincmd);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
925 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
926
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
927 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
928 describe_XIC (XIC xic)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
929 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
930 XIMStyle style;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
931 Window client_win=0, focus_win=0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
932 char *resourceName = NULL;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
933 char *resourceClass = NULL;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
934 char *bad_arg = NULL;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
935 unsigned long filter_mask = NoEventMask;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
936 XVaNestedList p_list, s_list;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
937 XFontSet p_fontset = NULL, s_fontset = NULL;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
938 Pixel p_fg=0, p_bg = 0, s_fg=0, s_bg = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
939 XRectangle *p_area = NULL, *s_area = NULL;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
940 XRectangle *p_needed = NULL, *s_needed = NULL;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
941 XPoint *p_spot = NULL;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
942
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
943 /* Check for valid input context and method */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
944 if (!xic)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
945 stderr_out ("Input method is NULL\n");
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
946
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
947 if (!XIMOfIC(xic))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
948 stderr_out ("XIMOfIC() returns NULL\n");
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
949
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
950 /* Print out Input Context Attributes */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
951 p_list = XVaCreateNestedList (0,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
952 XNFontSet, &p_fontset,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
953 XNArea, &p_area,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
954 XNAreaNeeded, &p_needed,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
955 XNSpotLocation, &p_spot,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
956 XNForeground, &p_fg,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
957 XNBackground, &p_bg,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
958 NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
959
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
960 s_list = XVaCreateNestedList (0,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
961 XNFontSet, &s_fontset,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
962 XNArea, &s_area,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
963 XNAreaNeeded, &s_needed,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
964 XNForeground, &s_fg,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
965 XNBackground, &s_bg,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
966 NULL);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
967
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
968 bad_arg = XGetICValues(xic,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
969 XNInputStyle, &style,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
970 XNFilterEvents, &filter_mask,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
971 XNClientWindow, &client_win,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
972 XNFocusWindow, &focus_win,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
973 XNResourceName, &resourceName,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
974 XNResourceClass, &resourceClass,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
975 XNPreeditAttributes, p_list,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
976 XNStatusAttributes, s_list,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
977 NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
978 XFree(p_list);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
979 XFree(s_list);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
980
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
981 if (bad_arg != NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
982 stderr_out ("Couldn't get IC value: %s\n", bad_arg);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
983
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
984 stderr_out ("\nInput method context attributes:\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
985 stderr_out ("Style: "); describe_XIMStyle (style);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 207
diff changeset
986 stderr_out ("Client window: %lx\n", (unsigned long int)client_win);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 207
diff changeset
987 stderr_out ("Focus window: %lx\n", (unsigned long int)focus_win);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
988 stderr_out ("Preedit:\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
989 describe_XRectangle (" Area", p_area);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
990 describe_XRectangle (" Area needed", p_needed);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 207
diff changeset
991 stderr_out (" foreground: %lx\n", (unsigned long int)p_fg);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 207
diff changeset
992 stderr_out (" background: %lx\n", (unsigned long int)p_bg);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
993 stderr_out (" fontset: "); describe_XFontSet (p_fontset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
994 stderr_out ("Status:\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
995 describe_XRectangle (" Area", s_area);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
996 describe_XRectangle (" Area needed", s_needed);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 207
diff changeset
997 stderr_out (" foreground: %lx\n", (unsigned long int)s_fg);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 207
diff changeset
998 stderr_out (" background: %lx\n", (unsigned long int)s_bg);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
999 stderr_out (" fontset: \n"); describe_XFontSet (s_fontset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1000 stderr_out ("XNResourceName: %s\n", resourceName ? resourceName : "NULL");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1001 stderr_out ("XNResourceClass: %s\n", resourceClass ? resourceClass : "NULL");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1002 stderr_out ("XNFilterEvents: "); describe_event_mask (filter_mask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1003 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1004
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1005 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1006 describe_XRectangle (char *name, XRectangle *r)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1007 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1008 if (r == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1009 stderr_out ("%s: NULL\n", name);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1010 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1011 stderr_out ("%s: x=%d y=%d w=%d h=%d\n",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1012 name, r->x, r->y, r->width, r->height);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1013 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1014
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1015 /* Print out elements of Event mask */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1016 /* Defines from X11/X.h */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1017 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1018 describe_event_mask (unsigned long mask)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1019 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1020 #define DESCRIBE_EVENT_MASK(bit) if ((bit) & mask) stderr_out (#bit " ")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1021 DESCRIBE_EVENT_MASK (NoEventMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1022 DESCRIBE_EVENT_MASK (KeyPressMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1023 DESCRIBE_EVENT_MASK (KeyReleaseMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1024 DESCRIBE_EVENT_MASK (ButtonPressMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1025 DESCRIBE_EVENT_MASK (ButtonReleaseMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1026 DESCRIBE_EVENT_MASK (EnterWindowMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1027 DESCRIBE_EVENT_MASK (LeaveWindowMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1028 DESCRIBE_EVENT_MASK (PointerMotionMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1029 DESCRIBE_EVENT_MASK (PointerMotionHintMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1030 DESCRIBE_EVENT_MASK (Button1MotionMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1031 DESCRIBE_EVENT_MASK (Button2MotionMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1032 DESCRIBE_EVENT_MASK (Button3MotionMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1033 DESCRIBE_EVENT_MASK (Button4MotionMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1034 DESCRIBE_EVENT_MASK (Button5MotionMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1035 DESCRIBE_EVENT_MASK (ButtonMotionMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1036 DESCRIBE_EVENT_MASK (KeymapStateMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1037 DESCRIBE_EVENT_MASK (ExposureMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1038 DESCRIBE_EVENT_MASK (VisibilityChangeMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1039 DESCRIBE_EVENT_MASK (StructureNotifyMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1040 DESCRIBE_EVENT_MASK (ResizeRedirectMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1041 DESCRIBE_EVENT_MASK (SubstructureNotifyMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1042 DESCRIBE_EVENT_MASK (SubstructureRedirectMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1043 DESCRIBE_EVENT_MASK (FocusChangeMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1044 DESCRIBE_EVENT_MASK (PropertyChangeMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1045 DESCRIBE_EVENT_MASK (ColormapChangeMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1046 DESCRIBE_EVENT_MASK (OwnerGrabButtonMask);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1047 #undef DESCRIBE_EVENT_MASK
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1048 stderr_out("\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1049 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1050
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1051 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1052 describe_XIMStyle (XIMStyle style)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1053 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1054 #define DESCRIBE_STYLE(bit) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1055 if (bit & style) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1056 stderr_out (#bit " ");
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
1057
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1058 DESCRIBE_STYLE (XIMPreeditArea);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1059 DESCRIBE_STYLE (XIMPreeditCallbacks);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1060 DESCRIBE_STYLE (XIMPreeditPosition);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1061 DESCRIBE_STYLE (XIMPreeditNothing);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1062 DESCRIBE_STYLE (XIMPreeditNone);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1063 DESCRIBE_STYLE (XIMStatusArea);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1064 DESCRIBE_STYLE (XIMStatusCallbacks);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1065 DESCRIBE_STYLE (XIMStatusNothing);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1066 DESCRIBE_STYLE (XIMStatusNone);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1067 #undef DESCRIBE_STYLE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1068 stderr_out("\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1069 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1070
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1071 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1072 describe_XIMStyles (XIMStyles *p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1073 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1074 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1075 stderr_out ("%d Style(s):\n", p->count_styles);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1076 for (i=0; i<p->count_styles ; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1077 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1078 describe_XIMStyle (p->supported_styles[i]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1079 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1080 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1081
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1082 #endif /* DEBUG_XEMACS */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1083
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1084 /* Random cruft follows */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1085
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1086 #if 0
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1087 static void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1088 Unit_Test (struct frame *f, char * s)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1089 /* mrb unit testing */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1090 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1091 XrmValue fromVal, toVal;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1092
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1093 fromVal.addr = s;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1094 fromVal.size = strlen (s);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1095 toVal.addr = (XtPointer) &user_preferred_XIMStyles;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1096 toVal.size = sizeof (XIMStyles);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
1097
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1098 if (XtConvertAndStore (FRAME_X_TEXT_WIDGET (f), XtRString, &fromVal,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1099 XtRXimStyles, &toVal) != False)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1100 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1101 stderr_out ("Unit_Test: fromVal.addr=0x%x\n",fromVal.addr);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1102 stderr_out ("Unit_Test: fromVal.size=%d\n", fromVal.size);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1103 stderr_out ("Unit_Test: toVal.addr=0x%x\n", toVal.addr);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1104 stderr_out ("Unit_Test: toVal.size=%d\n", toVal.size);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1105 describe_XIMStyles ((XIMStyles *) toVal.addr);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1106 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1107 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1108 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1109
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1110 #if 0
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1111 /* Get a fontset for IM to use */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1112 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1113 x_init_fontset (struct device *d)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1114 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1115 Display *dpy = DEVICE_X_DISPLAY (d);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1116 XFontSet fontset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1117 char ** missing_charsets;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1118 int num_missing_charsets;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1119 char * default_string;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1120 /* char * font_set_string = "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*";*/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1121 char * font_set_string = "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*, -misc-fixed-medium-r-normal--14-130-75-75-c-70-jisx0201.1976-0,-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-0, -misc-fixed-medium-r-normal--14-130-75-75-c-70-jisx0201.1976-0" ;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
1122
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1123 DEVICE_X_FONTSET (d) = fontset =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1124 XCreateFontSet (dpy,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1125 font_set_string,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1126 &missing_charsets,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1127 &num_missing_charsets,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1128 &default_string);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1129
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1130 if (fontset == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1131 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1132 stderr_out ("Unable to create fontset from string:\n%s\n", font_set_string);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1133 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1134 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1135 if (num_missing_charsets > 0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1136 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1137 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1138 stderr_out ("\nMissing charsets for fontset %s:\n", font_set_string);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1139 for (i=0; i < num_missing_charsets; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1140 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1141 stderr_out ("%s\n", missing_charsets[i]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1142 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1143 XFreeStringList (missing_charsets);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1144 stderr_out ("Default string: %s\n", default_string);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1145 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 179
diff changeset
1146
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1147 #ifdef DEBUG_XIM
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1148 describe_XFontSet (fontset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1149 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1150 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1151 #endif /* 0 */