mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-04-10 08:21:13 -04:00
feat: add skip timer to avoid rermanently block render
This commit is contained in:
parent
02067e3b1e
commit
842b45b584
1 changed files with 42 additions and 0 deletions
42
src/mango.c
42
src/mango.c
|
|
@ -502,6 +502,7 @@ struct Monitor {
|
||||||
struct wl_listener request_state;
|
struct wl_listener request_state;
|
||||||
struct wl_listener destroy_lock_surface;
|
struct wl_listener destroy_lock_surface;
|
||||||
struct wlr_session_lock_surface_v1 *lock_surface;
|
struct wlr_session_lock_surface_v1 *lock_surface;
|
||||||
|
struct wl_event_source *skip_timeout;
|
||||||
struct wlr_box m; /* monitor area, layout-relative */
|
struct wlr_box m; /* monitor area, layout-relative */
|
||||||
struct wlr_box w; /* window area, layout-relative */
|
struct wlr_box w; /* window area, layout-relative */
|
||||||
struct wl_list layers[4]; /* LayerSurface::link */
|
struct wl_list layers[4]; /* LayerSurface::link */
|
||||||
|
|
@ -783,6 +784,7 @@ static Client *get_scroll_stack_head(Client *c);
|
||||||
static bool client_only_in_one_tag(Client *c);
|
static bool client_only_in_one_tag(Client *c);
|
||||||
static Client *get_focused_stack_client(Client *sc);
|
static Client *get_focused_stack_client(Client *sc);
|
||||||
static bool client_is_in_same_stack(Client *sc, Client *tc, Client *fc);
|
static bool client_is_in_same_stack(Client *sc, Client *tc, Client *fc);
|
||||||
|
static void destroy_monitor_skip_timer(Monitor *m);
|
||||||
|
|
||||||
#include "data/static_keymap.h"
|
#include "data/static_keymap.h"
|
||||||
#include "dispatch/bind_declare.h"
|
#include "dispatch/bind_declare.h"
|
||||||
|
|
@ -2223,6 +2225,9 @@ void cleanupmon(struct wl_listener *listener, void *data) {
|
||||||
wlr_scene_node_destroy(&m->blur->node);
|
wlr_scene_node_destroy(&m->blur->node);
|
||||||
m->blur = NULL;
|
m->blur = NULL;
|
||||||
}
|
}
|
||||||
|
if (m->skip_timeout) {
|
||||||
|
destroy_monitor_skip_timer(m);
|
||||||
|
}
|
||||||
m->wlr_output->data = NULL;
|
m->wlr_output->data = NULL;
|
||||||
free(m->pertag);
|
free(m->pertag);
|
||||||
free(m);
|
free(m);
|
||||||
|
|
@ -2774,6 +2779,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
m = wlr_output->data = ecalloc(1, sizeof(*m));
|
m = wlr_output->data = ecalloc(1, sizeof(*m));
|
||||||
m->wlr_output = wlr_output;
|
m->wlr_output = wlr_output;
|
||||||
m->wlr_output->data = m;
|
m->wlr_output->data = m;
|
||||||
|
m->skip_timeout = NULL;
|
||||||
|
|
||||||
wl_list_init(&m->dwl_ipc_outputs);
|
wl_list_init(&m->dwl_ipc_outputs);
|
||||||
|
|
||||||
|
|
@ -4419,6 +4425,37 @@ void client_set_opacity(Client *c, double opacity) {
|
||||||
scene_buffer_apply_opacity, &opacity);
|
scene_buffer_apply_opacity, &opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void destroy_monitor_skip_timer(Monitor *m) {
|
||||||
|
if (m->skip_timeout) {
|
||||||
|
wl_event_source_timer_update(m->skip_timeout, 0);
|
||||||
|
wl_event_source_remove(m->skip_timeout);
|
||||||
|
m->skip_timeout = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int skip_timeout_callback(void *data) {
|
||||||
|
Monitor *m = data;
|
||||||
|
Client *c, *tmp;
|
||||||
|
|
||||||
|
wl_list_for_each_safe(c, tmp, &clients, link) { c->configure_serial = 0; }
|
||||||
|
|
||||||
|
if (m->skip_timeout) {
|
||||||
|
destroy_monitor_skip_timer(m);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void check_skip_timeout(Monitor *m) {
|
||||||
|
if (m->skip_timeout) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
struct wl_event_loop *loop = wl_display_get_event_loop(dpy);
|
||||||
|
m->skip_timeout = wl_event_loop_add_timer(loop, skip_timeout_callback, m);
|
||||||
|
if (m->skip_timeout) {
|
||||||
|
wl_event_source_timer_update(m->skip_timeout, 100); // 100ms
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void rendermon(struct wl_listener *listener, void *data) {
|
void rendermon(struct wl_listener *listener, void *data) {
|
||||||
Monitor *m = wl_container_of(listener, m, frame);
|
Monitor *m = wl_container_of(listener, m, frame);
|
||||||
Client *c = NULL, *tmp = NULL;
|
Client *c = NULL, *tmp = NULL;
|
||||||
|
|
@ -4461,10 +4498,15 @@ void rendermon(struct wl_listener *listener, void *data) {
|
||||||
if (!animations && !(allow_tearing && frame_allow_tearing) &&
|
if (!animations && !(allow_tearing && frame_allow_tearing) &&
|
||||||
c->configure_serial && client_is_rendered_on_mon(c, m) &&
|
c->configure_serial && client_is_rendered_on_mon(c, m) &&
|
||||||
!client_is_stopped(c)) {
|
!client_is_stopped(c)) {
|
||||||
|
check_skip_timeout(m);
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m->skip_timeout) {
|
||||||
|
destroy_monitor_skip_timer(m);
|
||||||
|
}
|
||||||
|
|
||||||
// 只有在需要帧时才构建和提交状态
|
// 只有在需要帧时才构建和提交状态
|
||||||
if (allow_tearing && frame_allow_tearing) {
|
if (allow_tearing && frame_allow_tearing) {
|
||||||
apply_tear_state(m);
|
apply_tear_state(m);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue