# HG changeset patch # User Torsten Lilge # Date 1642140574 -3600 # Node ID 6ad5bb8f6a6d4332b5db86b507c4ddf876f7a034 # Parent 3c4e851e0220d87ea80efd8269cf8f1546166a05 fix masimized start on systems with two monitors (bug #61172) * main-window.cc: include QWindow and QScreen; (set_window_layout): in maximized mode, only set geometry on systems with one monitor and if total and available geometry differ, otherwise reduce the geometry by a few pixels diff -r 3c4e851e0220 -r 6ad5bb8f6a6d libgui/src/main-window.cc --- a/libgui/src/main-window.cc Thu Jan 13 07:28:18 2022 -0800 +++ b/libgui/src/main-window.cc Fri Jan 14 07:09:34 2022 +0100 @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,7 @@ #include #include #include +#include // QTerminal includes #include "QTerminal.h" @@ -1543,7 +1545,29 @@ if (isMaximized()) { - setGeometry( QApplication::desktop ()->availableGeometry (this)); + // If the window state is restored to maximized layout, the + // horizontal layout is not preserved. This cann be avoided by + // setting the geometry to the max. available geometry. However, on + // X11, the available geometry (excluding task bar etc.) is equal to + // the total geometry leading to a full screen mode without window + // decorations. This in turn can be avoided by reducing the max. + // size by a few pixels. + + QScreen *s = windowHandle ()->screen (); // Get current screen + QRect av_geom = s->availableGeometry (); // Get available and total + QRect geom = s->geometry (); // screen geometry + + QList screen_list = QGuiApplication::screens (); + if ((screen_list.length () > 1) && (av_geom == geom)) + { + // If we have more than one monitor and available and total + // geometry are the same, reduce this too large geometry + QRect new_geom (av_geom.x () + 1, av_geom.y () + 1, + av_geom.width ()-2, av_geom.height ()-2); + setGeometry (new_geom); + } + else + setGeometry (av_geom); // Set (correct) available geometry } if (! restoreState (settings->value (mw_state).toByteArray ()))