4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
19 static XIM input_method=NULL;
20 static XIMStyle input_style=(XIMPreeditNothing|XIMStatusNothing);
23 void ioncore_init_xim(void)
28 XIMStyles *xim_styles = NULL;
31 if((p=XSetLocaleModifiers(""))!=NULL && *p)
32 xim=XOpenIM(ioncore_g.dpy, NULL, NULL, NULL);
34 if(xim==NULL && (p=XSetLocaleModifiers("@im=none"))!=NULL && *p)
35 xim=XOpenIM(ioncore_g.dpy, NULL, NULL, NULL);
38 ioncore_warn_nolog(TR("Failed to open input method."));
42 if(XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) || !xim_styles) {
43 ioncore_warn_nolog(TR("Input method doesn't support any style."));
48 for(i=0; (ushort)i<xim_styles->count_styles; i++){
49 if(input_style==xim_styles->supported_styles[i]){
58 ioncore_warn_nolog(TR("input method doesn't support my preedit type."));
67 XIC xwindow_create_xic(Window win)
69 /*static bool tried=FALSE;*/
73 if(input_method==NULL && !tried){
78 if(input_method==NULL)
81 xic=XCreateIC(input_method, XNInputStyle, input_style,
82 XNClientWindow, win, XNFocusWindow, win,
86 warn(TR("Failed to create input context."));
92 bool window_create_xic(WWindow *wwin)
95 wwin->xic=xwindow_create_xic(wwin->win);
96 return (wwin->xic!=NULL);