4 * Copyright (c) Tuomo Valkonen 1999-2001.
5 * See the included file LICENSE for details.
14 #include <X11/Xlocale.h>
17 static XIM input_method
=NULL
;
18 static XIMStyle input_style
=(XIMPreeditNothing
|XIMStatusNothing
);
21 static void init_xlocale(void)
26 XIMStyles
*xim_styles
= NULL
;
29 if((p
=XSetLocaleModifiers(""))!=NULL
&& *p
)
30 xim
=XOpenIM(wglobal
.dpy
, NULL
, NULL
, NULL
);
32 if(xim
==NULL
&& (p
=XSetLocaleModifiers("@im=none"))!=NULL
&& *p
)
33 xim
=XOpenIM(wglobal
.dpy
, NULL
, NULL
, NULL
);
36 warn("Failed to open input method");
40 if(XGetIMValues(xim
, XNQueryInputStyle
, &xim_styles
, NULL
) || !xim_styles
) {
41 warn("input method doesn't support any style");
46 for(i
=0; (ushort
)i
<xim_styles
->count_styles
; i
++){
47 if(input_style
==xim_styles
->supported_styles
[i
]){
56 warn("input method doesn't support my preedit type");
65 XIC
create_xic(Window win
)
67 static bool tried
=FALSE
;
70 if(input_method
==NULL
&& !tried
){
75 if(input_method
==NULL
)
78 xic
=XCreateIC(input_method
, XNInputStyle
, input_style
,
79 XNClientWindow
, win
, XNFocusWindow
, win
,
83 warn("Failed to create input context");