Account for multiple screens when computing QSizeGrip available geometry

In a multi-screen setup, when the window was resized on one
of the screens, the resize was limited to the available geometry
of the screen the window was on.
Fix this by using the whole virtual geometry of all the screens
as basis for the resize.

Fixes: QTBUG-91714
Change-Id: I28dd241d73f6a68550af88e368f0dbdcb9ebf42b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Zhang Hao 2021-03-11 08:52:13 +08:00
parent 2db455aff4
commit be643a27f4
4 changed files with 18 additions and 3 deletions

View File

@ -163,6 +163,10 @@ QT_BEGIN_NAMESPACE
\value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
\value InteractiveResizeAcrossScreens (bool) Whether using the whole virtual geometry of all the screens
as basis for the resize.
This enum value has been added in Qt 6.2.
\sa themeHint(), QStyle::pixelMetric()
*/
@ -563,6 +567,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
}
case MouseQuickSelectionThreshold:
return QVariant(10);
case InteractiveResizeAcrossScreens:
return true;
}
return QVariant();
}

View File

@ -117,7 +117,8 @@ public:
TouchDoubleTapDistance,
ShowShortcutsInContextMenus,
IconFallbackSearchPaths,
MouseQuickSelectionThreshold
MouseQuickSelectionThreshold,
InteractiveResizeAcrossScreens,
};
enum DialogType {

View File

@ -519,6 +519,8 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
return QVariant(int(QTextCharFormat::DotLine));
case QPlatformTheme::UseFullScreenForPopupMenu:
return QVariant(bool([[NSApplication sharedApplication] presentationOptions] & NSApplicationPresentationFullScreen));
case QPlatformTheme::InteractiveResizeAcrossScreens:
return !NSScreen.screensHaveSeparateSpaces;
default:
break;
}

View File

@ -50,6 +50,8 @@
#include "qdebug.h"
#include <private/qwidget_p.h>
#include "private/qapplication_p.h"
#include <qpa/qplatformtheme.h>
#include <QtWidgets/qabstractscrollarea.h>
QT_BEGIN_NAMESPACE
@ -313,8 +315,12 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
QRect availableGeometry;
bool hasVerticalSizeConstraint = true;
bool hasHorizontalSizeConstraint = true;
if (tlw->isWindow())
availableGeometry = QWidgetPrivate::availableScreenGeometry(tlw);
if (tlw->isWindow()) {
if (QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::InteractiveResizeAcrossScreens).toBool())
availableGeometry = tlw->screen()->availableVirtualGeometry();
else
availableGeometry = QWidgetPrivate::availableScreenGeometry(tlw);
}
else {
const QWidget *tlwParent = tlw->parentWidget();
// Check if tlw is inside QAbstractScrollArea/QScrollArea.