From e7d5b5b866940213eeb06fd5c778c52b5f762bdb Mon Sep 17 00:00:00 2001 From: Lukas W Date: Fri, 5 May 2017 16:59:44 +0200 Subject: [PATCH] Subwindow detach: Fix minor pos & size issues --- src/gui/SubWindow.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) 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); }