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 XEmacs.
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
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
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. */
22 /* Synched up with: Not in FSF. */
24 /* Written by Martin Buchholz. */
27 #include <X11/Xlocale.h> /* More portable than <locale.h> ? */
29 #include "console-x.h"
32 #include "EmacsFrame.h"
36 #error XIM_MOTIF is not defined??
40 Initialize_Locale (void)
44 /* dverna - Nov. 98: #### DON'T DO THIS !!! The default XtLanguageProc
45 routine calls setlocale(LC_ALL, lang) which fucks up our lower-level
46 locale management, and especially the value of LC_NUMERIC. Anyway, since
47 at this point, we don't know yet whether we're gonna need an X11 frame,
48 we should really do it manually and not use Xlib's dumb default routine */
49 /*XtSetLanguageProc (NULL, (XtLanguageProc) NULL, NULL);*/
50 if ((locale = setlocale (LC_ALL, "")) == NULL)
52 stderr_out ("Can't set locale.\n");
53 stderr_out ("Using C locale instead.\n");
56 if ((locale = setlocale (LC_ALL, "C")) == NULL)
58 stderr_out ("Can't even set locale to `C'!\n");
63 if (!XSupportsLocale ())
65 stderr_out ("X Windows does not support locale `%s'\n", locale);
66 stderr_out ("Using C Locale instead\n");
69 if ((locale = setlocale (LC_ALL, "C")) == NULL)
71 stderr_out ("Can't even set locale to `C'!\n");
74 if (!XSupportsLocale ())
76 stderr_out ("X Windows does not even support locale `C'!\n");
81 setlocale(LC_NUMERIC, "C");
83 if (XSetLocaleModifiers ("") == NULL)
85 stderr_out ("XSetLocaleModifiers(\"\") failed\n");
86 stderr_out ("Check the value of the XMODIFIERS environment variable.\n");
90 /* Create X input method for device */
92 XIM_init_device (struct device *d)
97 /* Callback for the deleting frame. */
99 XIM_delete_frame (Widget w, XtPointer client_data, XtPointer call_data)
101 XmImUnregister ((Widget) client_data);
105 XIM_init_frame (struct frame *f)
107 Widget w = FRAME_X_TEXT_WIDGET (f);
110 XmFontListEntry fontlistEntry;
119 xim_resources_t xim_resources;
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 */
125 #define res(name, class, representation, field, default_value) \
126 { name, class, representation, sizeof(xim_resources.field), \
127 XtOffsetOf(xim_resources_t, field), \
128 XtRString, (XtPointer) (default_value) }
130 static XtResource resources[] =
132 /* name class represent'n field default value */
133 res(XtNfontSet, XtCFontSet, XtRFontSet, fontset, XtDefaultFontSet),
134 res(XtNximForeground, XtCForeground, XtRPixel, fg, XtDefaultForeground),
135 res(XtNximBackground, XtCBackground, XtRPixel, bg, XtDefaultBackground)
138 XtGetApplicationResources (w, &xim_resources,
139 resources, XtNumber (resources),
142 if (! xim_resources.fontset)
144 stderr_out ("Can't get fontset resource for Input Method\n");
148 fontlistEntry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
150 (XtPointer) xim_resources.fontset);
151 fontlist = XmFontListAppendEntry (NULL, fontlistEntry);
154 XmNfontList, fontlist,
155 XmNforeground, xim_resources.fg,
156 XmNbackground, xim_resources.bg,
157 XmNspotLocation, &spot,
158 /* XmNlineSpace, 0, */
161 XmFontListEntryFree (&fontlistEntry);
163 XtAddCallback (w, XmNdestroyCallback, XIM_delete_frame, (XtPointer) w);
167 XIM_SetGeometry (struct frame *f)
172 XIM_SetSpotLocation (struct frame *f, int x, int y)
174 /* #### FIX: Must make sure spot fits within Preedit Area */
175 XPoint *spot = &(FRAME_X_XIC_SPOT (f));
176 if (spot->x == (short) x &&
177 spot->y == (short) y)
183 XmImVaSetValues (FRAME_X_TEXT_WIDGET (f), XmNspotLocation, spot, NULL);
187 XIM_focus_event (struct frame *f, int in_p)
190 XmImVaSetFocusValues (FRAME_X_TEXT_WIDGET (f), NULL);
192 XmImUnsetFocus (FRAME_X_TEXT_WIDGET (f));
196 vars_of_input_method_motif (void)
198 Fprovide (intern ("xim"));