不使用单独的客户端动画计时器,采取统一提交的方式,让动画更加一致

This commit is contained in:
DreamMaoMao 2025-02-21 20:09:32 +08:00
parent ce23c4bc20
commit 343fecae8a

View file

@ -235,7 +235,7 @@ typedef struct {
float scroller_proportion;
bool need_set_position;
struct dwl_animation animation;
struct wl_event_source *timer_tick;
// struct wl_event_source *timer_tick;
} Client;
@ -551,7 +551,7 @@ void incovgaps(const Arg *arg);
void incigaps(const Arg *arg);
void defaultgaps(const Arg *arg);
void buffer_set_size(Client *c, animationScale scale_data);
int timer_tick_action(void *data);
// int timer_tick_action(void *data);
#include "dispatch.h"
@ -3131,8 +3131,8 @@ mapnotify(struct wl_listener *listener, void *data) {
c->scene->node.data = c->scene_surface->node.data = c;
client_get_geometry(c, &c->geom);
c->timer_tick = wl_event_loop_add_timer(wl_display_get_event_loop(dpy), timer_tick_action, c);
wl_event_source_timer_update(c->timer_tick, 0);
// c->timer_tick = wl_event_loop_add_timer(wl_display_get_event_loop(dpy), timer_tick_action, c);
// wl_event_source_timer_update(c->timer_tick, 0);
/* Handle unmanaged clients first so we can return prior create borders */
if (client_is_unmanaged(c)) {
@ -3692,12 +3692,14 @@ void rendermon(struct wl_listener *listener, void *data) {
struct wlr_output_state pending = {0};
struct timespec now;
bool need_more_frames = false;
// Draw frames for all clients
wl_list_for_each(c, &clients, link) {
client_draw_frame(c);
need_more_frames = client_draw_frame(c) || need_more_frames;
}
wlr_scene_output_commit(m->scene_output, NULL);
// Send frame done notification
@ -3706,6 +3708,10 @@ void rendermon(struct wl_listener *listener, void *data) {
// // Clean up pending state
wlr_output_state_finish(&pending);
if (need_more_frames) {
wlr_output_schedule_frame(m->wlr_output);
}
}
void // 0.5
@ -3907,7 +3913,7 @@ void resize(Client *c, struct wlr_box geo, int interact) {
if (!c->mon)
return;
wl_event_source_timer_update(c->timer_tick, 10);
// wl_event_source_timer_update(c->timer_tick, 10);
c->need_set_position = true;
// oldgeom = c->geom;
bbox = interact ? &sgeom : &c->mon->w;
@ -4394,18 +4400,18 @@ void signalhandler(int signalnumber) {
// 不调用 exit 以允许生成核心转储文件
}
int timer_tick_action(void *data) {
Client *c = (Client *)data;
// int timer_tick_action(void *data) {
// Client *c = (Client *)data;
if (c->animation.running) {
wlr_output_schedule_frame(c->mon->wlr_output);
wl_event_source_timer_update(c->timer_tick, 10);
} else {
wl_event_source_timer_update(c->timer_tick, 0);
}
// if (c->animation.running) {
// wlr_output_schedule_frame(c->mon->wlr_output);
// wl_event_source_timer_update(c->timer_tick, 10);
// } else {
// wl_event_source_timer_update(c->timer_tick, 0);
// }
return 0;
}
// return 0;
// }
void setup(void) {
@ -5428,7 +5434,7 @@ void unmapnotify(struct wl_listener *listener, void *data) {
wlr_foreign_toplevel_handle_v1_destroy(c->foreign_toplevel);
c->foreign_toplevel = NULL;
}
wl_event_source_remove(c->timer_tick);
// wl_event_source_remove(c->timer_tick);
wlr_scene_node_destroy(&c->scene->node);
printstatus();
motionnotify(0, NULL, 0, 0, 0, 0);