opt:avoid not refreshing the last frame of the animation

This commit is contained in:
DreamMaoMao 2025-02-24 11:03:55 +08:00
parent b7c32a0223
commit 88b78a6679

View file

@ -233,7 +233,7 @@ typedef struct {
bool is_open_animation; bool is_open_animation;
bool is_restoring_from_ov; bool is_restoring_from_ov;
float scroller_proportion; float scroller_proportion;
bool need_set_position; bool need_output_flush;
struct dwl_animation animation; struct dwl_animation animation;
// struct wl_event_source *timer_tick; // struct wl_event_source *timer_tick;
@ -714,7 +714,7 @@ double find_animation_curve_at(double t) {
return baked_points[up].y; return baked_points[up].y;
} }
bool client_animation_next_tick(Client *c) { void client_animation_next_tick(Client *c) {
double animation_passed = double animation_passed =
(double)c->animation.passed_frames / c->animation.total_frames; (double)c->animation.passed_frames / c->animation.total_frames;
double factor = find_animation_curve_at(animation_passed); double factor = find_animation_curve_at(animation_passed);
@ -773,11 +773,11 @@ bool client_animation_next_tick(Client *c) {
if (surface && pointer_c == selmon->sel) { if (surface && pointer_c == selmon->sel) {
wlr_seat_pointer_notify_enter(seat, surface, sx, sy); wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
} }
c->need_set_position = false;
return false; // end flush in next frame, not the current frame
c->need_output_flush = false;
} else { } else {
c->animation.passed_frames++; c->animation.passed_frames++;
return true;
} }
} }
@ -897,23 +897,20 @@ bool client_draw_frame(Client *c) {
if (!c || !client_surface(c)->mapped) if (!c || !client_surface(c)->mapped)
return false; return false;
if (!c->need_set_position) if (!c->need_output_flush)
return false; return false;
bool need_more_frames = false;
if (c->animation.running) { if (c->animation.running) {
if (client_animation_next_tick(c)) { client_animation_next_tick(c);
need_more_frames = true;
}
client_apply_clip(c); client_apply_clip(c);
} else { } else {
wlr_scene_node_set_position(&c->scene->node, c->pending.x, c->pending.y); wlr_scene_node_set_position(&c->scene->node, c->pending.x, c->pending.y);
apply_border(c, c->pending, 0); apply_border(c, c->pending, 0);
client_apply_clip(c); client_apply_clip(c);
c->need_set_position = false; c->need_output_flush = false;
} }
// c->resize = 1; // c->resize = 1;
return need_more_frames; return true;
} }
void // 0.5 void // 0.5
@ -3937,7 +3934,7 @@ void resize(Client *c, struct wlr_box geo, int interact) {
return; return;
// wl_event_source_timer_update(c->timer_tick, 10); // wl_event_source_timer_update(c->timer_tick, 10);
c->need_set_position = true; c->need_output_flush = true;
// oldgeom = c->geom; // oldgeom = c->geom;
bbox = interact ? &sgeom : &c->mon->w; bbox = interact ? &sgeom : &c->mon->w;
@ -3991,7 +3988,7 @@ void resize(Client *c, struct wlr_box geo, int interact) {
if (c == grabc) { if (c == grabc) {
c->animation.running = false; c->animation.running = false;
c->need_set_position = false; c->need_output_flush = false;
c->animainit_geom = c->current = c->pending = c->animation.current = c->geom; c->animainit_geom = c->current = c->pending = c->animation.current = c->geom;
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y); wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
apply_border(c,c->geom, 0); apply_border(c,c->geom, 0);