Warning: count(): Parameter must be an array or an object that implements Countable in /home/asaki/www/wordpress/wp-includes/post-template.php on line 275

Warning: count(): Parameter must be an array or an object that implements Countable in /home/asaki/www/wordpress/wp-includes/post-template.php on line 275

Warning: count(): Parameter must be an array or an object that implements Countable in /home/asaki/www/wordpress/wp-includes/post-template.php on line 275

Warning: count(): Parameter must be an array or an object that implements Countable in /home/asaki/www/wordpress/wp-includes/post-template.php on line 275

Warning: count(): Parameter must be an array or an object that implements Countable in /home/asaki/www/wordpress/wp-includes/post-template.php on line 275
7月 112005
 

Qt4でInputMethodの表示が変だった件を、ソースを読んでチェックしていくこととした。
あわよくば治してしまおうとのもくろみもあるけれど、どのくらい時間が取れるか分からないから、それは目安がついてから。
まずは表示がされないのが「QinputMethodEventに正しく属性が設定されていないため」なのか「表示部が対応してないため」なのかを探っていこう。
なお、対象はqt-x11-opensource-desktop-4.0.0である。


まずはsrc/gui/inputmethod/qximinputcontext_x11.cppをチェック。
「QInputMethodEvent」で属性を設定しているあたりを探すと240行付近に以下のような行を発見。


QList<QInputMethodEvent::Attribute> attrs;
if (cursor > 0)
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, cursor,
qic->standardFormat(QInputContext::PreeditFormat));
if (sellen)
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, cursor, sellen,
qic->standardFormat(QInputContext::SelectionFormat));
if (cursor + sellen < data->text.length())
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
cursor + sellen, data->text.length() - cursor - sellen,
qic->standardFormat(QInputContext::PreeditFormat));
QInputMethodEvent e(data->text, attrs);
qic->sendEvent(e);

ふむ。Qt3と同程度の情報(カーソルと選択された文字列の長さ)しかないが、一応属性を設定しているようである。
ちなみに、設定している属性はsrc/gui/inputmethod/qinputcontext.cppのQInputContext::standardFormat()で分かる。
PreeditFormatでは背景に少し色をつけて、下線を。SelectionFormatでは色の反転をしているようだ。現状のQInputContextにはこの二つのフォーマットしかない。ただ、これらのフォーマットはQInputContextからの派生クラスが自由に作ればいいのだろう。
前後の文脈まではチェックしていないが、属性の設定コードがあるのは発見した。
では、表示部はどうか。src/gui/widgets/qlineedit.cppを見てみる。
QLineEdit::inputMethodEvent()のなかにQInputMethodEvent::Attributeを考慮したコードがあるのを発見。細かくは見ていないが、表示部も問題はなさそうだ。
って、あれ。じゃ、なぜ前に動作チェックしたときは属性が表示されてなかったんだ。
チェックミスかな。これ以降は動作させつつ、内部情報も表示させないと分からないので、時間がかかりそうなのでまた今度。


Warning: count(): Parameter must be an array or an object that implements Countable in /home/asaki/www/wordpress/wp-includes/class-wp-comment-query.php on line 405

コメントを残す