GTK: fix menu positioning on high-DPI

The target position is passed in physical native pixels, so call
QPlatformWindow::mapToGlobal() instead of QWindow::mapToGlobal().
The latter operates on logical pixels.

Task-number: QTBUG-55251
Change-Id: I789128a0a345d4113fced82ed1b215fe14044634
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
J-P Nurmi 2018-02-01 14:40:46 +01:00
parent 0307bfea31
commit fef6b31b99

View File

@ -41,6 +41,7 @@
#include <QtGui/qwindow.h>
#include <QtGui/qpa/qplatformtheme.h>
#include <QtGui/qpa/qplatformwindow.h>
#undef signals
#include <gtk/gtk.h>
@ -450,8 +451,9 @@ void QGtk3Menu::showPopup(const QWindow *parentWindow, const QRect &targetRect,
m_targetPos = QPoint(targetRect.x(), targetRect.y() + targetRect.height());
if (parentWindow)
m_targetPos = parentWindow->mapToGlobal(m_targetPos);
QPlatformWindow *pw = parentWindow ? parentWindow->handle() : nullptr;
if (pw)
m_targetPos = pw->mapToGlobal(m_targetPos);
gtk_menu_popup(GTK_MENU(m_menu), NULL, NULL, qt_gtk_menu_position_func, this, 0, gtk_get_current_event_time());
}