Navigation Menu

Skip to content

Commit

Permalink
Do not restore geometry for maximized windows.
Browse files Browse the repository at this point in the history
Geometry restore causes subsequent minimization of previously maximized windows
as observed with KWin 5.19, Qt 5.15 on X11
  • Loading branch information
marisn committed Aug 15, 2020
1 parent 8e4cdba commit 84cf041
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/gui/qgswidgetstatehelper_p.cpp
Expand Up @@ -14,6 +14,7 @@
* *
***************************************************************************/
#include "qgswidgetstatehelper_p.h"
#include <QWindow>
#include <QWidget>
#include <QEvent>
#include <QObject>
Expand Down Expand Up @@ -46,8 +47,28 @@ bool QgsWidgetStateHelper::eventFilter( QObject *object, QEvent *event )
{
QWidget *widget = qobject_cast<QWidget *>( object );
QString name = widgetSafeName( widget );

#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// If window is already maximized by Window Manager,
// there is no need to restore its geometry as it might lead to
// an incorrect state of QFlags<Qt::WindowState>(WindowMinimized|WindowMaximized)
// thus minimizing window after it just has been restored by WM.
// Inability to restore minimzed windows has been observed with
// KWin 5.19 and Qt 5.15 running under X11.
QWindow *win = widget->windowHandle();
if ( !win )
return QObject::eventFilter( object, event );

if ( !( win->windowStates() & Qt::WindowMaximized ) )
{
QString key = mKeys[name];
QgsGuiUtils::restoreGeometry( widget, key );
}
#else
QString key = mKeys[name];
QgsGuiUtils::restoreGeometry( widget, key );
#endif

widget->setProperty( "widgetStateHelperWasShown", QVariant( true ) );
}
return QObject::eventFilter( object, event );
Expand Down

0 comments on commit 84cf041

Please sign in to comment.