mirror of
https://codeberg.org/dwl/dwl.git
synced 2026-02-05 10:43:07 +00:00
make rendermon more straightforward
Prior to damage tracking, we had to make sure wlr_output_commit was called even if we weren't rendering anything new. If we didn't, then nothing would render after attempting the first window resize. This is no longer a problem (maybe because adding damage schedules another frame callback?), so we can do some normal early-returns here.
This commit is contained in:
parent
38fe384783
commit
8616d947b7
32
dwl.c
32
dwl.c
@ -1758,7 +1758,7 @@ void
|
|||||||
rendermon(struct wl_listener *listener, void *data)
|
rendermon(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
int render = 1;
|
int render;
|
||||||
bool needs_frame;
|
bool needs_frame;
|
||||||
pixman_region32_t damage;
|
pixman_region32_t damage;
|
||||||
|
|
||||||
@ -1769,19 +1769,26 @@ rendermon(struct wl_listener *listener, void *data)
|
|||||||
struct timespec now;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
/* Do not render if any XDG clients have an outstanding resize. */
|
/* If there is any XDG client which is awaiting resize, request a new
|
||||||
|
* frame from that client, and do not render anything new until there
|
||||||
|
* are no pending resizes remaining. */
|
||||||
wl_list_for_each(c, &stack, slink) {
|
wl_list_for_each(c, &stack, slink) {
|
||||||
if (c->resize) {
|
if (c->resize) {
|
||||||
wlr_surface_send_frame_done(client_surface(c), &now);
|
wlr_surface_send_frame_done(client_surface(c), &now);
|
||||||
render = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pixman_region32_init(&damage);
|
|
||||||
if (!wlr_output_damage_attach_render(m->damage, &needs_frame, &damage))
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do not render if no new frame is needed */
|
||||||
|
pixman_region32_init(&damage);
|
||||||
|
render = wlr_output_damage_attach_render(m->damage, &needs_frame, &damage);
|
||||||
|
pixman_region32_fini(&damage);
|
||||||
|
if (!render || !needs_frame) {
|
||||||
|
/* Rollback is needed because attach_render is double-buffered */
|
||||||
|
wlr_output_rollback(m->wlr_output);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (render && needs_frame) {
|
|
||||||
/* Begin the renderer (calls glViewport and some other GL sanity checks) */
|
/* Begin the renderer (calls glViewport and some other GL sanity checks) */
|
||||||
wlr_renderer_begin(drw, m->wlr_output->width, m->wlr_output->height);
|
wlr_renderer_begin(drw, m->wlr_output->width, m->wlr_output->height);
|
||||||
wlr_renderer_clear(drw, rootcolor);
|
wlr_renderer_clear(drw, rootcolor);
|
||||||
@ -1806,14 +1813,7 @@ rendermon(struct wl_listener *listener, void *data)
|
|||||||
/* Conclude rendering and swap the buffers, showing the final frame
|
/* Conclude rendering and swap the buffers, showing the final frame
|
||||||
* on-screen. */
|
* on-screen. */
|
||||||
wlr_renderer_end(drw);
|
wlr_renderer_end(drw);
|
||||||
|
|
||||||
wlr_output_set_damage(m->wlr_output, &m->damage->current);
|
wlr_output_set_damage(m->wlr_output, &m->damage->current);
|
||||||
} else {
|
|
||||||
wlr_output_rollback(m->wlr_output);
|
|
||||||
}
|
|
||||||
|
|
||||||
pixman_region32_fini(&damage);
|
|
||||||
|
|
||||||
wlr_output_commit(m->wlr_output);
|
wlr_output_commit(m->wlr_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user