diff options
-rw-r--r-- | include/cru/ui/WindowHost.hpp | 1 | ||||
-rw-r--r-- | src/ui/WindowHost.cpp | 21 |
2 files changed, 8 insertions, 14 deletions
diff --git a/include/cru/ui/WindowHost.hpp b/include/cru/ui/WindowHost.hpp index 97acf72e..7f7d62f0 100644 --- a/include/cru/ui/WindowHost.hpp +++ b/include/cru/ui/WindowHost.hpp @@ -126,7 +126,6 @@ class WindowHost : public Object { platform::gui::INativeWindow* native_window_ = nullptr; bool need_layout_ = false; - platform::gui::TimerAutoCanceler relayout_timer_canceler_; Event<AfterLayoutEventArgs> after_layout_event_; std::vector<std::function<void()> > after_layout_stable_action_; diff --git a/src/ui/WindowHost.cpp b/src/ui/WindowHost.cpp index 4b32467b..b0908e4f 100644 --- a/src/ui/WindowHost.cpp +++ b/src/ui/WindowHost.cpp @@ -146,16 +146,8 @@ void WindowHost::InvalidatePaint() { } void WindowHost::InvalidateLayout() { - if constexpr (debug_flags::layout) - log::TagDebug(log_tag, u"A relayout is requested."); - if (!need_layout_) { - platform::gui::IUiApplication::GetInstance()->SetImmediate([this] { - Relayout(); - need_layout_ = false; - InvalidatePaint(); - }); - need_layout_ = true; - } + need_layout_ = true; + this->InvalidatePaint(); } bool WindowHost::IsLayoutPreferToFillWindow() const { @@ -253,11 +245,14 @@ void WindowHost::RunAfterLayoutStable(std::function<void()> action) { void WindowHost::OnNativeDestroy(INativeWindow* window, std::nullptr_t) { CRU_UNUSED(window) - this->relayout_timer_canceler_.Reset(); this->native_window_ = nullptr; } void WindowHost::OnNativePaint(INativeWindow* window, std::nullptr_t) { + if (need_layout_) { + Relayout(); + need_layout_ = false; + } auto painter = window->BeginPaint(); painter->Clear(colors::white); root_render_object_->Draw(painter.get()); @@ -356,8 +351,8 @@ void WindowHost::OnNativeKeyDown( nullptr, args.key, args.modifier); } -void WindowHost::OnNativeKeyUp( - INativeWindow* window, const platform::gui::NativeKeyEventArgs& args) { +void WindowHost::OnNativeKeyUp(INativeWindow* window, + const platform::gui::NativeKeyEventArgs& args) { CRU_UNUSED(window) DispatchEvent(event_names::KeyUp, focus_control_, &Control::KeyUpEvent, |