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.
5 This file is part of SXEmacs
7 SXEmacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 SXEmacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* Synched up with: Not in FSF. */
23 /* Written by Martin Buchholz. */
26 #include <X11/Xlocale.h> /* More portable than <locale.h> ? */
28 #include "ui/X11/console-x.h"
29 #include "ui/device.h"
31 #include "ui/X11/EmacsFrame.h"
35 #error XIM_MOTIF is not defined??
38 void Initialize_Locale(void)
42 /* dverna - Nov. 98: #### DON'T DO THIS !!! The default XtLanguageProc
43 routine calls setlocale(LC_ALL, lang) which fucks up our lower-level
44 locale management, and especially the value of LC_NUMERIC. Anyway, since
45 at this point, we don't know yet whether we're gonna need an X11 frame,
46 we should really do it manually and not use Xlib's dumb default routine */
47 /*XtSetLanguageProc (NULL, (XtLanguageProc) NULL, NULL); */
48 if ((locale = setlocale(LC_ALL, "")) == NULL) {
49 stderr_out("Can't set locale.\n");
50 stderr_out("Using C locale instead.\n");
53 if ((locale = setlocale(LC_ALL, "C")) == NULL) {
54 stderr_out("Can't even set locale to `C'!\n");
59 if (!XSupportsLocale()) {
60 stderr_out("X Windows does not support locale `%s'\n", locale);
61 stderr_out("Using C Locale instead\n");
64 if ((locale = setlocale(LC_ALL, "C")) == NULL) {
65 stderr_out("Can't even set locale to `C'!\n");
68 if (!XSupportsLocale()) {
70 ("X Windows does not even support locale `C'!\n");
75 setlocale(LC_NUMERIC, "C");
77 if (XSetLocaleModifiers("") == NULL) {
78 stderr_out("XSetLocaleModifiers(\"\") failed\n");
80 ("Check the value of the XMODIFIERS environment variable.\n");
84 /* Create X input method for device */
85 void XIM_init_device(struct device *d)
90 /* Callback for the deleting frame. */
92 XIM_delete_frame(Widget w, XtPointer client_data, XtPointer call_data)
94 XmImUnregister((Widget) client_data);
97 void XIM_init_frame(struct frame *f)
99 Widget w = FRAME_X_TEXT_WIDGET(f);
100 XPoint spot = { 0, 0 };
102 XmFontListEntry fontlistEntry;
110 xim_resources_t xim_resources;
112 /* mrb: #### Fix so that background and foreground is set from
113 default face, rather than foreground and background resources, or
114 that the user can use set-frame-parameters to set xic attributes */
116 #define res(name, class, representation, field, default_value) \
117 { name, class, representation, sizeof(xim_resources.field), \
118 XtOffsetOf(xim_resources_t, field), \
119 XtRString, (XtPointer) (default_value) }
121 static XtResource resources[] = {
122 /* name class represent'n field default value */
123 res(XtNfontSet, XtCFontSet, XtRFontSet, fontset,
125 res(XtNximForeground, XtCForeground, XtRPixel, fg,
126 XtDefaultForeground),
127 res(XtNximBackground, XtCBackground, XtRPixel, bg,
131 XtGetApplicationResources(w, &xim_resources,
132 resources, XtNumber(resources), NULL, 0);
134 if (!xim_resources.fontset) {
135 stderr_out("Can't get fontset resource for Input Method\n");
139 fontlistEntry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
141 (XtPointer) xim_resources.
143 fontlist = XmFontListAppendEntry(NULL, fontlistEntry);
146 XmNfontList, fontlist,
147 XmNforeground, xim_resources.fg,
148 XmNbackground, xim_resources.bg, XmNspotLocation, &spot,
149 /* XmNlineSpace, 0, */
152 XmFontListEntryFree(&fontlistEntry);
154 XtAddCallback(w, XmNdestroyCallback, XIM_delete_frame, (XtPointer) w);
157 void XIM_SetGeometry(struct frame *f)
161 void XIM_SetSpotLocation(struct frame *f, int x, int y)
163 /* #### FIX: Must make sure spot fits within Preedit Area */
164 XPoint *spot = &(FRAME_X_XIC_SPOT(f));
165 if (spot->x == (short)x && spot->y == (short)y)
171 XmImVaSetValues(FRAME_X_TEXT_WIDGET(f), XmNspotLocation, spot, NULL);
174 void XIM_focus_event(struct frame *f, int in_p)
177 XmImVaSetFocusValues(FRAME_X_TEXT_WIDGET(f), NULL);
179 XmImUnsetFocus(FRAME_X_TEXT_WIDGET(f));
182 void vars_of_input_method_motif(void)
184 Fprovide(intern("xim"));