code review
[wmaker-crm.git] / WINGs / winputmethod.c
blob303d560186df19e3cf0114caf6c75110efe38bc6
3 #include <X11/Xlib.h>
5 #include "WINGsP.h"
9 typedef struct W_IMContext {
10 XIM xim;
12 struct W_ICContext *icList;
13 } WMIMContext;
16 typedef struct W_ICContext {
17 struct W_ICContext *next;
18 struct W_ICContext *prev;
20 XIC xic;
21 } WMICContext;
25 Bool
26 W_InitIMStuff(WMScreen *scr)
28 WMIMContext *ctx;
30 ctx = scr->imctx = wmalloc(sizeof(WMIMContext));
32 ctx->xim = XOpenIM(scr->display, NULL, NULL, NULL);
33 if (ctx->xim == NULL) {
34 wwarning("could not open IM");
35 return False;
41 void
42 W_CloseIMStuff(WMScreen *scr)
44 if (!scr->imctx)
45 return;
47 if (scr->imctx->xim)
48 XCloseIM(scr->imctx->xim);
49 wfree(scr->imctx);
50 scr->imctx = NULL;
55 WMICContext*
56 W_CreateIC(WMView *view)
58 WMScreen *scr = W_VIEW_SCREEN(view);
59 WMICContext *ctx;
61 ctx->prev = NULL;
62 ctx->next = scr->imctx->icList;
63 if (scr->imctx->icList)
64 scr->imctx->icList->prev = ctx;
70 void
71 W_DestroyIC(WMICContext *ctx)
73 XDestroyIC(ctx->xic);
79 int
80 W_LookupString(WMView *view, XKeyEvent *event,
81 char buffer, int bufsize, KeySym ksym)