diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index 1e47f0fb028..1ae149edfde 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -26,9 +26,11 @@ #include "SubWindow.h" -#include -#include -#include +#include +#include +#include +#include +#include #include "embed.h" @@ -233,8 +235,9 @@ void SubWindow::detach() auto pos = mapToGlobal(widget()->pos()); widget()->setWindowFlags(Qt::Window); widget()->show(); - widget()->move(pos); hide(); + + widget()->windowHandle()->setPosition(pos); } void SubWindow::attach() @@ -242,11 +245,18 @@ void SubWindow::attach() if (! widget()->windowFlags().testFlag(Qt::Window)) { return; } - auto pos = widget()->pos(); + auto frame = widget()->windowHandle()->frameGeometry(); + widget()->setWindowFlags(Qt::Widget); widget()->show(); show(); - move(mdiArea()->mapFromGlobal(pos)); + + // Delay moving & resizing using event queue. Ensures that this widget is + // visible first, so that resizing works. + QObject o;connect(&o, &QObject::destroyed, this, [this, frame]() { + move(mdiArea()->mapFromGlobal(frame.topLeft())); + resize(frame.size()); + }, Qt::QueuedConnection); }