diff --git a/src/mirage.cpp b/src/mirage.cpp index 44f9ee3..fb8ee4f 100644 --- a/src/mirage.cpp +++ b/src/mirage.cpp @@ -53,8 +53,8 @@ void mirage_app::run() { widget_manager::get().update(); last_time = get_current_time(); - // std::this_thread::sleep_for(std::chrono::milliseconds(1)); - std::this_thread::yield(); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + // std::this_thread::yield(); } running = false; render_context->cleanup(); diff --git a/src/widget/mwidget.h b/src/widget/mwidget.h index 3ecca57..dc23e61 100644 --- a/src/widget/mwidget.h +++ b/src/widget/mwidget.h @@ -57,6 +57,9 @@ public: void set_parent(const widget_key& in_parent); virtual void invalidate(invalidate_reason in_reason); + auto has_invalidate_reason(invalidate_reason in_reason) const { return get_component_ref().has(in_reason); } + void clear_invalidate_reason(invalidate_reason in_reason) { get_component_ref().unset(in_reason); } + auto get_invalidation_reason() const { return get_component_ref().invalidate; } auto is_enabled() const { return get_component_ref().is_enabled(); } diff --git a/src/widget_tree/widget_system.cpp b/src/widget_tree/widget_system.cpp index 1dfa225..a148e62 100644 --- a/src/widget_tree/widget_system.cpp +++ b/src/widget_tree/widget_system.cpp @@ -224,6 +224,8 @@ void widget_render_system::onUpdate(mustache::World& in_world) { return; if (!window->is_visible()) return; + if (!window->has_invalidate_reason(invalidate_reason::paint)) + return; auto& window_state = window->get_state(); @@ -248,6 +250,7 @@ void widget_render_system::onUpdate(mustache::World& in_world) { sg_commit(); window_state.present(); + window->clear_invalidate_reason(invalidate_reason::paint); } void widget_render_system::paint(const widget_key& in_key) {