Revert "link mute/volumeup/volumedown keys to respective amixer commands"
[notion/jeffpc.git] / ioncore / xic.c
blob50142bfaed128f915603bfbc71b84f8f46df7bee
1 /*
2 * ion/ioncore/xic.c
4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
7 */
9 #include <ctype.h>
10 #include <string.h>
11 #include "common.h"
12 #include "global.h"
13 #include "ioncore.h"
16 static XIM input_method=NULL;
17 static XIMStyle input_style=(XIMPreeditNothing|XIMStatusNothing);
20 void ioncore_init_xim(void)
22 char *p;
23 int i;
24 XIM xim=NULL;
25 XIMStyles *xim_styles = NULL;
26 bool found=FALSE;
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);
34 if(xim==NULL){
35 ioncore_warn_nolog(TR("Failed to open input method."));
36 return;
39 if(XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) || !xim_styles) {
40 ioncore_warn_nolog(TR("Input method doesn't support any style."));
41 XCloseIM(xim);
42 return;
45 for(i=0; (ushort)i<xim_styles->count_styles; i++){
46 if(input_style==xim_styles->supported_styles[i]){
47 found=TRUE;
48 break;
52 XFree(xim_styles);
54 if(!found){
55 ioncore_warn_nolog(TR("input method doesn't support my preedit type."));
56 XCloseIM(xim);
57 return;
60 input_method=xim;
64 XIC xwindow_create_xic(Window win)
66 /*static bool tried=FALSE;*/
67 XIC xic;
70 if(input_method==NULL && !tried){
71 init_xlocale();
72 tried=TRUE;
73 }*/
75 if(input_method==NULL)
76 return NULL;
78 xic=XCreateIC(input_method, XNInputStyle, input_style,
79 XNClientWindow, win, XNFocusWindow, win,
80 NULL);
82 if(xic==NULL)
83 warn(TR("Failed to create input context."));
85 return xic;
89 bool window_create_xic(WWindow *wwin)
91 if(wwin->xic==NULL)
92 wwin->xic=xwindow_create_xic(wwin->win);
93 return (wwin->xic!=NULL);