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.
This commit is contained in:
hippoz 2022-05-14 11:31:57 +03:00
parent c85c367e11
commit 8251532938
Signed by: hippoz
GPG key ID: 7C52899193467641

View file

@ -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; m_is_focused = update_focus_to;
auto focus_update_event = FocusUpdateEvent(update_focus_to); auto focus_update_event = FocusUpdateEvent(update_focus_to);
on_focus_update(focus_update_event); on_focus_update(focus_update_event);
@ -187,6 +190,9 @@ void Widget::handle_mouse_button_event(MouseButtonEvent &event) {
return; return;
} }
if (m_is_active == update_activation_to)
return;
m_is_active = update_activation_to; m_is_active = update_activation_to;
auto activation_update_event = ActivationUpdateEvent(update_activation_to); auto activation_update_event = ActivationUpdateEvent(update_activation_to);
on_activation_update(activation_update_event); on_activation_update(activation_update_event);