Fallback to root if chosen input style unsupported in input method
@@ -545,6 +545,7 @@ static void *xmalloc(size_t);
static void *xrealloc(void *, size_t);
static char *xstrdup(char *);
+static int isavailablestyle(XIMStyle);
static void setpreeditposition();
static void usage(void);
@@ -3911,8 +3912,12 @@ xinit(void)
}
}
}
+ /* default ximstyle (root) */
+ ximstyle = (XIMPreeditNothing | XIMStatusNothing);
+ pnlist = NULL;
if (!strncmp(imstyle, IMSTYLE_OVERTHESPOT, 11)) {
ximstyle = (XIMPreeditPosition | XIMStatusNothing);
+ if (isavailablestyle(ximstyle)) {
sprintf(pat, "-*-*-*-R-*-*-%d-*-*-*-*-*-*,*", dc.font.height);
fontset = XCreateFontSet(xw.dpy, pat, &missingcharlist,
&nummissingcharlist, &defstring);
@@ -3923,9 +3928,7 @@ xinit(void)
spot.x = 0; spot.y = 0;
pnlist = XVaCreateNestedList(0, XNFontSet, fontset, XNSpotLocation,
&spot, NULL);
- } else {
- ximstyle = (XIMPreeditNothing | XIMStatusNothing);
- pnlist = NULL;
+ }
}
xw.xic = XCreateIC(xw.xim, XNInputStyle, ximstyle, XNClientWindow,
xw.win, XNFocusWindow, xw.win,
@@ -4893,6 +4896,19 @@ reload(int sig)
signal(SIGUSR1, reload);
}
+int
+isavailablestyle(XIMStyle ximstyle)
+{
+ XIMStyles *ximstyles;
+ int i;
+ /* Get available input styles */
+ XGetIMValues(xw.xim, XNQueryInputStyle, &ximstyles, NULL);
+ for (i = 0; i < ximstyles->count_styles; i++)
+ if (ximstyle == ximstyles->supported_styles[i])
+ return TRUE;
+ return FALSE;
+}
+
void
setpreeditposition()
{
