Windows: Fix maximizing frameless windows on secondary screens.

They would either disappear or be positioned at bogus coordinates.

The MINMAXINFO structure works with coords from the primary screen
then uses an "interesting" algorithm to adjust to secondary screen:

Say you have a primary screen with width=1000 and secondary screen
with width=2000, here's what you get when you set ptMaxSize to:

ptMaxSize.x   | Size window gets in second screen
--------------------------------------------------
    500       |                500
    1000      |               2000
    1001      |               2001
    1100      |               2100

So basically you can't get any value between 1000 and 1999

How many people use the taskbar on a second display and maximimize
a frameless window anyway ?

Task-number: QTBUG-39537
Change-Id: Ic9b3120e7fb5a9a5d97828a2e44be02ae587b92e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Sérgio Martins 2014-06-11 12:54:21 +01:00 committed by The Qt Project
parent f65333b027
commit dbe6db192a

View File

@ -1936,7 +1936,10 @@ void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const
&& (m_data.flags & Qt::FramelessWindowHint)) { && (m_data.flags & Qt::FramelessWindowHint)) {
// This block fixes QTBUG-8361: Frameless windows shouldn't cover the // This block fixes QTBUG-8361: Frameless windows shouldn't cover the
// taskbar when maximized // taskbar when maximized
if (const QScreen *screen = effectiveScreen(window())) { const QScreen *screen = effectiveScreen(window());
// Documentation of MINMAXINFO states that it will only work for the primary screen
if (screen && screen == QGuiApplication::primaryScreen()) {
mmi->ptMaxSize.y = screen->availableGeometry().height(); mmi->ptMaxSize.y = screen->availableGeometry().height();
// Width, because you can have the taskbar on the sides too. // Width, because you can have the taskbar on the sides too.
@ -1945,8 +1948,8 @@ void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const
// If you have the taskbar on top, or on the left you don't want it at (0,0): // If you have the taskbar on top, or on the left you don't want it at (0,0):
mmi->ptMaxPosition.x = screen->availableGeometry().x(); mmi->ptMaxPosition.x = screen->availableGeometry().x();
mmi->ptMaxPosition.y = screen->availableGeometry().y(); mmi->ptMaxPosition.y = screen->availableGeometry().y();
} else { } else if (!screen){
qWarning() << "Invalid screen"; qWarning() << "effectiveScreen() returned a null screen";
} }
} }