better Input Method Editor (IME) support (35f7db)
This commit is contained in:
parent
9f1a2db7c5
commit
e7cfd5ae16
11 changed files with 56 additions and 93 deletions
77
x.c
77
x.c
|
|
@ -166,6 +166,9 @@ static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int);
|
|||
static void xdrawglyph(Glyph, int, int);
|
||||
static void xclear(int, int, int, int);
|
||||
static int xgeommasktogravity(int);
|
||||
static void ximopen(Display *);
|
||||
static void ximinstantiate(Display *, XPointer, XPointer);
|
||||
static void ximdestroy(XIM, XPointer, XPointer);
|
||||
static void xinit(int, int);
|
||||
static void cresize(int, int);
|
||||
static void xresize(int, int);
|
||||
|
|
@ -946,6 +949,46 @@ xgeommasktogravity(int mask)
|
|||
return SouthEastGravity;
|
||||
}
|
||||
|
||||
void
|
||||
ximopen(Display *dpy)
|
||||
{
|
||||
XIMCallback destroy = { .client_data = NULL, .callback = ximdestroy };
|
||||
|
||||
if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
|
||||
XSetLocaleModifiers("@im=local");
|
||||
if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
|
||||
XSetLocaleModifiers("@im=");
|
||||
if ((xw.xim = XOpenIM(xw.dpy,
|
||||
NULL, NULL, NULL)) == NULL) {
|
||||
die("XOpenIM failed. Could not open input"
|
||||
" device.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (XSetIMValues(xw.xim, XNDestroyCallback, &destroy, NULL) != NULL)
|
||||
die("XSetIMValues failed. Could not set input method value.\n");
|
||||
xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
||||
XNClientWindow, xw.win, XNFocusWindow, xw.win, NULL);
|
||||
if (xw.xic == NULL)
|
||||
die("XCreateIC failed. Could not obtain input method.\n");
|
||||
}
|
||||
|
||||
void
|
||||
ximinstantiate(Display *dpy, XPointer client, XPointer call)
|
||||
{
|
||||
ximopen(dpy);
|
||||
XUnregisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
|
||||
ximinstantiate, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
ximdestroy(XIM xim, XPointer client, XPointer call)
|
||||
{
|
||||
xw.xim = NULL;
|
||||
XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
|
||||
ximinstantiate, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
xloadfont(Font *f, FcPattern *pattern)
|
||||
{
|
||||
|
|
@ -1196,10 +1239,7 @@ xinit(int cols, int rows)
|
|||
xw.attrs.background_pixel = dc.col[defaultbg].pixel;
|
||||
xw.attrs.border_pixel = dc.col[defaultbg].pixel;
|
||||
xw.attrs.bit_gravity = NorthWestGravity;
|
||||
xw.attrs.event_mask = FocusChangeMask | KeyPressMask
|
||||
#if FIXIME_PATCH
|
||||
| KeyReleaseMask
|
||||
#endif // FIXIME_PATCH
|
||||
xw.attrs.event_mask = FocusChangeMask | KeyPressMask | KeyReleaseMask
|
||||
| ExposureMask | VisibilityChangeMask | StructureNotifyMask
|
||||
| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask
|
||||
#if ST_EMBEDDER_PATCH
|
||||
|
|
@ -1243,26 +1283,7 @@ xinit(int cols, int rows)
|
|||
xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap);
|
||||
|
||||
/* input methods */
|
||||
#if FIXIME_PATCH
|
||||
ximopen(xw.dpy);
|
||||
#else
|
||||
if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
|
||||
XSetLocaleModifiers("@im=local");
|
||||
if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
|
||||
XSetLocaleModifiers("@im=");
|
||||
if ((xw.xim = XOpenIM(xw.dpy,
|
||||
NULL, NULL, NULL)) == NULL) {
|
||||
die("XOpenIM failed. Could not open input"
|
||||
" device.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing
|
||||
| XIMStatusNothing, XNClientWindow, xw.win,
|
||||
XNFocusWindow, xw.win, NULL);
|
||||
if (xw.xic == NULL)
|
||||
die("XCreateIC failed. Could not obtain input method.\n");
|
||||
#endif // FIXIME_PATCH
|
||||
|
||||
/* white cursor, black outline */
|
||||
#if HIDECURSOR_PATCH
|
||||
|
|
@ -1885,6 +1906,16 @@ xfinishdraw(void)
|
|||
defaultfg : defaultbg].pixel);
|
||||
}
|
||||
|
||||
void
|
||||
xximspot(int x, int y)
|
||||
{
|
||||
XPoint spot = { borderpx + x * win.cw, borderpx + (y + 1) * win.ch };
|
||||
XVaNestedList attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
|
||||
|
||||
XSetICValues(xw.xic, XNPreeditAttributes, attr, NULL);
|
||||
XFree(attr);
|
||||
}
|
||||
|
||||
void
|
||||
expose(XEvent *ev)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue