mirror of
https://codeberg.org/dwl/dwl.git
synced 2026-04-08 08:21:00 -04:00
Simpler damage implementation
This commit is contained in:
parent
1e3a66478d
commit
e17445bb43
2 changed files with 16 additions and 29 deletions
43
dwl.c
43
dwl.c
|
|
@ -26,7 +26,6 @@
|
|||
#include <wlr/types/wlr_keyboard.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_output_damage.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_output_management_v1.h>
|
||||
#include <wlr/types/wlr_pointer.h>
|
||||
|
|
@ -147,7 +146,6 @@ typedef struct {
|
|||
|
||||
struct wlr_box geo;
|
||||
enum zwlr_layer_shell_v1_layer layer;
|
||||
Monitor *mon;
|
||||
} LayerSurface;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -178,7 +176,7 @@ struct Monitor {
|
|||
double mfact;
|
||||
int nmaster;
|
||||
Client *fullscreenclient;
|
||||
struct wlr_output_damage *damage;
|
||||
int isdamaged;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -773,8 +771,7 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
|
|||
layersurface->layer = wlr_layer_surface->current.layer;
|
||||
}
|
||||
|
||||
// Damage the whole screen
|
||||
wlr_output_damage_add_whole(m->damage);
|
||||
m->isdamaged = true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -786,9 +783,8 @@ commitnotify(struct wl_listener *listener, void *data)
|
|||
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);
|
||||
c->mon->isdamaged = true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -833,7 +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->isdamaged = 1;
|
||||
m->tagset[0] = m->tagset[1] = 1;
|
||||
for (r = monrules; r < END(monrules); r++) {
|
||||
if (!r->name || strstr(wlr_output->name, r->name)) {
|
||||
|
|
@ -1025,9 +1021,8 @@ destroynotify(struct wl_listener *listener, void *data)
|
|||
/* Called when the surface is destroyed and should never be shown again. */
|
||||
Client *c = wl_container_of(listener, c, destroy);
|
||||
|
||||
// Damage the whole screen
|
||||
if (c->mon)
|
||||
wlr_output_damage_add_whole(c->mon->damage);
|
||||
c->mon->isdamaged = true;
|
||||
|
||||
wl_list_remove(&c->map.link);
|
||||
wl_list_remove(&c->unmap.link);
|
||||
|
|
@ -1371,8 +1366,7 @@ mapnotify(struct wl_listener *listener, void *data)
|
|||
/* Set initial monitor, tags, floating status, and focus */
|
||||
applyrules(c);
|
||||
|
||||
// Damage the whole screen
|
||||
wlr_output_damage_add_whole(c->mon->damage);
|
||||
c->mon->isdamaged = true;
|
||||
|
||||
if (c->mon->fullscreenclient && c->mon->fullscreenclient == oldfocus
|
||||
&& !c->isfloating && c->mon->lt[c->mon->sellt]->arrange) {
|
||||
|
|
@ -1775,13 +1769,14 @@ rendermon(struct wl_listener *listener, void *data)
|
|||
}
|
||||
}
|
||||
|
||||
bool needs_frame;
|
||||
pixman_region32_t damage;
|
||||
pixman_region32_init(&damage);
|
||||
if (!wlr_output_damage_attach_render(m->damage, &needs_frame, &damage))
|
||||
/* wlr_output_attach_render makes the OpenGL context current. */
|
||||
if (!wlr_output_attach_render(m->wlr_output, NULL))
|
||||
return;
|
||||
|
||||
if (render && needs_frame) {
|
||||
// We must render the monitor twice, once for each buffer, each time damage occurs
|
||||
if (render && (m->isdamaged > -1)) {
|
||||
m->isdamaged--;
|
||||
|
||||
/* 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);
|
||||
|
|
@ -1806,14 +1801,8 @@ 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);
|
||||
}
|
||||
|
||||
|
|
@ -1971,7 +1960,7 @@ setmon(Client *c, Monitor *m, unsigned int newtags)
|
|||
if (oldmon) {
|
||||
wlr_surface_send_leave(client_surface(c), oldmon->wlr_output);
|
||||
arrange(oldmon);
|
||||
wlr_output_damage_add_whole(oldmon->damage);
|
||||
oldmon->isdamaged = true;
|
||||
}
|
||||
if (m) {
|
||||
/* Make sure window actually overlaps with the monitor */
|
||||
|
|
@ -1979,7 +1968,7 @@ setmon(Client *c, Monitor *m, unsigned int newtags)
|
|||
wlr_surface_send_enter(client_surface(c), m->wlr_output);
|
||||
c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||
arrange(m);
|
||||
wlr_output_damage_add_whole(m->damage);
|
||||
m->isdamaged = true;
|
||||
}
|
||||
focusclient(focustop(selmon), 1);
|
||||
}
|
||||
|
|
@ -2299,9 +2288,7 @@ unmapnotify(struct wl_listener *listener, void *data)
|
|||
/* Called when the surface is unmapped, and should no longer be shown. */
|
||||
Client *c = wl_container_of(listener, c, unmap);
|
||||
|
||||
// Damage the whole screen
|
||||
if (c->mon)
|
||||
wlr_output_damage_add_whole(c->mon->damage);
|
||||
c->mon->isdamaged = true;
|
||||
|
||||
wl_list_remove(&c->link);
|
||||
if (client_is_unmanaged(c))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue