diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 8c228f588e..b9dd2c557e 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -221,6 +221,28 @@ void QWindowsInputContext::setFocusObject(QObject *) updateEnabled(); } +HWND QWindowsInputContext::getVirtualKeyboardWindowHandle() const +{ + return ::FindWindowA("IPTip_Main_Window", nullptr); +} + +QRectF QWindowsInputContext::keyboardRect() const +{ + if (HWND hwnd = getVirtualKeyboardWindowHandle()) { + RECT rect; + if (::GetWindowRect(hwnd, &rect)) { + return QRectF(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); + } + } + return QRectF(); +} + +bool QWindowsInputContext::isInputPanelVisible() const +{ + HWND hwnd = getVirtualKeyboardWindowHandle(); + return hwnd && ::IsWindowEnabled(hwnd) && ::IsWindowVisible(hwnd); +} + void QWindowsInputContext::updateEnabled() { if (!QGuiApplication::focusObject()) diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.h b/src/plugins/platforms/windows/qwindowsinputcontext.h index 617ef30cef..ada1fc0d29 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.h +++ b/src/plugins/platforms/windows/qwindowsinputcontext.h @@ -79,6 +79,9 @@ public: void invokeAction(QInputMethod::Action, int cursorPosition) override; void setFocusObject(QObject *object) override; + QRectF keyboardRect() const override; + bool isInputPanelVisible() const override; + bool startComposition(HWND hwnd); bool composition(HWND hwnd, LPARAM lParam); bool endComposition(HWND hwnd); @@ -98,6 +101,7 @@ private: void startContextComposition(); void endContextComposition(); void updateEnabled(); + HWND getVirtualKeyboardWindowHandle() const; const DWORD m_WM_MSIME_MOUSE; static HIMC m_defaultContext;