From 4cba4193df9a11cee862acd12f6216a0bfaf80c1 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 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index 690000b4e9d..2dc52deb0b2 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -29,9 +29,11 @@ #include "SubWindow.h" #include +#include #include #include #include +#include #include "embed.h" @@ -261,8 +263,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() @@ -270,11 +273,18 @@ void SubWindow::attach() if (! isDetached()) { 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); }