annotate src/input-method-motif.c @ 175:2d532a89d707 r20-3b14

Import from CVS: tag r20-3b14
author cvs
date Mon, 13 Aug 2007 09:50:14 +0200
parents 538048ae2ab8
children 3d6bfa290dbd
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
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
26 #include <X11/Xlocale.h> /* More portable than <locale.h> ? */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
27 #include <config.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;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
43
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 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
75
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
76 if (XSetLocaleModifiers ("") == NULL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
77 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
78 stderr_out ("XSetLocaleModifiers(\"\") failed\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
79 stderr_out ("Check the value of the XMODIFIERS environment variable.\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
80 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
81 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
82
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
83 /* Create X input method for device */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
84 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
85 XIM_init_device (struct device *d)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
86 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
87 /* Nothing to do */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
88 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
89
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
90 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
91 XIM_init_frame (struct frame *f)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
92 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
93 struct device *d = XDEVICE (FRAME_DEVICE (f));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
94 Widget w = FRAME_X_TEXT_WIDGET (f);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
95 XPoint spot = {0,0};
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
96 XFontSet fontset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
97 XmFontList fontlist;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
98 XmFontListEntry fontlistEntry;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
99
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
100 typedef struct
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
101 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
102 XFontSet fontset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
103 Pixel fg;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
104 Pixel bg;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
105 } xim_resources_t;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
106
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
107 xim_resources_t xim_resources;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
108
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
109 /* mrb: #### Fix so that background and foreground is set from
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
110 default face, rather than foreground and background resources, or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
111 that the user can use set-frame-parameters to set xic attributes */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
112
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
113 #define res(name, class, representation, field, default_value) \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
114 { name, class, representation, sizeof(xim_resources.field), \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
115 XtOffsetOf(xim_resources_t, field), XtRString, default_value }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
116
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
117 static XtResource resources[] =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
118 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
119 /* name class represent'n field default value */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
120 res(XtNfontSet, XtCFontSet, XtRFontSet, fontset, XtDefaultFontSet),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
121 res(XtNximForeground, XtCForeground, XtRPixel, fg, XtDefaultForeground),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
122 res(XtNximBackground, XtCBackground, XtRPixel, bg, XtDefaultBackground)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
123 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
124
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
125 XtGetApplicationResources (w, &xim_resources,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
126 resources, XtNumber (resources),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
127 NULL, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
128
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
129 if (! xim_resources.fontset)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
130 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
131 stderr_out ("Can't get fontset resource for Input Method\n");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
132 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
133 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
134
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
135 fontlistEntry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
136 XmFONT_IS_FONTSET,
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
137 (XtPointer) xim_resources.fontset);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
138 fontlist = XmFontListAppendEntry (NULL, fontlistEntry);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
139 XmImRegister (w, 0);
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
140 XmImVaSetValues (w,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
141 XmNfontList, fontlist,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
142 XmNforeground, xim_resources.fg,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
143 XmNbackground, xim_resources.bg,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
144 XmNspotLocation, &spot,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
145 /* XmNlineSpace, 0, */
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 98
diff changeset
146 NULL);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
147
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
148 XmFontListEntryFree (&fontlistEntry);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
149 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
150
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
151 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
152 XIM_SetGeometry (struct frame *f)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
153 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
154 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
155
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
156 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
157 XIM_SetSpotLocation (struct frame *f, int x, int y)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
158 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
159 /* ### FIX: Must make sure spot fits within Preedit Area */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
160 XPoint *spot = &(FRAME_X_XIC_SPOT (f));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
161 if (spot->x == (short) x &&
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
162 spot->y == (short) y)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
163 return;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
164
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
165 spot->x = (short) x;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
166 spot->y = (short) y;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
167
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
168 XmImVaSetValues (FRAME_X_TEXT_WIDGET (f), XmNspotLocation, spot, NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
169 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
170
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
171 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
172 XIM_focus_event (struct frame *f, int in_p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
173 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
174 if (in_p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
175 XmImVaSetFocusValues (FRAME_X_TEXT_WIDGET (f), NULL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
176 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
177 XmImUnsetFocus (FRAME_X_TEXT_WIDGET (f));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
178 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
179
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
180 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
181 vars_of_input_method_motif (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
182 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
183 Fprovide (intern ("xim"));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
184 }