1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-1999 The LyX team.
9 * ======================================================*/
14 // This part is the full blown Input Method manager for X11R5 and up.
15 // For the plain-and-old-X11R4 version, see later.
18 #include <X11/Xutil.h>
19 #include <X11/keysym.h>
28 XComposeStatus compose_status={0,0};
30 // This is called after the main LyX window has been created
31 void InitLyXLookup(Display* display, Window window)
35 // This part could be done before opening display
36 setlocale(LC_CTYPE,"");
37 if (!XSupportsLocale()) {
38 lyxerr.debug("InitLyXLookup: X does not support this locale.");
41 if (!XSetLocaleModifiers("")) {
42 lyxerr.debug("InitLyXLookup: Could not set modifiers "
47 // This part will have to be done for each frame
48 xim = XOpenIM (display, 0, 0, 0);
51 XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
52 XNClientWindow, window,
53 XNFocusWindow, window,
57 lyxerr.debug("InitLyXLookup: could not create "
64 lyxerr.debug("InitLyXLookup: could not open "
71 bool isDeadEvent(XEvent *event,
72 char *buffer_return, int bytes_buffer,
73 KeySym *keysym_return)
75 XLookupString(&event->xkey, buffer_return,
76 bytes_buffer, keysym_return,
78 // Can this be done safely in any other way?
79 // This is all the dead keys I know of in X11R6.1
82 || *keysym_return == XK_dead_grave
85 || *keysym_return == XK_dead_acute
87 #ifdef XK_dead_circumflex
88 || *keysym_return == XK_dead_circumflex
91 || *keysym_return == XK_dead_tilde
94 || *keysym_return == XK_dead_macron
97 || *keysym_return == XK_dead_breve
99 #ifdef XK_dead_abovedot
100 || *keysym_return == XK_dead_abovedot
102 #ifdef XK_dead_diaeresis
103 || *keysym_return == XK_dead_diaeresis
105 #ifdef XK_dead_abovering
106 || *keysym_return == XK_dead_abovering
108 #ifdef XK_dead_doubleacute
109 || *keysym_return == XK_dead_doubleacute
112 || *keysym_return == XK_dead_caron
114 #ifdef XK_dead_cedilla
115 || *keysym_return == XK_dead_cedilla
117 #ifdef XK_dead_ogonek
118 || *keysym_return == XK_dead_ogonek
121 || *keysym_return == XK_dead_iota
123 #ifdef XK_dead_voiced_sound
124 || *keysym_return == XK_dead_voiced_sound
126 #ifdef XK_dead_semivoiced_sound
127 || *keysym_return == XK_dead_semivoiced_sound
129 #ifdef XK_dead_belowdot
130 || *keysym_return == XK_dead_belowdot
138 // This is called instead of XLookupString()
139 int LyXLookupString(XEvent *event,
140 char *buffer_return, int bytes_buffer,
141 KeySym *keysym_return)
145 if (isDeadEvent(event, buffer_return, bytes_buffer,
149 if (XFilterEvent (event, None)) {
150 //lyxerr <<"XFilterEvent");
151 *keysym_return = NoSymbol;
154 if (event->type != KeyPress)
155 lyxerr <<"LyXLookupString: wrong event type"
156 +string(event->type));
157 Status status_return;
159 result = XmbLookupString(xic, &event->xkey, buffer_return,
160 bytes_buffer, keysym_return,
162 switch(status_return) {
164 //lyxerr <<"XLookupBoth");
167 //lyxerr <<"XLookupChars");
168 *keysym_return = NoSymbol;
171 //lyxerr <<"XLookupKeySym");
175 //lyxerr <<"default");
176 *keysym_return = NoSymbol;
181 result = XLookupString(&event->xkey, buffer_return,
182 bytes_buffer, keysym_return,
188 // This is called after the main window has been destroyed
189 void CloseLyXLookup()
192 lyxerr.debug("CloseLyXLookup: destroying input context");
199 #else // We do not have XOpenIM, so we stick with normal XLookupString
201 #include <X11/Xlib.h>
202 #include <X11/Xutil.h>
204 XComposeStatus compose_status={0,0};
206 // This is called after the main LyX window has been created
207 void InitLyXLookup(Display* , Window )
212 // This is called instead of XLookupString(). I this particular case,
213 // this *is* XLookupString...
214 int LyXLookupString(XEvent *event,
215 char *buffer_return, int bytes_buffer,
216 KeySym *keysym_return)
218 return XLookupString(&event->xkey, buffer_return,
219 bytes_buffer, keysym_return,
223 // This is called after the main window has been destroyed
224 void CloseLyXLookup()
230 #endif // HAVE_XOPENIM