diff --git a/Makefile b/Makefile index a0d1cc3..81bf017 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ CFLAGS += -I. -DWLR_USE_UNSTABLE -std=c99 WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols) WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner) -PKGS = wlroots wayland-server xcb xkbcommon libinput +PKGS = wlroots wayland-server xcb xkbcommon libinput pixman-1 CFLAGS += $(foreach p,$(PKGS),$(shell pkg-config --cflags $(p))) LDLIBS += $(foreach p,$(PKGS),$(shell pkg-config --libs $(p))) diff --git a/dwl.c b/dwl.c index 4098f86..9f2367c 100644 --- a/dwl.c +++ b/dwl.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -176,6 +177,7 @@ struct Monitor { double mfact; int nmaster; Client *fullscreenclient; + struct wlr_output_damage *damage; }; typedef struct { @@ -779,6 +781,10 @@ commitnotify(struct wl_listener *listener, void *data) /* mark a pending resize as completed */ if (c->resize && c->resize <= c->surface.xdg->configure_serial) c->resize = 0; + + // Damage the whole screen + if (c->mon) + wlr_output_damage_add_whole(c->mon->damage); } void @@ -823,6 +829,7 @@ createmon(struct wl_listener *listener, void *data) /* Initialize monitor state using configured rules */ for (size_t i = 0; i < LENGTH(m->layers); i++) wl_list_init(&m->layers[i]); + m->damage = wlr_output_damage_create(wlr_output); m->tagset[0] = m->tagset[1] = 1; for (r = monrules; r < END(monrules); r++) { if (!r->name || strstr(wlr_output->name, r->name)) { @@ -1760,7 +1767,14 @@ rendermon(struct wl_listener *listener, void *data) if (!wlr_output_attach_render(m->wlr_output, NULL)) return; - if (render) { + bool needs_frame; + pixman_region32_t damage; + pixman_region32_init(&damage); + if (!wlr_output_damage_attach_render(m->damage, &needs_frame, &damage)) { + BARF("Cannot make damage output current"); + } + + if (render && needs_frame) { /* 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_clear(drw, rootcolor); @@ -1785,8 +1799,14 @@ rendermon(struct wl_listener *listener, void *data) /* Conclude rendering and swap the buffers, showing the final frame * on-screen. */ wlr_renderer_end(drw); + + 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); }