annotate src/input-method-xlib.c @ 563:183866b06e0b

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