diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-10-16 10:29:01 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-10-16 10:27:58 +0000 |
commit | e00b295344e23bf2110c744b057225a24d589757 (patch) | |
tree | 56df47710ec0d68145bb9c2b79e1fcddc585a692 /src | |
parent | 2d4fe257cad8b10f284de7a0b10a1a297026e86d (diff) |
QSystemTrayIcon/Windows: Fix position of context menu with High DPI scaling
Apply scale factor of screen.
Task-number: QTBUG-63781
Change-Id: I1b5630edbdf6bb356955a7d70458a885af441953
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/util/qsystemtrayicon_win.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp index d110cb8be4..3f007f24c1 100644 --- a/src/widgets/util/qsystemtrayicon_win.cpp +++ b/src/widgets/util/qsystemtrayicon_win.cpp @@ -49,7 +49,9 @@ #include <private/qsystemlibrary_p.h> #include <private/qguiapplication_p.h> +#include <private/qhighdpiscaling_p.h> #include <qpa/qplatformnativeinterface.h> +#include <qpa/qplatformscreen.h> #include <QSettings> #include <QDebug> #include <QHash> @@ -335,6 +337,13 @@ bool QSystemTrayIconSys::winEvent( MSG *m, long *result ) Q_ASSERT(q_uNOTIFYICONID == HIWORD(m->lParam)); message = LOWORD(m->lParam); gpos = QPoint(GET_X_LPARAM(m->wParam), GET_Y_LPARAM(m->wParam)); + // Drop this chunk when merging to 5.10; code has been moved to Windows QPA. + if (const QScreen *primaryScreen = QGuiApplication::primaryScreen()) { + if (const QPlatformScreen *screen = primaryScreen->handle()->screenForPosition(gpos)) { + gpos = QHighDpi::fromNative(gpos, QHighDpiScaling::factor(screen), + screen->geometry().topLeft()); + } + } } else { Q_ASSERT(q_uNOTIFYICONID == m->wParam); message = m->lParam; |