From 8251532938391f508e1692c98299c97b47c0cf2e Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Sat, 14 May 2022 11:31:57 +0300 Subject: [PATCH] don't dispatch activation/focus events if the status did not change This commit prevents the dispatch of activation/focus events if the status did not change. This eliminates useless repaints when mousing around inside a button. --- src/Widget.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Widget.cpp b/src/Widget.cpp index efb57fc..7bc692d 100644 --- a/src/Widget.cpp +++ b/src/Widget.cpp @@ -167,6 +167,9 @@ void Widget::handle_mouse_move_event(MouseMoveEvent &event) { } } + if (m_is_focused == update_focus_to) + return; + m_is_focused = update_focus_to; auto focus_update_event = FocusUpdateEvent(update_focus_to); on_focus_update(focus_update_event); @@ -187,6 +190,9 @@ void Widget::handle_mouse_button_event(MouseButtonEvent &event) { return; } + if (m_is_active == update_activation_to) + return; + m_is_active = update_activation_to; auto activation_update_event = ActivationUpdateEvent(update_activation_to); on_activation_update(activation_update_event);