Skip to content

Commit

Permalink
refactor: further simplify main UI element animations.
Browse files Browse the repository at this point in the history
Signed-off-by: ldelossa <[email protected]>
  • Loading branch information
ldelossa committed Sep 12, 2024
1 parent ff824ab commit 4c10ad5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
14 changes: 3 additions & 11 deletions src/panel/message_tray/message_tray.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 3 additions & 11 deletions src/panel/quick_settings/quick_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4c10ad5

Please sign in to comment.