summaryrefslogtreecommitdiffstats
path: root/src/gui/inputmethod
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/inputmethod')
-rw-r--r--src/gui/inputmethod/qwininputcontext_win.cpp10
-rw-r--r--src/gui/inputmethod/qximinputcontext_p.h1
-rw-r--r--src/gui/inputmethod/qximinputcontext_x11.cpp32
3 files changed, 28 insertions, 15 deletions
diff --git a/src/gui/inputmethod/qwininputcontext_win.cpp b/src/gui/inputmethod/qwininputcontext_win.cpp
index 720f0b8..e3e8aa4 100644
--- a/src/gui/inputmethod/qwininputcontext_win.cpp
+++ b/src/gui/inputmethod/qwininputcontext_win.cpp
@@ -57,15 +57,17 @@
#ifdef Q_IME_DEBUG
#include "qdebug.h"
-#endif
-
-QT_BEGIN_NAMESPACE
+#endif
-extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
#if defined(Q_OS_WINCE)
extern void qt_wince_show_SIP(bool show); // defined in qguifunctions_wince.cpp
#endif
+QT_BEGIN_NAMESPACE
+
+extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
+
+
DEFINE_GUID(IID_IActiveIMMApp,
0x08c0e040, 0x62d1, 0x11d1, 0x93, 0x26, 0x0, 0x60, 0xb0, 0x67, 0xb8, 0x6e);
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 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;