mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-10-27 02:04:14 +00:00
Merge remote-tracking branch 'miles/basic_damage_tracking' into basic_damage_tracking
This commit is contained in:
commit
b267258251
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
|
PKGS = wlroots wayland-server xcb xkbcommon libinput pixman-1
|
||||||
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)))
|
||||||
|
|
||||||
|
|||||||
56
dwl.c
56
dwl.c
@ -26,6 +26,7 @@
|
|||||||
#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>
|
||||||
@ -146,6 +147,7 @@ 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 {
|
||||||
@ -176,6 +178,7 @@ struct Monitor {
|
|||||||
double mfact;
|
double mfact;
|
||||||
int nmaster;
|
int nmaster;
|
||||||
Client *fullscreenclient;
|
Client *fullscreenclient;
|
||||||
|
struct wlr_output_damage *damage;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -769,6 +772,9 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
|
|||||||
&layersurface->link);
|
&layersurface->link);
|
||||||
layersurface->layer = wlr_layer_surface->current.layer;
|
layersurface->layer = wlr_layer_surface->current.layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Damage the whole screen
|
||||||
|
wlr_output_damage_add_whole(m->damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -779,6 +785,10 @@ commitnotify(struct wl_listener *listener, void *data)
|
|||||||
/* mark a pending resize as completed */
|
/* mark a pending resize as completed */
|
||||||
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)
|
||||||
|
wlr_output_damage_add_whole(c->mon->damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -823,6 +833,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->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)) {
|
||||||
@ -1013,6 +1024,11 @@ 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)
|
||||||
|
wlr_output_damage_add_whole(c->mon->damage);
|
||||||
|
|
||||||
wl_list_remove(&c->map.link);
|
wl_list_remove(&c->map.link);
|
||||||
wl_list_remove(&c->unmap.link);
|
wl_list_remove(&c->unmap.link);
|
||||||
wl_list_remove(&c->destroy.link);
|
wl_list_remove(&c->destroy.link);
|
||||||
@ -1355,6 +1371,9 @@ 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
|
||||||
|
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) {
|
||||||
maximizeclient(c->mon->fullscreenclient);
|
maximizeclient(c->mon->fullscreenclient);
|
||||||
@ -1739,7 +1758,9 @@ 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;
|
||||||
|
pixman_region32_t damage;
|
||||||
|
|
||||||
/* This function is called every time an output is ready to display a frame,
|
/* This function is called every time an output is ready to display a frame,
|
||||||
* generally at the output's refresh rate (e.g. 60Hz). */
|
* generally at the output's refresh rate (e.g. 60Hz). */
|
||||||
@ -1748,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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* wlr_output_attach_render makes the OpenGL context current. */
|
|
||||||
if (!wlr_output_attach_render(m->wlr_output, NULL))
|
|
||||||
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) {
|
|
||||||
/* 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);
|
||||||
@ -1785,8 +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_commit(m->wlr_output);
|
wlr_output_commit(m->wlr_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1944,6 +1971,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);
|
||||||
}
|
}
|
||||||
if (m) {
|
if (m) {
|
||||||
/* Make sure window actually overlaps with the monitor */
|
/* Make sure window actually overlaps with the monitor */
|
||||||
@ -1951,6 +1979,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);
|
||||||
}
|
}
|
||||||
focusclient(focustop(selmon), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
}
|
}
|
||||||
@ -2274,6 +2303,11 @@ 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
|
||||||
|
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))
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user