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