diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2009-05-12 12:45:32 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2009-05-12 12:45:32 (GMT) |
commit | 1898c46452beae9e28cf9be7851099b4b4d2779e (patch) | |
tree | 00477e689bf1bd867fb3428476029b47817a9db8 /src/gui/inputmethod/qximinputcontext_x11.cpp | |
parent | f15b8a83e2e51955776a3f07cb85ebfc342dd8ef (diff) | |
parent | 4d5a5149b716c67f031a3a40e23370f90542c92f (diff) | |
download | Qt-1898c46452beae9e28cf9be7851099b4b4d2779e.zip Qt-1898c46452beae9e28cf9be7851099b4b4d2779e.tar.gz Qt-1898c46452beae9e28cf9be7851099b4b4d2779e.tar.bz2 |
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-statemachine
Conflicts:
src/gui/graphicsview/qgraphicsitem.cpp
Diffstat (limited to 'src/gui/inputmethod/qximinputcontext_x11.cpp')
-rw-r--r-- | src/gui/inputmethod/qximinputcontext_x11.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/gui/inputmethod/qximinputcontext_x11.cpp index 2fbe86f..c320fb4 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,11 +287,14 @@ void QXIMInputContext::ICData::clear() text = QString(); selectedChars.clear(); composing = false; + preeditEmpty = true; } QXIMInputContext::ICData *QXIMInputContext::icData() const { - return ximData.value(focusWidget()->effectiveWinId()); + if (QWidget *w = focusWidget()) + return ximData.value(w->effectiveWinId()); + return 0; } /* The cache here is needed, as X11 leaks a few kb for every XFreeFontSet call, so we avoid creating and deletion of fontsets as @@ -433,7 +437,8 @@ void QXIMInputContext::create_xim() // reinitialize input context after the input method // server (like SCIM) has been launched without // requiring the user to manually switch focus. - if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) + if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled) + && focusWidget->testAttribute(Qt::WA_WState_Created)) setFocusWidget(focusWidget); } // following code fragment is not required for immodule @@ -531,12 +536,14 @@ void QXIMInputContext::reset() if (data->ic) { char *mb = XmbResetIC(data->ic); + QInputMethodEvent e; if (mb) { - QInputMethodEvent e; e.setCommitString(QString::fromLocal8Bit(mb)); - sendEvent(e); XFree(mb); - + data->preeditEmpty = false; // force sending an event + } + if (!data->preeditEmpty) { + sendEvent(e); update(); } } @@ -562,12 +569,14 @@ void QXIMInputContext::mouseHandler(int pos, QMouseEvent *e) return; XIM_DEBUG("QXIMInputContext::mouseHandler pos=%d", pos); - ICData *data = ximData.value(focusWidget()->effectiveWinId()); - if (!data) - return; - if (pos < 0 || pos > data->text.length()) - reset(); - // ##### handle mouse position + if (QWidget *w = focusWidget()) { + ICData *data = ximData.value(w->effectiveWinId()); + if (!data) + return; + if (pos < 0 || pos > data->text.length()) + reset(); + // ##### handle mouse position + } } bool QXIMInputContext::isComposing() const @@ -683,6 +692,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; |