Skip to content

KWindowConfig: Use setVisibility to ensure QtQuick windows are maximized

Joshua Goins requested to merge work/redstrate/quick-window-maximize-fix into master

When integrating WindowStateSaver into Plasma's Discover, we discovered an issue where the maximized state was not restoring correctly. This wasn't obvious, but this is intentional behavior on the part of QWindow.

You see, Discover is using the QML version of this class which is called while the window hasn't technically been shown/is visible yet. In this time, we call setWindowState to Maximized. Then QQuickWindowQmlImpl::setWindowVisibility is called to figure out the window's actual visibility where it then reads the visibility property of the window. Since it was still AutomaticVisibility, the window doesn't get maximized and the window state is reset back to WindowNoState. Bad!

So now in KWindowConfig::restoreWindowSize, let's make sure to set the window visibility state as well to cover this case. This should fix QtQuick windows not being maximized when Window-Maximized is true.

Merge request reports