From f9d41665f0b17e61778b77c59e85922f70a53ff7 Mon Sep 17 00:00:00 2001 From: Joshua Ogunyinka Date: Wed, 24 Nov 2021 11:10:57 +0400 Subject: [PATCH] Fix bounds getting reset when a dialog is closed (fix #3018) --- src/ui/manager.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp index 2170d2d87..fb3047c5d 100644 --- a/src/ui/manager.cpp +++ b/src/ui/manager.cpp @@ -1490,6 +1490,19 @@ void Manager::_closeWindow(Window* window, bool redraw_background) ASSERT(windowDisplay); ASSERT(windowDisplay != this->display()); + // Just as we've set the origin of the window bounds to (0, 0) + // when we created the native window, we have to restore the + // ui::Window bounds' origin now that we are going to remove/close + // the native window. + if (parentDisplay && windowDisplay) { + const int scale = parentDisplay->nativeWindow()->scale(); + const gfx::Point parentOrigin = parentDisplay->nativeWindow()->contentRect().origin(); + const gfx::Point origin = windowDisplay->nativeWindow()->contentRect().origin(); + const gfx::Rect newBounds((origin - parentOrigin) / scale, + window->bounds().size()); + window->setBounds(newBounds); + } + // Remove all messages for this display. removeMessagesForDisplay(windowDisplay);