Attachment "im.c" to
ticket [570902ff]
added by
mdejong
2002-06-19 09:29:33.
#include <X11/Xlib.h>
#include <stdlib.h>
#include <locale.h>
int main() {
Display *d;
int screen;
Window window;
XIM im;
XIC ic;
if (setlocale(LC_CTYPE, "") == NULL)
exit(1);
if (! XSupportsLocale() )
exit(2);
d = XOpenDisplay(":0.0");
if (d == NULL)
exit(3);
screen = DefaultScreen(d);
window = XCreateSimpleWindow(d, RootWindow(d, screen),
0, 0, 200, 200, 2,
BlackPixel(d, screen),
WhitePixel(d, screen));
im = XOpenIM(d, NULL, NULL, NULL);
if (im == NULL)
exit(4);
if( (ic = XCreateIC(im, XNInputStyle,
XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, window, NULL)) == NULL )
exit(5);
/*
The XCloseIM method can free the same memory twice
because of a bug in the close method for a specific
input context. This fix is to NULL out the
im->core.ic_chain member after freeing the elements
of the queue. This should be done by X, but we
can avoid the bug by calling XDestroyIC ourselves.
*/
/*XDestroyIC(ic);*/
XCloseIM(im);
XCloseDisplay(d);
}