mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-04-05 07:15:49 -04:00
opt: optimize frame skip logic
This commit is contained in:
parent
842b45b584
commit
0696fe964d
1 changed files with 27 additions and 20 deletions
47
src/mango.c
47
src/mango.c
|
|
@ -508,6 +508,7 @@ struct Monitor {
|
||||||
struct wl_list layers[4]; /* LayerSurface::link */
|
struct wl_list layers[4]; /* LayerSurface::link */
|
||||||
uint32_t seltags;
|
uint32_t seltags;
|
||||||
uint32_t tagset[2];
|
uint32_t tagset[2];
|
||||||
|
bool skiping_frame;
|
||||||
|
|
||||||
struct wl_list dwl_ipc_outputs;
|
struct wl_list dwl_ipc_outputs;
|
||||||
int32_t gappih; /* horizontal gap between windows */
|
int32_t gappih; /* horizontal gap between windows */
|
||||||
|
|
@ -784,7 +785,8 @@ 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);
|
static void monitor_stop_skip_timer(Monitor *m);
|
||||||
|
static int monitor_skip_frame_timeout_callback(void *data);
|
||||||
|
|
||||||
#include "data/static_keymap.h"
|
#include "data/static_keymap.h"
|
||||||
#include "dispatch/bind_declare.h"
|
#include "dispatch/bind_declare.h"
|
||||||
|
|
@ -2226,7 +2228,9 @@ void cleanupmon(struct wl_listener *listener, void *data) {
|
||||||
m->blur = NULL;
|
m->blur = NULL;
|
||||||
}
|
}
|
||||||
if (m->skip_timeout) {
|
if (m->skip_timeout) {
|
||||||
destroy_monitor_skip_timer(m);
|
monitor_stop_skip_timer(m);
|
||||||
|
wl_event_source_remove(m->skip_timeout);
|
||||||
|
m->skip_timeout = NULL;
|
||||||
}
|
}
|
||||||
m->wlr_output->data = NULL;
|
m->wlr_output->data = NULL;
|
||||||
free(m->pertag);
|
free(m->pertag);
|
||||||
|
|
@ -2776,10 +2780,15 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct wl_event_loop *loop = wl_display_get_event_loop(dpy);
|
||||||
m = wlr_output->data = ecalloc(1, sizeof(*m));
|
m = wlr_output->data = ecalloc(1, sizeof(*m));
|
||||||
|
|
||||||
|
m->skip_timeout =
|
||||||
|
wl_event_loop_add_timer(loop, monitor_skip_frame_timeout_callback, m);
|
||||||
|
m->skiping_frame = false;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
@ -4425,34 +4434,32 @@ 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) {
|
void monitor_stop_skip_timer(Monitor *m) {
|
||||||
if (m->skip_timeout) {
|
if (m->skip_timeout)
|
||||||
wl_event_source_timer_update(m->skip_timeout, 0);
|
wl_event_source_timer_update(m->skip_timeout, 0);
|
||||||
wl_event_source_remove(m->skip_timeout);
|
m->skiping_frame = false;
|
||||||
m->skip_timeout = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int skip_timeout_callback(void *data) {
|
static int monitor_skip_frame_timeout_callback(void *data) {
|
||||||
Monitor *m = data;
|
Monitor *m = data;
|
||||||
Client *c, *tmp;
|
Client *c, *tmp;
|
||||||
|
|
||||||
wl_list_for_each_safe(c, tmp, &clients, link) { c->configure_serial = 0; }
|
wl_list_for_each_safe(c, tmp, &clients, link) { c->configure_serial = 0; }
|
||||||
|
|
||||||
if (m->skip_timeout) {
|
monitor_stop_skip_timer(m);
|
||||||
destroy_monitor_skip_timer(m);
|
wlr_output_schedule_frame(m->wlr_output);
|
||||||
}
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_skip_timeout(Monitor *m) {
|
void monitor_check_skip_frame_timeout(Monitor *m) {
|
||||||
if (m->skip_timeout) {
|
if (m->skiping_frame) {
|
||||||
return;
|
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) {
|
if (m->skip_timeout) {
|
||||||
wl_event_source_timer_update(m->skip_timeout, 100); // 100ms
|
wl_event_source_timer_update(m->skip_timeout, 100); // 100ms
|
||||||
|
m->skiping_frame = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4498,13 +4505,13 @@ 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);
|
monitor_check_skip_frame_timeout(m);
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->skip_timeout) {
|
if (m->skiping_frame) {
|
||||||
destroy_monitor_skip_timer(m);
|
monitor_stop_skip_timer(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 只有在需要帧时才构建和提交状态
|
// 只有在需要帧时才构建和提交状态
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue