Windows: Correctly associate IME contexts.
Associate a 0-context with the window if IME is disabled, store this state as a flag to QWindowsWindow. Associate default context again when enabled window gains focus. Task-number: QTBUG-40691 Change-Id: I78d5494a05f93a39e245ca7c096d45445e684ea8 Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
This commit is contained in:
parent
c91c05b056
commit
b55f88caba
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -88,6 +88,7 @@ private:
|
||||
void endContextComposition();
|
||||
|
||||
const DWORD m_WM_MSIME_MOUSE;
|
||||
static HIMC m_defaultContext;
|
||||
CompositionContext m_compositionContext;
|
||||
bool m_endCompositionRecursionGuard;
|
||||
};
|
||||
|
@ -138,7 +138,8 @@ public:
|
||||
Exposed = 0x10000,
|
||||
WithinCreate = 0x20000,
|
||||
WithinMaximize = 0x40000,
|
||||
MaximizeToFullScreen = 0x80000
|
||||
MaximizeToFullScreen = 0x80000,
|
||||
InputMethodDisabled =0x100000
|
||||
};
|
||||
|
||||
QWindowsWindow(QWindow *window, const QWindowsWindowData &data);
|
||||
|
Loading…
Reference in New Issue
Block a user