diff --git a/src/window.cpp b/src/window.cpp index e8bbfbf5d6..16a43e0fdd 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1010,9 +1010,10 @@ void Window::SetDirty() const * Re-initialize a window, and optionally change its size. * @param rx Horizontal resize of the window. * @param ry Vertical resize of the window. + * @param reposition If set, reposition the window to default location. * @note For just resizing the window, use #ResizeWindow instead. */ -void Window::ReInit(int rx, int ry) +void Window::ReInit(int rx, int ry, bool reposition) { this->SetDirty(); // Mark whole current window as dirty. @@ -1039,6 +1040,12 @@ void Window::ReInit(int rx, int ry) if (this->resize.step_width > 1) dx -= dx % (int)this->resize.step_width; if (this->resize.step_height > 1) dy -= dy % (int)this->resize.step_height; + if (reposition) { + Point pt = this->OnInitialPosition(this->nested_root->smallest_x, this->nested_root->smallest_y, window_number); + this->InitializePositionSize(pt.x, pt.y, this->nested_root->smallest_x, this->nested_root->smallest_y); + this->FindWindowPlacementAndResize(this->window_desc->GetDefaultWidth(), this->window_desc->GetDefaultHeight()); + } + ResizeWindow(this, dx, dy); /* ResizeWindow() does this->SetDirty() already, no need to do it again here. */ } diff --git a/src/window_gui.h b/src/window_gui.h index c9825ab686..c94af5d84b 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -449,7 +449,7 @@ public: static void DeleteClosedWindows(); void SetDirty() const; - void ReInit(int rx = 0, int ry = 0); + void ReInit(int rx = 0, int ry = 0, bool reposition = false); /** Is window shaded currently? */ inline bool IsShaded() const