summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorViktor Arvidsson <viktor.arvidss@gmail.com>2022-01-31 19:59:37 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-15 09:34:51 +0000
commit8c8c39c948e02efedfb2b1fe72318f39c3aee819 (patch)
treeed102964dd3bc4142f769304919621153cd850ec /src
parentf9eb7a29c8187b1021414c6d8eb6e0133b9ad07a (diff)
downloadqtbase-8c8c39c948e02efedfb2b1fe72318f39c3aee819.tar.gz
Windows QPA: Fix frameless maximize on secondary screens
Frameless windows shouldn't cover the taskbar when maximized. This has been fixed for the main screen in the past but did not work for secondary screens. According to the code the MINMAXINFO is only available for the main screen but I believe this is a misunderstanding of the Windows documentation. Besides we use QScreen::availableGeometry() which seems to be correct. Fixes: QTBUG-51327 Change-Id: Ib2205c480359d1a870dcfcf0312fbe417f650e28 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> (cherry picked from commit 46e9852a1d04357c98b2c62338e1e2af0de9b486) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 991a3a8e91..186d9fe44b 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -2683,32 +2683,30 @@ void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const
// This block fixes QTBUG-8361, QTBUG-4362: Frameless/title-less windows shouldn't cover the
// taskbar when maximized
- if ((testFlag(WithinMaximize) || window()->windowStates().testFlag(Qt::WindowMinimized))
- && (m_data.flags.testFlag(Qt::FramelessWindowHint)
- || (m_data.flags.testFlag(Qt::CustomizeWindowHint) && !m_data.flags.testFlag(Qt::WindowTitleHint)))) {
- const QScreen *screen = window()->screen();
-
- // Documentation of MINMAXINFO states that it will only work for the primary screen
- if (screen && screen == QGuiApplication::primaryScreen()) {
- const QRect availableGeometry = QHighDpi::toNativePixels(screen->availableGeometry(), screen);
+ if (m_data.flags.testFlag(Qt::FramelessWindowHint)
+ || (m_data.flags.testFlag(Qt::CustomizeWindowHint) && !m_data.flags.testFlag(Qt::WindowTitleHint))) {
+ if (QPlatformScreen *currentScreen = screen()) {
+ const QRect geometry = currentScreen->geometry();
+ const QRect availableGeometry = currentScreen->availableGeometry();
mmi->ptMaxSize.y = availableGeometry.height();
// Width, because you can have the taskbar on the sides too.
mmi->ptMaxSize.x = availableGeometry.width();
// If you have the taskbar on top, or on the left you don't want it at (0,0):
- mmi->ptMaxPosition.x = availableGeometry.x();
- mmi->ptMaxPosition.y = availableGeometry.y();
+ QPoint availablePositionDiff = geometry.topLeft() - availableGeometry.topLeft();
+ mmi->ptMaxPosition.x = availablePositionDiff.x();
+ mmi->ptMaxPosition.y = availablePositionDiff.y();
if (!m_data.flags.testFlag(Qt::FramelessWindowHint)) {
- const int borderWidth = getBorderWidth(screen->handle());
+ const int borderWidth = getBorderWidth(currentScreen);
mmi->ptMaxSize.x += borderWidth * 2;
mmi->ptMaxSize.y += borderWidth * 2;
mmi->ptMaxTrackSize = mmi->ptMaxSize;
mmi->ptMaxPosition.x -= borderWidth;
mmi->ptMaxPosition.y -= borderWidth;
}
- } else if (!screen){
- qWarning("window()->screen() returned a null screen");
+ } else {
+ qWarning("screen() returned a null screen");
}
}