mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-10-28 18:44:17 +00:00
Simpler damage implementation
This commit is contained in:
parent
1e3a66478d
commit
e17445bb43
2
Makefile
2
Makefile
@ -5,7 +5,7 @@ CFLAGS += -I. -DWLR_USE_UNSTABLE -std=c99
|
|||||||
WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols)
|
WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols)
|
||||||
WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner)
|
WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner)
|
||||||
|
|
||||||
PKGS = wlroots wayland-server xcb xkbcommon libinput pixman-1
|
PKGS = wlroots wayland-server xcb xkbcommon libinput
|
||||||
CFLAGS += $(foreach p,$(PKGS),$(shell pkg-config --cflags $(p)))
|
CFLAGS += $(foreach p,$(PKGS),$(shell pkg-config --cflags $(p)))
|
||||||
LDLIBS += $(foreach p,$(PKGS),$(shell pkg-config --libs $(p)))
|
LDLIBS += $(foreach p,$(PKGS),$(shell pkg-config --libs $(p)))
|
||||||
|
|
||||||
|
|||||||
43
dwl.c
43
dwl.c
@ -26,7 +26,6 @@
|
|||||||
#include <wlr/types/wlr_keyboard.h>
|
#include <wlr/types/wlr_keyboard.h>
|
||||||
#include <wlr/types/wlr_matrix.h>
|
#include <wlr/types/wlr_matrix.h>
|
||||||
#include <wlr/types/wlr_output.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_layout.h>
|
||||||
#include <wlr/types/wlr_output_management_v1.h>
|
#include <wlr/types/wlr_output_management_v1.h>
|
||||||
#include <wlr/types/wlr_pointer.h>
|
#include <wlr/types/wlr_pointer.h>
|
||||||
@ -147,7 +146,6 @@ typedef struct {
|
|||||||
|
|
||||||
struct wlr_box geo;
|
struct wlr_box geo;
|
||||||
enum zwlr_layer_shell_v1_layer layer;
|
enum zwlr_layer_shell_v1_layer layer;
|
||||||
Monitor *mon;
|
|
||||||
} LayerSurface;
|
} LayerSurface;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -178,7 +176,7 @@ struct Monitor {
|
|||||||
double mfact;
|
double mfact;
|
||||||
int nmaster;
|
int nmaster;
|
||||||
Client *fullscreenclient;
|
Client *fullscreenclient;
|
||||||
struct wlr_output_damage *damage;
|
int isdamaged;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -773,8 +771,7 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
|
|||||||
layersurface->layer = wlr_layer_surface->current.layer;
|
layersurface->layer = wlr_layer_surface->current.layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Damage the whole screen
|
m->isdamaged = true;
|
||||||
wlr_output_damage_add_whole(m->damage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -786,9 +783,8 @@ commitnotify(struct wl_listener *listener, void *data)
|
|||||||
if (c->resize && c->resize <= c->surface.xdg->configure_serial)
|
if (c->resize && c->resize <= c->surface.xdg->configure_serial)
|
||||||
c->resize = 0;
|
c->resize = 0;
|
||||||
|
|
||||||
// Damage the whole screen
|
|
||||||
if (c->mon)
|
if (c->mon)
|
||||||
wlr_output_damage_add_whole(c->mon->damage);
|
c->mon->isdamaged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -833,7 +829,7 @@ createmon(struct wl_listener *listener, void *data)
|
|||||||
/* Initialize monitor state using configured rules */
|
/* Initialize monitor state using configured rules */
|
||||||
for (size_t i = 0; i < LENGTH(m->layers); i++)
|
for (size_t i = 0; i < LENGTH(m->layers); i++)
|
||||||
wl_list_init(&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;
|
m->tagset[0] = m->tagset[1] = 1;
|
||||||
for (r = monrules; r < END(monrules); r++) {
|
for (r = monrules; r < END(monrules); r++) {
|
||||||
if (!r->name || strstr(wlr_output->name, r->name)) {
|
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. */
|
/* Called when the surface is destroyed and should never be shown again. */
|
||||||
Client *c = wl_container_of(listener, c, destroy);
|
Client *c = wl_container_of(listener, c, destroy);
|
||||||
|
|
||||||
// Damage the whole screen
|
|
||||||
if (c->mon)
|
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->map.link);
|
||||||
wl_list_remove(&c->unmap.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 */
|
/* Set initial monitor, tags, floating status, and focus */
|
||||||
applyrules(c);
|
applyrules(c);
|
||||||
|
|
||||||
// Damage the whole screen
|
c->mon->isdamaged = true;
|
||||||
wlr_output_damage_add_whole(c->mon->damage);
|
|
||||||
|
|
||||||
if (c->mon->fullscreenclient && c->mon->fullscreenclient == oldfocus
|
if (c->mon->fullscreenclient && c->mon->fullscreenclient == oldfocus
|
||||||
&& !c->isfloating && c->mon->lt[c->mon->sellt]->arrange) {
|
&& !c->isfloating && c->mon->lt[c->mon->sellt]->arrange) {
|
||||||
@ -1775,13 +1769,14 @@ rendermon(struct wl_listener *listener, void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool needs_frame;
|
/* wlr_output_attach_render makes the OpenGL context current. */
|
||||||
pixman_region32_t damage;
|
if (!wlr_output_attach_render(m->wlr_output, NULL))
|
||||||
pixman_region32_init(&damage);
|
|
||||||
if (!wlr_output_damage_attach_render(m->damage, &needs_frame, &damage))
|
|
||||||
return;
|
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) */
|
/* 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 +1801,8 @@ 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);
|
|
||||||
} else {
|
|
||||||
wlr_output_rollback(m->wlr_output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pixman_region32_fini(&damage);
|
|
||||||
|
|
||||||
wlr_output_commit(m->wlr_output);
|
wlr_output_commit(m->wlr_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1971,7 +1960,7 @@ setmon(Client *c, Monitor *m, unsigned int newtags)
|
|||||||
if (oldmon) {
|
if (oldmon) {
|
||||||
wlr_surface_send_leave(client_surface(c), oldmon->wlr_output);
|
wlr_surface_send_leave(client_surface(c), oldmon->wlr_output);
|
||||||
arrange(oldmon);
|
arrange(oldmon);
|
||||||
wlr_output_damage_add_whole(oldmon->damage);
|
oldmon->isdamaged = true;
|
||||||
}
|
}
|
||||||
if (m) {
|
if (m) {
|
||||||
/* Make sure window actually overlaps with the monitor */
|
/* 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);
|
wlr_surface_send_enter(client_surface(c), m->wlr_output);
|
||||||
c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */
|
c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||||
arrange(m);
|
arrange(m);
|
||||||
wlr_output_damage_add_whole(m->damage);
|
m->isdamaged = true;
|
||||||
}
|
}
|
||||||
focusclient(focustop(selmon), 1);
|
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. */
|
/* Called when the surface is unmapped, and should no longer be shown. */
|
||||||
Client *c = wl_container_of(listener, c, unmap);
|
Client *c = wl_container_of(listener, c, unmap);
|
||||||
|
|
||||||
// Damage the whole screen
|
c->mon->isdamaged = true;
|
||||||
if (c->mon)
|
|
||||||
wlr_output_damage_add_whole(c->mon->damage);
|
|
||||||
|
|
||||||
wl_list_remove(&c->link);
|
wl_list_remove(&c->link);
|
||||||
if (client_is_unmanaged(c))
|
if (client_is_unmanaged(c))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user