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>
This commit is contained in:
Friedemann Kleint 2017-10-16 10:29:01 +02:00
parent 2d4fe257ca
commit e00b295344

View File

@ -49,7 +49,9 @@
#include <private/qsystemlibrary_p.h> #include <private/qsystemlibrary_p.h>
#include <private/qguiapplication_p.h> #include <private/qguiapplication_p.h>
#include <private/qhighdpiscaling_p.h>
#include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformscreen.h>
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include <QHash> #include <QHash>
@ -335,6 +337,13 @@ bool QSystemTrayIconSys::winEvent( MSG *m, long *result )
Q_ASSERT(q_uNOTIFYICONID == HIWORD(m->lParam)); Q_ASSERT(q_uNOTIFYICONID == HIWORD(m->lParam));
message = LOWORD(m->lParam); message = LOWORD(m->lParam);
gpos = QPoint(GET_X_LPARAM(m->wParam), GET_Y_LPARAM(m->wParam)); 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 { } else {
Q_ASSERT(q_uNOTIFYICONID == m->wParam); Q_ASSERT(q_uNOTIFYICONID == m->wParam);
message = m->lParam; message = m->lParam;