From bed29872d2a7befff9d4cb7313cb40060326a95e Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 9 Nov 2020 20:45:27 +0800 Subject: ... --- src/ui/host/WindowHost.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/ui/host') diff --git a/src/ui/host/WindowHost.cpp b/src/ui/host/WindowHost.cpp index 1550361b..5e107733 100644 --- a/src/ui/host/WindowHost.cpp +++ b/src/ui/host/WindowHost.cpp @@ -150,6 +150,10 @@ gsl::not_null WindowHost::CreateNativeWindow( BindNativeEvent(this, native_window, native_window->KeyUpEvent(), &WindowHost::OnNativeKeyUp, event_revoker_guards_); + if (saved_rect_) { + native_window->SetWindowRect(saved_rect_.value()); + } + native_window_change_event_.Raise(native_window); return native_window_; @@ -263,8 +267,25 @@ void WindowHost::RunAfterLayoutStable(std::function action) { } } +Rect WindowHost::GetWindowRect() { + if (native_window_) return native_window_->GetWindowRect(); + return saved_rect_.value_or(Rect{}); +} + +void WindowHost::SetSavedWindowRect(std::optional rect) { + saved_rect_ = std::move(rect); +} + +void WindowHost::SetWindowRect(const Rect& rect) { + SetSavedWindowRect(rect); + if (native_window_) native_window_->SetWindowRect(rect); +} + void WindowHost::OnNativeDestroy(INativeWindow* window, std::nullptr_t) { CRU_UNUSED(window) + + saved_rect_ = this->native_window_->GetWindowRect(); + this->native_window_ = nullptr; event_revoker_guards_.clear(); -- cgit v1.2.3