Mercurial > octave
comparison libgui/src/main-window.cc @ 30639:6ad5bb8f6a6d stable
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
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Fri, 14 Jan 2022 07:09:34 +0100 |
parents | 796f54d4ddbf |
children | e2c8c852399e 0a082e1b7422 |
comparison
equal
deleted
inserted
replaced
30637:3c4e851e0220 | 30639:6ad5bb8f6a6d |
---|---|
42 #include <QKeySequence> | 42 #include <QKeySequence> |
43 #include <QLabel> | 43 #include <QLabel> |
44 #include <QMenu> | 44 #include <QMenu> |
45 #include <QMenuBar> | 45 #include <QMenuBar> |
46 #include <QMessageBox> | 46 #include <QMessageBox> |
47 #include <QScreen> | |
47 #include <QStyle> | 48 #include <QStyle> |
48 #include <QStyleFactory> | 49 #include <QStyleFactory> |
49 #include <QTextBrowser> | 50 #include <QTextBrowser> |
50 #include <QTextStream> | 51 #include <QTextStream> |
51 #include <QThread> | 52 #include <QThread> |
52 #include <QTimer> | 53 #include <QTimer> |
53 #include <QToolBar> | 54 #include <QToolBar> |
55 #include <QWindow> | |
54 | 56 |
55 // QTerminal includes | 57 // QTerminal includes |
56 #include "QTerminal.h" | 58 #include "QTerminal.h" |
57 | 59 |
58 #if defined (HAVE_QSCINTILLA) | 60 #if defined (HAVE_QSCINTILLA) |
1541 return; | 1543 return; |
1542 } | 1544 } |
1543 | 1545 |
1544 if (isMaximized()) | 1546 if (isMaximized()) |
1545 { | 1547 { |
1546 setGeometry( QApplication::desktop ()->availableGeometry (this)); | 1548 // If the window state is restored to maximized layout, the |
1549 // horizontal layout is not preserved. This cann be avoided by | |
1550 // setting the geometry to the max. available geometry. However, on | |
1551 // X11, the available geometry (excluding task bar etc.) is equal to | |
1552 // the total geometry leading to a full screen mode without window | |
1553 // decorations. This in turn can be avoided by reducing the max. | |
1554 // size by a few pixels. | |
1555 | |
1556 QScreen *s = windowHandle ()->screen (); // Get current screen | |
1557 QRect av_geom = s->availableGeometry (); // Get available and total | |
1558 QRect geom = s->geometry (); // screen geometry | |
1559 | |
1560 QList<QScreen *> screen_list = QGuiApplication::screens (); | |
1561 if ((screen_list.length () > 1) && (av_geom == geom)) | |
1562 { | |
1563 // If we have more than one monitor and available and total | |
1564 // geometry are the same, reduce this too large geometry | |
1565 QRect new_geom (av_geom.x () + 1, av_geom.y () + 1, | |
1566 av_geom.width ()-2, av_geom.height ()-2); | |
1567 setGeometry (new_geom); | |
1568 } | |
1569 else | |
1570 setGeometry (av_geom); // Set (correct) available geometry | |
1547 } | 1571 } |
1548 | 1572 |
1549 if (! restoreState (settings->value (mw_state).toByteArray ())) | 1573 if (! restoreState (settings->value (mw_state).toByteArray ())) |
1550 { | 1574 { |
1551 do_reset_windows (true); | 1575 do_reset_windows (true); |