From 68b754effd305653e61b15f1a037ebea84aadb7c Mon Sep 17 00:00:00 2001 From: tetektoza Date: Fri, 26 Sep 2025 22:22:51 +0200 Subject: [PATCH] Gui: Fix clarify selection menu HiDPI positioning issues On HiDPI screens, the Clarify Selection context menu appears far to the right of the intended position when triggered via right-click, which was making it really problematic to select entities. So the easiest solution is to apply `devicePixeLRatio` scaling when converting the stored right-click postiion from device pixels to Qt logical coordinates before calling `mapToGlobal()`. --- src/Gui/CommandView.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index abf7e74547..6b26c3bd47 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -3998,8 +3998,10 @@ void StdCmdClarifySelection::activated(int iMsg) } else { QPoint pos = QCursor::pos(); QPoint local = widget->mapFromGlobal(pos); - point = SbVec2s(static_cast(local.x()), - static_cast(widget->height() - local.y() - 1)); + + qreal devicePixelRatio = widget->devicePixelRatioF(); + point = SbVec2s(static_cast(local.x() * devicePixelRatio), + static_cast((widget->height() - local.y() - 1) * devicePixelRatio)); } // Use ray picking to get all objects under cursor @@ -4071,7 +4073,11 @@ void StdCmdClarifySelection::activated(int iMsg) QPoint globalPos; if (storedPosition.has_value()) { - globalPos = widget->mapToGlobal(QPoint(point[0], widget->height() - point[1] - 1)); + qreal devicePixelRatio = widget->devicePixelRatioF(); + int logicalHeight = static_cast(widget->height()); + QPoint localPos(static_cast(point[0] / devicePixelRatio), + logicalHeight - static_cast(point[1] / devicePixelRatio) - 1); + globalPos = widget->mapToGlobal(localPos); } else { globalPos = QCursor::pos(); }