comparison src/input-method-motif.c @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents
children 0d2f883870bc
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
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
35 #ifndef XIM_MOTIF
36 #error XIM_MOTIF is not defined??
37 #endif
38
39 void
40 Initialize_Locale (void)
41 {
42 char *locale;
43
44 XtSetLanguageProc (NULL, (XtLanguageProc) NULL, NULL);
45 if ((locale = setlocale (LC_ALL, "")) == NULL)
46 {
47 stderr_out ("Can't set locale.\n");
48 stderr_out ("Using C locale instead.\n");
49 putenv ("LANG=C");
50 putenv ("LC_ALL=C");
51 if ((locale = setlocale (LC_ALL, "C")) == NULL)
52 {
53 stderr_out ("Can't even set locale to `C'!\n");
54 return;
55 }
56 }
57
58 if (!XSupportsLocale ())
59 {
60 stderr_out ("X Windows does not support locale `%s'\n", locale);
61 stderr_out ("Using C Locale instead\n");
62 putenv ("LANG=C");
63 putenv ("LC_ALL=C");
64 if ((locale = setlocale (LC_ALL, "C")) == NULL)
65 {
66 stderr_out ("Can't even set locale to `C'!\n");
67 return;
68 }
69 if (!XSupportsLocale ())
70 {
71 stderr_out ("X Windows does not even support locale `C'!\n");
72 return;
73 }
74 }
75
76 if (XSetLocaleModifiers ("") == NULL)
77 {
78 stderr_out ("XSetLocaleModifiers(\"\") failed\n");
79 stderr_out ("Check the value of the XMODIFIERS environment variable.\n");
80 }
81 }
82
83 /* Create X input method for device */
84 void
85 XIM_init_device (struct device *d)
86 {
87 /* Nothing to do */
88 }
89
90 void
91 XIM_init_frame (struct frame *f)
92 {
93 struct device *d = XDEVICE (FRAME_DEVICE (f));
94 Widget w = FRAME_X_TEXT_WIDGET (f);
95 XPoint spot = {0,0};
96 XFontSet fontset;
97 XmFontList fontlist;
98 XmFontListEntry fontlistEntry;
99
100 typedef struct
101 {
102 XFontSet fontset;
103 Pixel fg;
104 Pixel bg;
105 } xim_resources_t;
106
107 xim_resources_t xim_resources;
108
109 /* mrb: #### Fix so that background and foreground is set from
110 default face, rather than foreground and background resources, or
111 that the user can use set-frame-parameters to set xic attributes */
112
113 #define res(name, class, representation, field, default_value) \
114 { name, class, representation, sizeof(xim_resources.field), \
115 XtOffsetOf(xim_resources_t, field), XtRString, default_value }
116
117 static XtResource resources[] =
118 {
119 /* name class represent'n field default value */
120 res(XtNfontSet, XtCFontSet, XtRFontSet, fontset, XtDefaultFontSet),
121 res(XtNximForeground, XtCForeground, XtRPixel, fg, XtDefaultForeground),
122 res(XtNximBackground, XtCBackground, XtRPixel, bg, XtDefaultBackground)
123 };
124
125 XtGetApplicationResources (w, &xim_resources,
126 resources, XtNumber (resources),
127 NULL, 0);
128
129 if (! xim_resources.fontset)
130 {
131 stderr_out ("Can't get fontset resource for Input Method\n");
132 return;
133 }
134
135 fontlistEntry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
136 XmFONT_IS_FONTSET,
137 xim_resources.fontset);
138 fontlist = XmFontListAppendEntry (NULL, fontlistEntry);
139 XmImRegister (w, 0);
140 XmImVaSetFocusValues (w,
141 XmNfontList, fontlist,
142 XmNforeground, xim_resources.fg,
143 XmNbackground, xim_resources.bg,
144 XmNspotLocation, &spot,
145 /* XmNlineSpace, 0, */
146 NULL);
147
148 XmFontListEntryFree (&fontlistEntry);
149 }
150
151 void
152 XIM_SetGeometry (struct frame *f)
153 {
154 }
155
156 void
157 XIM_SetSpotLocation (struct frame *f, int x, int y)
158 {
159 /* ### FIX: Must make sure spot fits within Preedit Area */
160 XPoint *spot = &(FRAME_X_XIC_SPOT (f));
161 if (spot->x == (short) x &&
162 spot->y == (short) y)
163 return;
164
165 spot->x = (short) x;
166 spot->y = (short) y;
167
168 XmImVaSetValues (FRAME_X_TEXT_WIDGET (f), XmNspotLocation, spot, NULL);
169 }
170
171 void
172 XIM_focus_event (struct frame *f, int in_p)
173 {
174 if (in_p)
175 XmImVaSetFocusValues (FRAME_X_TEXT_WIDGET (f), NULL);
176 else
177 XmImUnsetFocus (FRAME_X_TEXT_WIDGET (f));
178 }
179
180 void
181 vars_of_input_method_motif (void)
182 {
183 Fprovide (intern ("xim"));
184 }