diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-04-04 08:59:11 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-04-04 08:59:18 +0200 |
commit | 216f57ef8682f74b72ae4e39cf1fd23abddf6a51 (patch) | |
tree | 9d1dc12e0944ec0252dac843fbadaf1dc4693888 /src/plugins/platforms/windows/qwindowsinputcontext.cpp | |
parent | 36bc2477753d19a14c587b97d4ec4f263e9e16c0 (diff) | |
parent | 8ce657d0279566ef327af1b88339534041ddc012 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I35ca979395620e104e50b06366d0869433a4ffc2
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsinputcontext.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsinputcontext.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index d0c3b80707..ea68ba8cab 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -54,6 +54,8 @@ #include <QtGui/QPalette> #include <QtGui/QGuiApplication> +#include <private/qhighdpiscaling_p.h> + #include <algorithm> QT_BEGIN_NAMESPACE @@ -165,7 +167,8 @@ Q_CORE_EXPORT QLocale qt_localeFromLCID(LCID id); // from qlocale_win.cpp HIMC QWindowsInputContext::m_defaultContext = 0; QWindowsInputContext::CompositionContext::CompositionContext() : - hwnd(0), haveCaret(false), position(0), isComposing(false) + hwnd(0), haveCaret(false), position(0), isComposing(false), + factor(1) { } @@ -274,9 +277,12 @@ void QWindowsInputContext::cursorRectChanged() if (!m_compositionContext.hwnd) return; const QInputMethod *inputMethod = QGuiApplication::inputMethod(); - const QRect cursorRectangle = inputMethod->cursorRectangle().toRect(); - if (!cursorRectangle.isValid()) + const QRectF cursorRectangleF = inputMethod->cursorRectangle(); + if (!cursorRectangleF.isValid()) return; + const QRect cursorRectangle = + QRectF(cursorRectangleF.topLeft() * m_compositionContext.factor, + cursorRectangleF.size() * m_compositionContext.factor).toRect(); qCDebug(lcQpaInputMethods) << __FUNCTION__<< cursorRectangle; @@ -394,7 +400,7 @@ bool QWindowsInputContext::startComposition(HWND hwnd) qCDebug(lcQpaInputMethods) << __FUNCTION__ << fo << window << "language=" << m_languageId; if (!fo || QWindowsWindow::handleOf(window) != hwnd) return false; - initContext(hwnd, fo); + initContext(hwnd, QHighDpiScaling::factor(window), fo); startContextComposition(); return true; } @@ -526,12 +532,13 @@ bool QWindowsInputContext::endComposition(HWND hwnd) return true; } -void QWindowsInputContext::initContext(HWND hwnd, QObject *focusObject) +void QWindowsInputContext::initContext(HWND hwnd, qreal factor, QObject *focusObject) { if (m_compositionContext.hwnd) doneContext(); m_compositionContext.hwnd = hwnd; m_compositionContext.focusObject = focusObject; + m_compositionContext.factor = factor; // Create a hidden caret which is kept at the microfocus // position in update(). This is important for some // Chinese input methods. |