To: xbugs@x.org Subject: Xlib: XCreateIC() needs extra XIC values. VERSION: R6.6 CLIENT MACHINE and OPERATING SYSTEM: FreeBSD 4.7 DISPLAY TYPE: XFree86 WINDOW MANAGER: qvwm COMPILER: gcc version 2.95.4 AREA: Xlib SYNOPSIS: XCreateIC() needs extra XIC values. DESCRIPTION: When creating XIC of which "input style" is "Preedit Position", XCreateIC() needs SpotLocation and FontSet value (nested in XNPreeditAttributes value). Also when "Preedit Area" or "Status Area" is specified as "input style", XCreateIC() needs FontSet value (nested in XNPreeditAttributes or XNStatusAttributes value). But according to Xlib specifications of R6, these value are unnecessary at creating XIC. Xlib specifications "Xlib --- C Language X Interface" (seen in ftp://ftp.x.org/pub/R6.6/xc/doc/hardcopy/X11/xlib.PS.gz) in pages 298--299 describe the following table. Input Style XIC Value Geometry Preedit Preedit Preedit Preedit Preedit Management Callback Position Area Nothing None ------------------------------------------------------------------------ ... Preedit ... SpotLocation ignored D-S-G ignored ignored ignored ... ^^^^^ FontSet GN ignored D-S-G D-S-G D-S-G ignored ... ^^^^^ ^^^^^ Input Style XIC Value Geometry Status Status Status Status Management Callback Area Nothing None ------------------------------------------------------------------------ ... Status ... FontSet GN ignored D-S-G D-S-G ignored ... ^^^^^ However, these behaviors are conforming to the specifications of R5. I think, although the specifications have been changed between R5 and R6, the implementaion has not been fixed. Xlib specifications of R5 (mit/hardcopy/Xlib/xlib.PS.Z in ftp://ftp.x.org/pub/R5/mit-4.tar.Z) in pages 241--242 describe the following table. Input Style XIC Value Geometry Preedit Preedit Preedit Preedit Preedit Management Callback Position Area Nothing None ------------------------------------------------------------------------ ... Preedit ... SpotLocation ignored C-S-G ignored ignored ignored ... ^^^^^ FontSet GN ignored C-S-G C-S-G D-S-G ignored ... ^^^^^ ^^^^^ Input Style XIC Value Geometry Status Status Status Status Management Callback Area Nothing None ------------------------------------------------------------------------ ... Status ... FontSet GN ignored C-S-G D-S-G ignored ... ^^^^^ REPEAT BY: To repeat, you need an XIM server which supports both 0x0104 (XIMPreeditPosition | XIMStatusArea) and 0x0101 (XIMPreeditArea | XIMStatusArea) as the XIM style. You must have the server running, and set the environment variable XMODIFIERS appropriately. $ cat Imakefile LOCAL_LIBRARIES = $(XONLYLIB) SRCS = xcreateic.c OBJS = $(SRCS:.c=.o) ComplexProgramTarget(xcreateic) $ cat xcreateic.c #include #include #include #include #include static int is_supported_style(XIMStyles *s, XIMStyle style) { int k; for (k = 0; k < s->count_styles && s->supported_styles[k] != style; ++k) ; return (k < s->count_styles); } static XIC create_ic(XIM im, XIMStyle style) { XIC ic; ic = XCreateIC(im, XNInputStyle, style, XNClientWindow, DefaultRootWindow(XDisplayOfIM(im)), NULL); return ic; } int main(void) { Display *dpy; XIM im; XIMStyle style; XIMStyles *supported; if ((dpy = XOpenDisplay("")) == NULL) { errx(1, "cannot open display."); } if (setlocale(LC_ALL, "") == NULL) { errx(1, "cannot set locale."); } if (XSupportsLocale() == False) { errx(1, "locale not supported."); } if (XSetLocaleModifiers("") == NULL) { errx(1, "cannot set locale modifiers."); } if ((im = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) { errx(1, "cannot open input method."); } if (XGetIMValues(im, XNQueryInputStyle, &supported, NULL) != NULL) { errx(1, "XNQueryInputStyle not supported."); } if (supported->count_styles < 1) { errx(1, "no style available."); } printf("style == (XIMPreeditPosition | XIMStatusArea):\n"); style = XIMPreeditPosition | XIMStatusArea; if (!is_supported_style(supported, style)) { errx(1, "style not supported."); } if (create_ic(im, style) == NULL) { warnx("cannot create input context."); } printf("style == (XIMPreeditArea | XIMStatusArea):\n"); style = XIMPreeditArea | XIMStatusArea; if (!is_supported_style(supported, style)) { errx(1, "style not supported."); } if (create_ic(im, style) == NULL) { warnx("cannot create input context."); } exit(0); return 0; } $ xmkmf -a ; make ... $ ./xcreateic style == (XIMPreeditPosition | XIMStatusArea): xcreateic: cannot create input context. style == (XIMPreeditArea | XIMStatusArea): xcreateic: cannot create input context. $ Note: no messages of warnx() should be printed out. SAMPLE FIX: diff -c -r xc.orig/lib/X11/imRm.c xc/lib/X11/imRm.c *** xc.orig/lib/X11/imRm.c Mon Apr 28 03:47:28 2003 --- xc/lib/X11/imRm.c Sun May 11 06:40:12 2003 *************** *** 1,4 **** --- 1,5 ---- /* $Xorg: imRm.c,v 1.4 2000/08/17 19:45:14 cpqbld Exp $ */ + /* SAMPLE FIX: 2003/05/11 */ /****************************************************************** Copyright 1990, 1991, 1992,1993, 1994 by FUJITSU LIMITED *************** *** 1866,1872 **** 0}, {XNSpotLocation, 0, 0, ! (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 0, 0, 0, --- 1867,1873 ---- 0}, {XNSpotLocation, 0, 0, ! (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 0, 0, 0, *************** *** 1926,1937 **** 0}, {XNFontSet, 0, 0, ! (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), ! (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 0, 0, ! (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET), (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 0}, {XNLineSpace, 0, --- 1927,1938 ---- 0}, {XNFontSet, 0, 0, ! (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), ! (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET), 0, 0, ! (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET), 0}, {XNLineSpace, 0,