From 343fecae8ab8fac826d0fc297068430c86127242 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Fri, 21 Feb 2025 20:09:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E4=BD=BF=E7=94=A8=E5=8D=95=E7=8B=AC?= =?UTF-8?q?=E7=9A=84=E5=AE=A2=E6=88=B7=E7=AB=AF=E5=8A=A8=E7=94=BB=E8=AE=A1?= =?UTF-8?q?=E6=97=B6=E5=99=A8=EF=BC=8C=E9=87=87=E5=8F=96=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E7=9A=84=E6=96=B9=E5=BC=8F=EF=BC=8C=E8=AE=A9?= =?UTF-8?q?=E5=8A=A8=E7=94=BB=E6=9B=B4=E5=8A=A0=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maomao.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/maomao.c b/maomao.c index 3dcf1ef3..ea8289e3 100644 --- a/maomao.c +++ b/maomao.c @@ -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);