annotate src/input-method-motif.c @ 266:18d185df8c54

Added tag r20-5b31 for changeset 8efd647ea9ca
author cvs
date Mon, 13 Aug 2007 10:25:39 +0200
parents 2c611d1463a6
children c5d627a313b1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1 /* Various functions for X11R5+ input methods, using the Motif XmIm* functions.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
2 input-method-xlib.c provides a lower-level implementation.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
3 Copyright (C) 1996 Sun Microsystems.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
4
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
5 This file is part of XEmacs.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
6
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
10 later version.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
11
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
15 for more details.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
16
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
21
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
23
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
24 /* Written by Martin Buchholz. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
25
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 185
diff changeset
26 #include <config.h>
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
27 #include <X11/Xlocale.h> /* More portable than <locale.h> ? */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
28 #include "lisp.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
29 #include "console-x.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
30 #include "device.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
31 #include "frame.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
32 #include "EmacsFrame.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
33 #include <Xm/Xm.h>
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
34
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
35 #ifndef XIM_MOTIF
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
36 #error XIM_MOTIF is not defined??
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
37 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
38
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
39 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
40 Initialize_Locale (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
41 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
42 char *locale;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 175
diff changeset
43
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
44 XtSetLanguageProc (NULL, (XtLanguageProc) NULL, NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
45 if ((locale = setlocale (LC_ALL, "")) == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
46 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
47 stderr_out ("Can't set locale.\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
48 stderr_out ("Using C locale instead.\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
49 putenv ("LANG=C");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
50 putenv ("LC_ALL=C");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
51 if ((locale = setlocale (LC_ALL, "C")) == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
52 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
53 stderr_out ("Can't even set locale to `C'!\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
54 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
55 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
56 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
57
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
58 if (!XSupportsLocale ())
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
59 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
60 stderr_out ("X Windows does not support locale `%s'\n", locale);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
61 stderr_out ("Using C Locale instead\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
62 putenv ("LANG=C");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
63 putenv ("LC_ALL=C");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
64 if ((locale = setlocale (LC_ALL, "C")) == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
65 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
66 stderr_out ("Can't even set locale to `C'!\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
67 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
68 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
69 if (!XSupportsLocale ())
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
70 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
71 stderr_out ("X Windows does not even support locale `C'!\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
72 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
73 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
74 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 175
diff changeset
75
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 207
diff changeset
76 setlocale(LC_NUMERIC, "C");
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 207
diff changeset
77
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
78 if (XSetLocaleModifiers ("") == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
79 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
80 stderr_out ("XSetLocaleModifiers(\"\") failed\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
81 stderr_out ("Check the value of the XMODIFIERS environment variable.\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
82 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
83 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
84
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
85 /* Create X input method for device */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
86 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
87 XIM_init_device (struct device *d)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
88 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
89 /* Nothing to do */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
90 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
91
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
92 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
93 XIM_init_frame (struct frame *f)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
94 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
95 struct device *d = XDEVICE (FRAME_DEVICE (f));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
96 Widget w = FRAME_X_TEXT_WIDGET (f);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
97 XPoint spot = {0,0};
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
98 XFontSet fontset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
99 XmFontList fontlist;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
100 XmFontListEntry fontlistEntry;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
101
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
102 typedef struct
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
103 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
104 XFontSet fontset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
105 Pixel fg;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
106 Pixel bg;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
107 } xim_resources_t;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 175
diff changeset
108
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
109 xim_resources_t xim_resources;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 175
diff changeset
110
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
111 /* mrb: #### Fix so that background and foreground is set from
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
112 default face, rather than foreground and background resources, or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
113 that the user can use set-frame-parameters to set xic attributes */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
114
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
115 #define res(name, class, representation, field, default_value) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
116 { name, class, representation, sizeof(xim_resources.field), \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
117 XtOffsetOf(xim_resources_t, field), XtRString, default_value }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
118
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
119 static XtResource resources[] =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
120 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
121 /* name class represent'n field default value */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
122 res(XtNfontSet, XtCFontSet, XtRFontSet, fontset, XtDefaultFontSet),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
123 res(XtNximForeground, XtCForeground, XtRPixel, fg, XtDefaultForeground),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
124 res(XtNximBackground, XtCBackground, XtRPixel, bg, XtDefaultBackground)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
125 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
126
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
127 XtGetApplicationResources (w, &xim_resources,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
128 resources, XtNumber (resources),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
129 NULL, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
130
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
131 if (! xim_resources.fontset)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
132 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
133 stderr_out ("Can't get fontset resource for Input Method\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
134 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
135 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
136
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
137 fontlistEntry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
138 XmFONT_IS_FONTSET,
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
139 (XtPointer) xim_resources.fontset);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
140 fontlist = XmFontListAppendEntry (NULL, fontlistEntry);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
141 XmImRegister (w, 0);
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
142 XmImVaSetValues (w,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
143 XmNfontList, fontlist,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
144 XmNforeground, xim_resources.fg,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
145 XmNbackground, xim_resources.bg,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
146 XmNspotLocation, &spot,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
147 /* XmNlineSpace, 0, */
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
148 NULL);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
149
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
150 XmFontListEntryFree (&fontlistEntry);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
151 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
152
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
153 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
154 XIM_SetGeometry (struct frame *f)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
155 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
156 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
157
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
158 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
159 XIM_SetSpotLocation (struct frame *f, int x, int y)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
160 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
161 /* ### FIX: Must make sure spot fits within Preedit Area */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
162 XPoint *spot = &(FRAME_X_XIC_SPOT (f));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
163 if (spot->x == (short) x &&
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
164 spot->y == (short) y)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
165 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
166
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
167 spot->x = (short) x;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
168 spot->y = (short) y;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
169
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
170 XmImVaSetValues (FRAME_X_TEXT_WIDGET (f), XmNspotLocation, spot, NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
171 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
172
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
173 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
174 XIM_focus_event (struct frame *f, int in_p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
175 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
176 if (in_p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
177 XmImVaSetFocusValues (FRAME_X_TEXT_WIDGET (f), NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
178 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
179 XmImUnsetFocus (FRAME_X_TEXT_WIDGET (f));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
180 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
181
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
182 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
183 vars_of_input_method_motif (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
184 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
185 Fprovide (intern ("xim"));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
186 }