From 4c10ad581b10bac1368ad8ca025c1ac33f0333e4 Mon Sep 17 00:00:00 2001 From: ldelossa Date: Thu, 12 Sep 2024 11:20:12 -0400 Subject: [PATCH] refactor: further simplify main UI element animations. Signed-off-by: ldelossa --- src/panel/message_tray/message_tray.c | 14 +++----------- src/panel/quick_settings/quick_settings.c | 14 +++----------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/panel/message_tray/message_tray.c b/src/panel/message_tray/message_tray.c index ad8d274..3e8e4e1 100644 --- a/src/panel/message_tray/message_tray.c +++ b/src/panel/message_tray/message_tray.c @@ -102,23 +102,15 @@ static void animation_close_done(AdwAnimation *animation, MessageTray *self) { }; void message_tray_set_hidden(MessageTray *self) { - int anim_state = 0; - g_debug("message_tray.c:message_tray_set_hidden() called."); - // this is required, since external callers will call this method as expect - // a no-op of there is no attached self->monitor. + // this is required, since external callers will call this method and expect + // a no-op if there is no attached self->monitor. if (!self || !self->win) { return; } - // this ensures there are no in-flight animation done callbacks on the - // event-loop before starting a new animation, and avoids timing bugs. - anim_state = adw_animation_get_state(self->animation); - if (anim_state != ADW_ANIMATION_IDLE && - anim_state != ADW_ANIMATION_FINISHED) { - adw_animation_reset(self->animation); - } + adw_animation_reset(self->animation); // reverse animation adw_timed_animation_set_reverse(ADW_TIMED_ANIMATION(self->animation), TRUE); diff --git a/src/panel/quick_settings/quick_settings.c b/src/panel/quick_settings/quick_settings.c index 35c4a9f..010f4fa 100644 --- a/src/panel/quick_settings/quick_settings.c +++ b/src/panel/quick_settings/quick_settings.c @@ -97,24 +97,16 @@ static void animation_close_done(AdwAnimation *animation, QuickSettings *self) { }; void quick_settings_set_hidden(QuickSettings *self) { - int anim_state = 0; - g_debug("quick_settings.c:quick_settings_set_hidden() called."); - // this is required, since external callers will call this method as expect - // a no-op of there is no attached self->panel. + // this is required, since external callers will call this method and expect + // a no-op if there is no attached self->panel. if (!self || !self->win) { g_debug("quick_settings.c:quick_settings_set_hidden() no-op."); return; } - // this ensures there are no in-flight animation done callbacks on the - // event-loop before starting a new animation, and avoids timing bugs. - anim_state = adw_animation_get_state(self->animation); - if (anim_state != ADW_ANIMATION_IDLE && - anim_state != ADW_ANIMATION_FINISHED) { - adw_animation_reset(self->animation); - } + adw_animation_reset(self->animation); // reverse animation adw_timed_animation_set_reverse(ADW_TIMED_ANIMATION(self->animation), TRUE);