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