summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsinputcontext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsinputcontext.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
index b1259d757e..94a27d146f 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -145,6 +145,7 @@ static inline void imeNotifyCancelComposition(HWND hwnd)
*/
+HIMC QWindowsInputContext::m_defaultContext = 0;
QWindowsInputContext::CompositionContext::CompositionContext() :
hwnd(0), haveCaret(false), position(0), isComposing(false)
@@ -199,13 +200,33 @@ void QWindowsInputContext::reset()
doneContext();
}
-void QWindowsInputContext::setFocusObject(QObject *)
+void QWindowsInputContext::setFocusObject(QObject *object)
{
// ### 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)
imeNotifyCancelComposition(m_compositionContext.hwnd);
+
+ const QWindow *window = QGuiApplication::focusWindow();
+ if (object && window) {
+ QWindowsWindow *platformWindow = QWindowsWindow::baseWindowOf(window);
+ if (inputMethodAccepted()) {
+ // Re-enable IME by associating default context saved on first disabling.
+ if (platformWindow->testFlag(QWindowsWindow::InputMethodDisabled)) {
+ ImmAssociateContext(platformWindow->handle(), QWindowsInputContext::m_defaultContext);
+ platformWindow->clearFlag(QWindowsWindow::InputMethodDisabled);
+ }
+ } else {
+ // Disable IME by associating 0 context. Store context first time.
+ if (!platformWindow->testFlag(QWindowsWindow::InputMethodDisabled)) {
+ const HIMC oldImC = ImmAssociateContext(platformWindow->handle(), 0);
+ platformWindow->setFlag(QWindowsWindow::InputMethodDisabled);
+ if (!QWindowsInputContext::m_defaultContext && oldImC)
+ QWindowsInputContext::m_defaultContext = oldImC;
+ }
+ }
+ }
}
/*!