fix(scenefx) shadow

chase scenefx changes
This commit is contained in:
wochap 2025-01-18 23:15:32 +00:00
parent 6b4729e357
commit bfdd644ffe

View File

@ -1,14 +1,14 @@
From 059a0c8988967e23807e4f78920816f679dbc068 Mon Sep 17 00:00:00 2001
From b102666dc62ab49ee8205f84971a3e651283160d Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com>
Date: Thu, 2 Jan 2025 19:06:36 -0500
Date: Sat, 18 Jan 2025 17:28:39 -0500
Subject: [PATCH] implement scenefx
---
Makefile | 2 +-
client.h | 14 ++-
config.def.h | 30 ++++-
dwl.c | 319 ++++++++++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 355 insertions(+), 10 deletions(-)
dwl.c | 328 ++++++++++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 364 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
index 3358bae..20b15bb 100644
@ -56,7 +56,7 @@ index 42f225f..e3cef30 100644
wlr_scene_rect_set_color(c->border[i], color);
}
diff --git a/config.def.h b/config.def.h
index 22d2171..d4e85c1 100644
index 22d2171..4ec6adb 100644
--- a/config.def.h
+++ b/config.def.h
@@ -12,7 +12,35 @@ static const float bordercolor[] = COLOR(0x444444ff);
@ -79,7 +79,7 @@ index 22d2171..d4e85c1 100644
+static const char *const shadow_ignore_list[] = { NULL }; /* list of app-id to ignore */
+
+static const int corner_radius = 8; /* 0 disables corner_radius */
+static const int corner_radius_inner = 8; /* 0 disables corner_radius */
+static const int corner_radius_inner = 9; /* 0 disables corner_radius */
+static const int corner_radius_only_floating = 0; /* only apply corner_radius and corner_radius_inner to floating windows */
+
+static const int blur = 1; /* flag to enable blur */
@ -97,7 +97,7 @@ index 22d2171..d4e85c1 100644
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
diff --git a/dwl.c b/dwl.c
index 5bf995e..3c551dc 100644
index 5bf995e..b5e8151 100644
--- a/dwl.c
+++ b/dwl.c
@@ -10,8 +10,13 @@
@ -135,7 +135,7 @@ index 5bf995e..3c551dc 100644
} Client;
typedef struct {
@@ -355,6 +365,11 @@ static Monitor *xytomon(double x, double y);
@@ -355,6 +365,12 @@ static Monitor *xytomon(double x, double y);
static void xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, double *nx, double *ny);
static void zoom(const Arg *arg);
@ -144,10 +144,11 @@ index 5bf995e..3c551dc 100644
+static void iter_xdg_scene_buffers_corner_radius(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data);
+static void output_configure_scene(struct wlr_scene_node *node, Client *c);
+static int in_shadow_ignore_list(const char *str);
+static void client_set_shadow_blur_sigma(Client *c, int blur_sigma);
/* variables */
static const char broken[] = "broken";
@@ -366,6 +381,8 @@ static struct wl_event_loop *event_loop;
@@ -366,6 +382,8 @@ static struct wl_event_loop *event_loop;
static struct wlr_backend *backend;
static struct wlr_scene *scene;
static struct wlr_scene_tree *layers[NUM_LAYERS];
@ -156,7 +157,7 @@ index 5bf995e..3c551dc 100644
static struct wlr_scene_tree *drag_icon;
/* Map from ZWLR_LAYER_SHELL_* constants to Lyr* enum */
static const int layermap[] = { LyrBg, LyrBottom, LyrTop, LyrOverlay };
@@ -413,6 +430,8 @@ static struct wlr_box sgeom;
@@ -413,6 +431,8 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
@ -165,7 +166,7 @@ index 5bf995e..3c551dc 100644
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -1061,6 +1080,9 @@ createnotify(struct wl_listener *listener, void *data)
@@ -1061,6 +1081,9 @@ createnotify(struct wl_listener *listener, void *data)
c->surface.xdg = toplevel->base;
c->bw = borderpx;
@ -175,7 +176,7 @@ index 5bf995e..3c551dc 100644
LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify);
LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify);
LISTEN(&toplevel->base->surface->events.unmap, &c->unmap, unmapnotify);
@@ -1369,8 +1391,20 @@ focusclient(Client *c, int lift)
@@ -1369,8 +1392,20 @@ focusclient(Client *c, int lift)
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
@ -184,7 +185,7 @@ index 5bf995e..3c551dc 100644
client_set_border_color(c, focuscolor);
+
+ if (shadow) {
+ wlr_scene_shadow_set_blur_sigma(c->shadow, shadow_blur_sigma_focus);
+ client_set_shadow_blur_sigma(c, (int)round(shadow_blur_sigma_focus));
+ if (c->has_shadow_enabled) {
+ wlr_scene_shadow_set_color(c->shadow, shadow_color_focus);
+ }
@ -197,12 +198,12 @@ index 5bf995e..3c551dc 100644
}
/* Deactivate old client if focus is changing */
@@ -1389,6 +1423,17 @@ focusclient(Client *c, int lift)
@@ -1389,6 +1424,17 @@ focusclient(Client *c, int lift)
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
client_set_border_color(old_c, bordercolor);
+ if (shadow) {
+ wlr_scene_shadow_set_blur_sigma(old_c->shadow, shadow_blur_sigma);
+ client_set_shadow_blur_sigma(old_c, (int)round(shadow_blur_sigma));
+ if (old_c->has_shadow_enabled) {
+ wlr_scene_shadow_set_color(old_c->shadow, shadow_color);
+ }
@ -215,7 +216,7 @@ index 5bf995e..3c551dc 100644
client_activate_surface(old, 0);
}
}
@@ -1718,6 +1763,21 @@ mapnotify(struct wl_listener *listener, void *data)
@@ -1718,6 +1764,21 @@ mapnotify(struct wl_listener *listener, void *data)
c->border[i]->node.data = c;
}
@ -237,7 +238,7 @@ index 5bf995e..3c551dc 100644
/* Initialize client geometry with room for border */
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT);
c->geom.width += 2 * c->bw;
@@ -1739,6 +1799,25 @@ mapnotify(struct wl_listener *listener, void *data)
@@ -1739,6 +1800,25 @@ mapnotify(struct wl_listener *listener, void *data)
}
printstatus();
@ -246,7 +247,7 @@ index 5bf995e..3c551dc 100644
+ if ((corner_radius_only_floating && !c->isfloating) || c->isfullscreen) {
+ radius = 0;
+ }
+ wlr_scene_rect_set_corner_radius(c->round_border, radius);
+ wlr_scene_rect_set_corner_radius(c->round_border, radius, CORNER_LOCATION_ALL);
+ }
+
+ if (shadow) {
@ -263,7 +264,7 @@ index 5bf995e..3c551dc 100644
unset_fullscreen:
m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
wl_list_for_each(w, &clients, link) {
@@ -2113,6 +2192,8 @@ rendermon(struct wl_listener *listener, void *data)
@@ -2113,6 +2193,8 @@ rendermon(struct wl_listener *listener, void *data)
goto skip;
}
@ -272,7 +273,7 @@ index 5bf995e..3c551dc 100644
/*
* HACK: The "correct" way to set the gamma is to commit it together with
* the rest of the state in one go, but to do that we would need to rewrite
@@ -2181,6 +2262,8 @@ resize(Client *c, struct wlr_box geo, int interact)
@@ -2181,6 +2263,8 @@ resize(Client *c, struct wlr_box geo, int interact)
{
struct wlr_box *bbox;
struct wlr_box clip;
@ -281,7 +282,7 @@ index 5bf995e..3c551dc 100644
if (!c->mon || !c->scene)
return;
@@ -2207,6 +2290,20 @@ resize(Client *c, struct wlr_box geo, int interact)
@@ -2207,6 +2291,20 @@ resize(Client *c, struct wlr_box geo, int interact)
c->geom.height - 2 * c->bw);
client_get_clip(c, &clip);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
@ -302,7 +303,7 @@ index 5bf995e..3c551dc 100644
}
void
@@ -2307,6 +2404,29 @@ setfloating(Client *c, int floating)
@@ -2307,6 +2405,29 @@ setfloating(Client *c, int floating)
{
Client *p = client_get_parent(c);
c->isfloating = floating;
@ -312,7 +313,7 @@ index 5bf995e..3c551dc 100644
+ if ((corner_radius_only_floating && !c->isfloating) || c->isfullscreen) {
+ radius = 0;
+ }
+ wlr_scene_rect_set_corner_radius(c->round_border, radius);
+ wlr_scene_rect_set_corner_radius(c->round_border, radius, CORNER_LOCATION_ALL);
+ }
+ if (corner_radius_inner > 0 && c->round_border != NULL) {
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_corner_radius, c);
@ -332,7 +333,7 @@ index 5bf995e..3c551dc 100644
/* If in floating layout do not change the client's layer */
if (!c->mon || !client_surface(c)->mapped || !c->mon->lt[c->mon->sellt]->arrange)
return;
@@ -2336,6 +2456,29 @@ setfullscreen(Client *c, int fullscreen)
@@ -2336,6 +2457,29 @@ setfullscreen(Client *c, int fullscreen)
* client positions are set by the user and cannot be recalculated */
resize(c, c->prev, 0);
}
@ -342,7 +343,7 @@ index 5bf995e..3c551dc 100644
+ if ((corner_radius_only_floating && !c->isfloating) || c->isfullscreen) {
+ radius = 0;
+ }
+ wlr_scene_rect_set_corner_radius(c->round_border, radius);
+ wlr_scene_rect_set_corner_radius(c->round_border, radius, CORNER_LOCATION_ALL);
+ }
+ if (corner_radius_inner > 0 && c->round_border != NULL) {
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_corner_radius, c);
@ -362,7 +363,7 @@ index 5bf995e..3c551dc 100644
arrange(c->mon);
printstatus();
}
@@ -2457,11 +2600,17 @@ setup(void)
@@ -2457,11 +2601,17 @@ setup(void)
drag_icon = wlr_scene_tree_create(&scene->tree);
wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
@ -381,7 +382,7 @@ index 5bf995e..3c551dc 100644
die("couldn't create renderer");
LISTEN_STATIC(&drw->events.lost, gpureset);
@@ -2871,6 +3020,14 @@ updatemons(struct wl_listener *listener, void *data)
@@ -2871,6 +3021,14 @@ updatemons(struct wl_listener *listener, void *data)
wlr_scene_node_set_position(&m->fullscreen_bg->node, m->m.x, m->m.y);
wlr_scene_rect_set_size(m->fullscreen_bg, m->m.width, m->m.height);
@ -396,7 +397,7 @@ index 5bf995e..3c551dc 100644
if (m->lock_surface) {
struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data;
wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);
@@ -2940,8 +3097,16 @@ urgent(struct wl_listener *listener, void *data)
@@ -2940,8 +3098,16 @@ urgent(struct wl_listener *listener, void *data)
c->isurgent = 1;
printstatus();
@ -405,7 +406,7 @@ index 5bf995e..3c551dc 100644
client_set_border_color(c, urgentcolor);
+
+ if (shadow && c->shadow != NULL) {
+ wlr_scene_shadow_set_blur_sigma(c->shadow, shadow_blur_sigma_focus);
+ client_set_shadow_blur_sigma(c, (int)round(shadow_blur_sigma_focus));
+ if (c->has_shadow_enabled) {
+ wlr_scene_shadow_set_color(c->shadow, shadow_color_focus);
+ }
@ -414,7 +415,7 @@ index 5bf995e..3c551dc 100644
}
void
@@ -3053,6 +3218,152 @@ zoom(const Arg *arg)
@@ -3053,6 +3219,160 @@ zoom(const Arg *arg)
arrange(selmon);
}
@ -563,6 +564,14 @@ index 5bf995e..3c551dc 100644
+ }
+ return 0;
+}
+
+void
+client_set_shadow_blur_sigma(Client *c, int blur_sigma)
+{
+ wlr_scene_shadow_set_blur_sigma(c->shadow, blur_sigma);
+ wlr_scene_node_set_position(&c->shadow->node, -blur_sigma, -blur_sigma);
+ wlr_scene_shadow_set_size(c->shadow, c->geom.width + (blur_sigma) * 2, c->geom.height + (blur_sigma) * 2);
+}
+
#ifdef XWAYLAND
void