bool TWindow::CreateInputContext() { if (!fInputContext) { XIM xim = gApplication->GetInputMethod(); if (!xim) return false; XIMStyles* supportedStyles; XGetIMValues(xim, XNQueryInputStyle, &supportedStyles, NULL, NULL); if (!supportedStyles || supportedStyles->count_styles == 0) return false; XIMStyle* bestStyle = NULL; for (unsigned short i = 0; i < supportedStyles->count_styles; i++) { XIMStyle* style = &supportedStyles->supported_styles[i]; // first check to see if it is supported if ((*style & (XIMPreeditPosition | XIMPreeditNothing | XIMPreeditNone)) && (*style & ( /*XIMStatusCallbacks |*/ XIMStatusNothing | XIMStatusNone))) { if (bestStyle) { if (((*style & XIMPreeditPosition) && !(*bestStyle & XIMPreeditPosition)) || ((*style & XIMStatusCallbacks) && !(*bestStyle & XIMStatusCallbacks))) bestStyle = style; else if (((*style & XIMPreeditNothing) && !(*bestStyle & (XIMPreeditPosition | XIMPreeditNothing))) || ((*style & XIMStatusNothing) && !(*bestStyle & (XIMStatusCallbacks | XIMStatusNothing)))) bestStyle = style; } else bestStyle = style; } } XIMStyle style = (bestStyle ? *bestStyle : 0); XFree(supportedStyles); if (!bestStyle) return false; XPoint point; point.x = point.y = 0; XRectangle rect; rect.x = rect.y = 0; rect.width = rect.height = 0x7fff; TFont* font = GetFont(); ASSERT(font && font->GetFontSet()); XVaNestedList preeditAttributes = XVaCreateNestedList(0, XNFontSet, font->GetFontSet(), XNSpotLocation, &point, XNArea, &rect, NULL); ASSERT(preeditAttributes); // XVaNestedList statusAttributes = XVaCreateNestedList(0, XNFontSet, font->GetFontSet(), NULL); // ASSERT(statusAttributes); XIC xic = XCreateIC(xim, XNInputStyle, style, XNClientWindow, fWindow, XNFocusWindow, fWindow, XNPreeditAttributes, preeditAttributes, /*XNStatusAttributes, statusAttributes, */ NULL); if (xic) fInputContext = new TInputContext(xic); /*if (fInputContext) { long mask; XGetICValues(fInputContext->GetXIC(), XNFilterEvents, &mask, NULL); printf("XIC mask = %lx\n", mask); }*/ } return (fInputContext != NULL); }