diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-03-23 12:13:43 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-03-24 15:18:55 (GMT) |
commit | 7f147cf30e8c72ed4c452de31f4b5f853dbe9e4f (patch) | |
tree | 94faed0e79b42e18dc384a8882bd110b57550a38 | |
parent | 2b9e47e4ce09802f00fa2ca39c0cd877f59ae4d9 (diff) | |
download | Qt-7f147cf30e8c72ed4c452de31f4b5f853dbe9e4f.zip Qt-7f147cf30e8c72ed4c452de31f4b5f853dbe9e4f.tar.gz Qt-7f147cf30e8c72ed4c452de31f4b5f853dbe9e4f.tar.bz2 |
Don't commit an empty string to the widget when it looses focus.
When a wiget that accepts keyboard input looses focus and the input
context is resetted we should clear the old preedit string by sending
an empty commit string only if the widget received non-empty pre-edit
string before.
Reviewed-by: Brad
-rw-r--r-- | src/gui/inputmethod/qximinputcontext_p.h | 1 | ||||
-rw-r--r-- | src/gui/inputmethod/qximinputcontext_x11.cpp | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/gui/inputmethod/qximinputcontext_p.h b/src/gui/inputmethod/qximinputcontext_p.h index ca2103b..3773122 100644 --- a/src/gui/inputmethod/qximinputcontext_p.h +++ b/src/gui/inputmethod/qximinputcontext_p.h @@ -98,6 +98,7 @@ public: QString text; QBitArray selectedChars; bool composing; + bool preeditEmpty; void clear(); }; diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/gui/inputmethod/qximinputcontext_x11.cpp index 48a96b1..1c8560f 100644 --- a/src/gui/inputmethod/qximinputcontext_x11.cpp +++ b/src/gui/inputmethod/qximinputcontext_x11.cpp @@ -264,6 +264,7 @@ extern "C" { qic->standardFormat(QInputContext::PreeditFormat)); attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, sellen ? 0 : 1, QVariant()); QInputMethodEvent e(data->text, attrs); + data->preeditEmpty = data->text.isEmpty(); qic->sendEvent(e); return 0; @@ -286,6 +287,7 @@ void QXIMInputContext::ICData::clear() text = QString(); selectedChars.clear(); composing = false; + preeditEmpty = true; } QXIMInputContext::ICData *QXIMInputContext::icData() const @@ -537,9 +539,12 @@ void QXIMInputContext::reset() if (mb) { e.setCommitString(QString::fromLocal8Bit(mb)); XFree(mb); + data->preeditEmpty = false; // force sending an event + } + if (!data->preeditEmpty) { + sendEvent(e); + update(); } - sendEvent(e); - update(); } data->clear(); } @@ -686,6 +691,7 @@ QXIMInputContext::ICData *QXIMInputContext::createICData(QWidget *w) { ICData *data = new ICData; data->widget = w; + data->preeditEmpty = true; XVaNestedList preedit_attr = 0; XIMCallback startcallback, drawcallback, donecallback; |