Windows/Input context: Update enabling of IME in in update(), too.
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Thu, 20 Aug 2015 12:51:53 +0000 (14:51 +0200)
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Tue, 25 Aug 2015 11:41:04 +0000 (11:41 +0000)
Amend change b55f88caba339a49bf0ebabfa324dde523c2b866 by splitting
out the enabling into a separate function and call that when
QWindowsInputContext::update() is triggered to reflect updates
of the microfocus in QGraphicsView or item view widgets.

Task-number: QTBUG-47679
Task-number: QTBUG-47705
Task-number: QTBUG-40691
Change-Id: I84a6647944f1aaedcd72d7060cc90e29a177f577
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
src/plugins/platforms/windows/qwindowsinputcontext.cpp
src/plugins/platforms/windows/qwindowsinputcontext.h

index c9434385701e95c3d4f1c2306a6c9fd31430d66b..68e38dc4a6fa5380aebbace6640111b0f63cfc40 100644 (file)
@@ -200,18 +200,27 @@ void QWindowsInputContext::reset()
     doneContext();
 }
 
-void QWindowsInputContext::setFocusObject(QObject *object)
+void QWindowsInputContext::setFocusObject(QObject *)
 {
     // ### fixme: On Windows 8.1, it has been observed that the Input context
     // remains active when this happens resulting in a lock-up. Consecutive
     // key events still have VK_PROCESSKEY set and are thus ignored.
     if (m_compositionContext.isComposing)
         reset();
+    updateEnabled();
+}
 
+void QWindowsInputContext::updateEnabled()
+{
+    if (!QGuiApplication::focusObject())
+        return;
     const QWindow *window = QGuiApplication::focusWindow();
-    if (object && window && window->handle()) {
+    if (window && window->handle()) {
         QWindowsWindow *platformWindow = QWindowsWindow::baseWindowOf(window);
-        if (inputMethodAccepted()) {
+        const bool accepted = inputMethodAccepted();
+        if (QWindowsContext::verbose > 1)
+            qCDebug(lcQpaInputMethods) << __FUNCTION__ << window << "accepted=" << accepted;
+        if (accepted) {
             // Re-enable IME by associating default context saved on first disabling.
             if (platformWindow->testFlag(QWindowsWindow::InputMethodDisabled)) {
                 ImmAssociateContext(platformWindow->handle(), QWindowsInputContext::m_defaultContext);
@@ -235,6 +244,8 @@ void QWindowsInputContext::setFocusObject(QObject *object)
 
 void QWindowsInputContext::update(Qt::InputMethodQueries queries)
 {
+    if (queries & Qt::ImEnabled)
+        updateEnabled();
     QPlatformInputContext::update(queries);
 }
 
index 83a39989f6ffda3d889fbae12a8395443bdc637e..110986c20c426c0fbb3981af5275a79c622c3b07 100644 (file)
@@ -87,6 +87,7 @@ private:
     void doneContext();
     void startContextComposition();
     void endContextComposition();
+    void updateEnabled();
 
     const DWORD m_WM_MSIME_MOUSE;
     static HIMC m_defaultContext;