From 934ac65e9a23091d864df40285dda2a34bdbbeee Mon Sep 17 00:00:00 2001 From: SpomJ Date: Mon, 18 May 2026 12:47:21 +0300 Subject: [PATCH 1/3] More fundamental fix Removes layout constraints when child is hidden, reapplies when child is shown. --- src/gui/SubWindow.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index c107699252a..ceab5e2606b 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -169,7 +169,7 @@ void SubWindow::changeEvent( QEvent *event ) void SubWindow::setVisible(bool visible) { - if (isDetached()) + if (isDetached() || visible) { // When detached, top-level window is the child widget itself. (This is janky and is best changed at some point.) // For that reason we forward show/hide to the child widget, and don't touch the hidden attached window frame. @@ -178,11 +178,7 @@ void SubWindow::setVisible(bool visible) else { // When attached, visibility of the actual window is controlled by SubWindow. - // SubWindow::hide() when it's already hidden still causes a size recalculation, - // if the child widget is hidden it does not get included into the layout, and maximum size is set to 0x0. - // There shouldn't be a reason to keep the child widget hidden when the subwindow is attached. - // see bug #8292 - widget()->show(); + // Nevertheless, the subwindow contents still need to be visible, which is addressed above. QMdiSubWindow::setVisible(visible); } } @@ -617,10 +613,6 @@ bool SubWindow::eventFilter(QObject* obj, QEvent* event) switch (event->type()) { - case QEvent::WindowStateChange: - event->accept(); - return true; - case QEvent::Close: if (isDetached()) { @@ -649,6 +641,14 @@ bool SubWindow::eventFilter(QObject* obj, QEvent* event) hide(); } return QMdiSubWindow::eventFilter(obj, event); + + case QEvent::Hide: + layout()->setSizeConstraint(QLayout::SetNoConstraint); + return QMdiSubWindow::eventFilter(obj, event); + + case QEvent::Show: + layout()->setSizeConstraint(QLayout::SetMinAndMaxSize); + return QMdiSubWindow::eventFilter(obj, event); default: return QMdiSubWindow::eventFilter(obj, event); From 8f51e9595de3165bc4ea530b71c86848e29bd05e Mon Sep 17 00:00:00 2001 From: SpomJ Date: Tue, 19 May 2026 02:22:01 +0300 Subject: [PATCH 2/3] fix dumb oversight I didn't fully soft-revert the last fix so this happened. The issue was that `|| visible` would steal the thing and QMdiSubWindow handler wouldn't execute which is important for doing pretty much everything about the window frame. --- src/gui/SubWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index ceab5e2606b..c8747021351 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -175,7 +175,7 @@ void SubWindow::setVisible(bool visible) // For that reason we forward show/hide to the child widget, and don't touch the hidden attached window frame. widget()->setVisible(visible); } - else + if (!isDetached()) { // When attached, visibility of the actual window is controlled by SubWindow. // Nevertheless, the subwindow contents still need to be visible, which is addressed above. From 9f714038a85d186063c9db12b9104942f8eb6a87 Mon Sep 17 00:00:00 2001 From: SpomJ Date: Tue, 19 May 2026 09:57:00 +0300 Subject: [PATCH 3/3] force a resize after layout is reset --- src/gui/SubWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index c8747021351..aa5e0a9427d 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -648,6 +648,7 @@ bool SubWindow::eventFilter(QObject* obj, QEvent* event) case QEvent::Show: layout()->setSizeConstraint(QLayout::SetMinAndMaxSize); + resize(widget()->size().addMargins(decorationMargins())); // manually sync the sizes again return QMdiSubWindow::eventFilter(obj, event); default: