[thhsieh: IMdkit problem on OverTheSpot]
----- Forwarded message from thhsieh -----
Date: Tue, 1 Feb 2000 23:52:29 +0800
From: thhsieh
To: xcin@linux.org.tw
Subject: IMdkit problem on OverTheSpot
X-Mailer: Mutt 1.0pre3us
Hi, 各位:
幾天前有一位 Peter Hung <peter@wahoo.com.tw> 網友告訴我說
IMdkit (或說 xcin-2.5) 在使用 OverTheSpot input style
(XIMPreeditPosition| XIMStatusNothing) 時會有問題。目前
xcin-2.5 是只有支援 Root input style
(XIMPreeditNothing | XIMStatusNothing), 但實際上 IMdkit
並沒有這些限制,因此我稍微修改了 xcin-2.5 的程式,讓它也
可以接受 OverTheSpot 來進行測試,結果發現真的有問題。
若有興趣的朋友可以幫忙試看看,不過在試之前您需要修改一下
xcin-2.5 的原始碼,我的修改如下:
1. xim.c: 找到 defaultStyles 的地方,改成這樣:
static XIMStyle defaultStyles[] = {
XIMPreeditNothing|XIMStatusNothing, /* Root */
XIMPreeditPosition|XIMStatusNothing, /* Over-the-Spot */
0
};
2. xim_IC.c: 找到 ic_set_value_by_name() 內的 XNInputStyle 地方,
改成這樣:
if (match (XNInputStyle, ic_attr)) {
rec->input_style = *((INT32 *)ic_attr->value);
/*
if (rec->input_style != (XIMPreeditNothing|XIMStatusNothing)) {
perr(XCINMSG_WARNING,
"XNInputStyle: only PreeditNothing|XIMStatusNothing "
"mode implemented.\n");
rec->input_style = XIMPreeditNothing|XIMStatusNothing;
}
*/
}
這樣的改法可能不完整,但至少已能做出步的測試。您可以直接用 rxvt-2.7.2
來做測試,在執行 xcin 後,再執行 rxvt:
rxvt -pt Root -im xcin ..... (Root input style)
rxvt -pt OverTheSpot -im xcin ..... (OverTheSpot input style)
您會發現,只有 Root style 可以正常使用,而 OverTheSpot 則不行。我 trace
了部分的 IMdkit source, 在 i18nPtHdr.c, _Xi18nMessageHandler() 函式裏,
正常情況下其 event flow 如下:
-- XIM_CONNECT
-- XIM_OPEN
-- XIM_QUERY_EXTENSION
-- XIM_ENCODING_NEGOTIATION
-- XIM_CLOSE
-- XIM_DISCONNECT
-- XIM_CONNECT
-- XIM_OPEN
-- XIM_QUERY_EXTENSION
-- XIM_ENCODING_NEGOTIATION
-- XIM_GET_IM_VALUES
-- XIM_CREATE_IC
但如果使用了 OverTheSpot style 時,上頭的 flow 執行到了 XIM_GET_IM_VALUES
之後,就不再 XIM_CREATE_IC, 而直接到到 XIM_CLOSE, XIM_DISCONNECT 了。因此
連線就失敗了。
再來看看 rxvt 的 source: command.c, IMInstantiateCallback():
/* try with no modifiers base */
if (xim == NULL && (p = XSetLocaleModifiers("@im=none")) != NULL && *p)
xim = XOpenIM(Xdisplay, NULL, NULL, NULL);
if (xim == NULL)
return;
XSetIMValues(xim, XNDestroyCallback, &ximcallback, NULL);
if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL)
|| !xim_styles) {
print_error("input method doesn't support any style");
XCloseIM(xim);
return;
}
當它執行到 XGetIMValues 時,正是 IMdkit 執行到 XIM_GET_IM_VALUES 那邊,
而接下來 rxvt 就會嘗試 create IC:
Input_Context = XCreateIC(xim, XNInputStyle, input_style,
XNClientWindow, TermWin.parent[0],
XNFocusWindow, TermWin.parent[0],
XNDestroyCallback, &ximcallback,
preedit_attr ? XNPreeditAttributes : NULL,
preedit_attr,
status_attr ? XNStatusAttributes : NULL,
status_attr,
NULL);
如果 input_style 是 Root style 的話,就沒問題,可以順利執行下去。但如
果是 OverTheSpot, 結果是 IMdkit 那邊會完全收不到來自 Xlib 的訊號,也
就無法進行 create IC 的動作,而在此同時, Xlib 直接傳回 NULL 給 rxvt,
因此最後上頭的 Input_Context 的結果就是 NULL, 於是 rxvt 接著就執行:
if (Input_Context == NULL) {
print_error("Failed to create input context");
XCloseIM(xim);
}
換句話說,當 input_style 不是 Root style 時,在 XCreateIC 的 Xlib 那
一關就掛了,問題有可能是出在 Xlib。
我是使用 XFree86-3.3.6 來做測試的。跟據 Peter Hung 的說明,在 3.3.5 也
有類似的問題,但在 3.9.X 上就沒這問題了 (XFree86-3.3.X = X11R6.3,
XFree86-3.9.X = X11R6.4?)。但我很納悶的是,我聽說日本的朋友多半是使用
非 Root input-style 的,當然他們的 XIM server 並不是使用 IMdkit, 而且
他們似乎也還在使用 XFree86-3.X, 似乎也沒聽說有類似的問題,因此我在擔心
這樣的問題可能不單純,說不定 IMdkit 也有 bug, 故在此 post 出來想與大家
討論 (希望有人能與我討論 :-))
如果這只是純粹 Xlib 的問題,那也許我就暫時先不管了,反正就等著大家將
來換到 XFree86-4.0 以後,似乎就可以水到渠成了 :-))
T.H.Hsieh
----- End forwarded message -----
Reply to: