4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
16 static XIM input_method
=NULL
;
17 static XIMStyle input_style
=(XIMPreeditNothing
|XIMStatusNothing
);
20 void ioncore_init_xim(void)
25 XIMStyles
*xim_styles
= NULL
;
28 if((p
=XSetLocaleModifiers(""))!=NULL
&& *p
)
29 xim
=XOpenIM(ioncore_g
.dpy
, NULL
, NULL
, NULL
);
31 if(xim
==NULL
&& (p
=XSetLocaleModifiers("@im=none"))!=NULL
&& *p
)
32 xim
=XOpenIM(ioncore_g
.dpy
, NULL
, NULL
, NULL
);
35 ioncore_warn_nolog(TR("Failed to open input method."));
39 if(XGetIMValues(xim
, XNQueryInputStyle
, &xim_styles
, NULL
) || !xim_styles
) {
40 ioncore_warn_nolog(TR("Input method doesn't support any style."));
45 for(i
=0; (ushort
)i
<xim_styles
->count_styles
; i
++){
46 if(input_style
==xim_styles
->supported_styles
[i
]){
55 ioncore_warn_nolog(TR("input method doesn't support my preedit type."));
64 XIC
xwindow_create_xic(Window win
)
66 /*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(TR("Failed to create input context."));
89 bool window_create_xic(WWindow
*wwin
)
92 wwin
->xic
=xwindow_create_xic(wwin
->win
);
93 return (wwin
->xic
!=NULL
);