Compare commits

..

No commits in common. "abf142827ccb79328925171b408fdde8eec32b83" and "ae2ed4649ab31d53ea6a0b3169e7fe4888026d86" have entirely different histories.

2 changed files with 244 additions and 364 deletions

View File

@ -1,111 +1,96 @@
### Description ### Description
Implement https://github.com/wlrfx/scenefx Implement https://github.com/wlrfx/scenefx
```c ```c
/* available options */ /* available options */
static const int opacity = 0; /* flag to enable opacity */ static const int opacity = 0; /* flag to enable opacity */
static const float opacity_inactive = 0.5; static const float opacity_inactive = 0.5;
static const float opacity_active = 1.0; static const float opacity_active = 1.0;
static const int shadow = 1; /* flag to enable shadow */ static const int shadow = 1; /* flag to enable shadow */
static const int shadow_only_floating = 0; /* only apply shadow to floating windows */ static const int shadow_only_floating = 0; /* only apply shadow to floating windows */
static const struct wlr_render_color shadow_color = COLOR(0x0000FFff); static const struct wlr_render_color shadow_color = COLOR(0x0000FFff);
static const struct wlr_render_color shadow_color_focus = COLOR(0xFF0000ff); static const struct wlr_render_color shadow_color_focus = COLOR(0xFF0000ff);
static const int shadow_blur_sigma = 20; static const int shadow_blur_sigma = 20;
static const int shadow_blur_sigma_focus = 40; static const int shadow_blur_sigma_focus = 40;
static const char *const shadow_ignore_list[] = { "xdg-desktop-portal-gtk", NULL }; /* list of app-id to ignore */
static const int corner_radius = 0; /* 0 disables corner_radius */
static const int corner_radius_inner = 3; /* 0 disables corner_radius */ static const int corner_radius = 0; /* 0 disables corner_radius */
static const int blur = 1; /* flag to enable blur */ static const int blur = 1; /* flag to enable blur */
static const int blur_optimized = 1; static const int blur_optimized = 1;
static const int blur_ignore_transparent = 1; static const int blur_ignore_transparent = 1;
static const struct blur_data blur_data = { static const struct blur_data blur_data = {
.radius = 5, .radius = 5,
.num_passes = 3, .num_passes = 3,
.noise = 0.02, .noise = 0.02,
.brightness = 0.9, .brightness = 0.9,
.contrast = 0.9, .contrast = 0.9,
.saturation = 1.1, .saturation = 1.1,
}; };
``` ```
> **NOTE:** If you are using nix with flakes, scenefx has a flake for scenefx https://github.com/wlrfx/scenefx/blob/main/flake.nix > **NOTE:** If you are using nix with flakes, scenefx has a flake for scenefx https://github.com/wlrfx/scenefx/blob/main/flake.nix
> **NOTE:** Blur doesn't work on windows with opacity set (opacity_active, opacity_inactive) > **NOTE:** Some GTK apps are being cut off when they have shadows enabled. You can use the `shadow_ignore_list` option to prevent shadows from being rendered on those apps
> **NOTE:** In DWL's Makefile `scenefx` must be placed before `wlroots-0.18`, e.g. `PKGS = scenefx wlroots-0.18 wayland-server ...` > **NOTE:** Blur doesn't work on windows with opacity set (opacity_active, opacity_inactive)
<details> > **NOTE:** In DWL's Makefile `scenefx` must be placed before wlroots, e.g. `PKGS = scenefx wlroots wayland-server ...`
<summary>Preview</summary>
<pre> <details>
<img src="https://i.imgur.com/nJIX6lp.png"/> <summary>Preview</summary>
</pre> <pre>
</details> <img src="https://i.imgur.com/4kFhSaS.png"/>
<img src="https://i.imgur.com/9ZQAUXx.png"/>
### Download </pre>
</details>
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.8-a/scenefx)
### Download
- [0.8](https://codeberg.org/dwl/dwl-patches/raw/commit/494baec5b107114b74d243440aa8581fe6c03e48/patches/scenefx/scenefx.patch)
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.5/scenefx)
**NOTE:** This patch was tested with the `b2e0ac4beb85aa89d0357dc8fcf8762808650890` commit on the `main` branch of `SceneFX`. It supports rounded borders, blur, and shadows. - [2024-07-09](https://codeberg.org/dwl/dwl-patches/raw/commit/13d96b51b54500dd24544cf3a73c61b7a1414bc6/patches/scenefx/scenefx.patch)
**IMPORTANT:** This patch requires you to build DWL with the following dependencies **IMPORTANT:** This patch only works with the `2ec3505248e819191c37cb831197629f373326fb` commit on the `main` branch of `scenefx`, therefore, it does not support **blur**.
- **scenefx** **IMPORTANT:** This patch requires you to build DWL with the following dependencies
- libGL
- **scenefx**
- [2024-07-09](https://codeberg.org/dwl/dwl-patches/raw/commit/13d96b51b54500dd24544cf3a73c61b7a1414bc6/patches/scenefx/scenefx.patch) - libGL
**IMPORTANT:** This patch only works with the `2ec3505248e819191c37cb831197629f373326fb` commit on the `main` branch of `scenefx`, therefore, it does not support **blur**. - [2024-04-11](https://codeberg.org/dwl/dwl-patches/raw/commit/6e3a57ffd16dafa31900b7e89e51672bd7bcc1e8/scenefx/scenefx.patch)
**IMPORTANT:** This patch requires you to build DWL with the following dependencies **IMPORTANT:** This patch only works with the `de4ec10e1ff9347b5833f00f8615d760d9378c99` commit on the `wlr_scene_blur` branch of `scenefx`, as it adds support for **blur**.
- **scenefx** **IMPORTANT:** This patch requires you to build DWL with the dependencies of WLROOTS:
- libGL
- **scenefx**
<details> - libGL
<summary>Preview</summary> - libcap
<pre> - libinput
<img src="https://i.imgur.com/4kFhSaS.png"/> - libpng
<img src="https://i.imgur.com/9ZQAUXx.png"/> - libxkbcommon
</pre> - mesa
</details> - pixman
- seatd
- [2024-04-11](https://codeberg.org/dwl/dwl-patches/raw/commit/6e3a57ffd16dafa31900b7e89e51672bd7bcc1e8/scenefx/scenefx.patch) - vulkan-loader
- wayland
**IMPORTANT:** This patch only works with the `de4ec10e1ff9347b5833f00f8615d760d9378c99` commit on the `wlr_scene_blur` branch of `scenefx`, as it adds support for **blur**. - wayland-protocols
- xorg.libX11
**IMPORTANT:** This patch requires you to build DWL with the dependencies of WLROOTS: - xorg.xcbutilerrors
- xorg.xcbutilimage
- **scenefx** - xorg.xcbutilrenderutil
- libGL - xorg.xcbutilwm
- libcap - xwayland (optional)
- libinput - ffmpeg
- libpng - hwdata
- libxkbcommon - libliftoff
- mesa - libdisplay-info
- pixman
- seatd - [v0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/7a5c3420822074c544fa102e030b7c30aa6b6be8/scenefx/scenefx.patch)
- vulkan-loader
- wayland ### Authors
- wayland-protocols
- xorg.libX11 - [wochap](https://codeberg.org/wochap)
- xorg.xcbutilerrors
- xorg.xcbutilimage
- xorg.xcbutilrenderutil
- xorg.xcbutilwm
- xwayland (optional)
- ffmpeg
- hwdata
- libliftoff
- libdisplay-info
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/7a5c3420822074c544fa102e030b7c30aa6b6be8/scenefx/scenefx.patch)
### Authors
- [wochap](https://codeberg.org/wochap)

View File

@ -1,58 +1,64 @@
From a0a4de0305a5f06431f8162d37070fffd9ad9dd8 Mon Sep 17 00:00:00 2001 From 2d4fb60abd6284236ce4ba0b9c3b562165937963 Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com> From: wochap <gean.marroquin@gmail.com>
Date: Tue, 24 Dec 2024 21:49:50 -0500 Date: Fri, 5 Jul 2024 11:45:43 -0500
Subject: [PATCH] feat: implement scenefx Subject: [PATCH] implement scenefx
--- ---
Makefile | 2 +- Makefile | 2 +-
client.h | 10 ++- client.h | 11 +++-
config.def.h | 28 +++++- config.def.h | 28 ++++++++-
dwl.c | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++- dwl.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++--
4 files changed, 268 insertions(+), 8 deletions(-) 4 files changed, 191 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile diff --git a/Makefile b/Makefile
index 3358bae..20b15bb 100644 index 0d651e7..0ae18a7 100644
--- a/Makefile --- a/Makefile
+++ b/Makefile +++ b/Makefile
@@ -12,7 +12,7 @@ DWLDEVCFLAGS = -g -pedantic -Wall -Wextra -Wdeclaration-after-statement \ @@ -12,7 +12,7 @@ DWLDEVCFLAGS = -g -pedantic -Wall -Wextra -Wdeclaration-after-statement \
-Wfloat-conversion -Wfloat-conversion
# CFLAGS / LDFLAGS # CFLAGS / LDFLAGS
-PKGS = wlroots-0.18 wayland-server xkbcommon libinput $(XLIBS) -PKGS = wlroots wayland-server xkbcommon libinput $(XLIBS)
+PKGS = scenefx wlroots-0.18 wayland-server xkbcommon libinput $(XLIBS) +PKGS = scenefx wlroots wayland-server xkbcommon libinput $(XLIBS)
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS) DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` -lm $(LIBS) LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` -lm $(LIBS)
diff --git a/client.h b/client.h diff --git a/client.h b/client.h
index 42f225f..12faec4 100644 index 42f225f..f75b3ff 100644
--- a/client.h --- a/client.h
+++ b/client.h +++ b/client.h
@@ -138,8 +138,8 @@ client_get_clip(Client *c, struct wlr_box *clip) @@ -131,7 +131,7 @@ client_get_appid(Client *c)
*clip = (struct wlr_box){ return c->surface.xdg->toplevel->app_id;
.x = 0, }
.y = 0,
- .width = c->geom.width - c->bw, -static inline void
- .height = c->geom.height - c->bw, +static inline int
+ .width = c->geom.width - c->bw * 2, client_get_clip(Client *c, struct wlr_box *clip)
+ .height = c->geom.height - c->bw * 2, {
}; struct wlr_box xdg_geom = {0};
@@ -144,12 +144,19 @@ client_get_clip(Client *c, struct wlr_box *clip)
#ifdef XWAYLAND #ifdef XWAYLAND
@@ -328,6 +328,12 @@ static inline void if (client_is_x11(c))
client_set_border_color(Client *c, const float color[static 4]) - return;
{ + return 1;
int i; #endif
wlr_xdg_surface_get_geometry(c->surface.xdg, &xdg_geom);
clip->x = xdg_geom.x;
clip->y = xdg_geom.y;
+ +
+ if (corner_radius > 0) { + if (xdg_geom.width <= c->geom.width - (int)c->bw
+ wlr_scene_rect_set_color(c->round_border, color); + && xdg_geom.height <= c->geom.height - (int)c->bw) {
+ return; + return 0;
+ } + }
+ +
for (i = 0; i < 4; i++) + return 1;
wlr_scene_rect_set_color(c->border[i], color);
} }
static inline void
diff --git a/config.def.h b/config.def.h diff --git a/config.def.h b/config.def.h
index 22d2171..a7ebe80 100644 index 22d2171..d28e698 100644
--- a/config.def.h --- a/config.def.h
+++ b/config.def.h +++ b/config.def.h
@@ -12,7 +12,33 @@ static const float bordercolor[] = COLOR(0x444444ff); @@ -12,7 +12,33 @@ static const float bordercolor[] = COLOR(0x444444ff);
@ -67,14 +73,14 @@ index 22d2171..a7ebe80 100644
+static const float opacity_active = 1.0; +static const float opacity_active = 1.0;
+ +
+static const int shadow = 1; /* flag to enable shadow */ +static const int shadow = 1; /* flag to enable shadow */
+static const int shadow_only_floating = 1; /* only apply shadow to floating windows */ +static const int shadow_only_floating = 0; /* only apply shadow to floating windows */
+static const float shadow_color[4] = COLOR(0x0000FFff); +static const struct wlr_render_color shadow_color = COLOR(0x0000FFff);
+static const float shadow_color_focus[4] = COLOR(0xFF0000ff); +static const struct wlr_render_color shadow_color_focus = COLOR(0xFF0000ff);
+static const int shadow_blur_sigma = 20; +static const int shadow_blur_sigma = 20;
+static const int shadow_blur_sigma_focus = 40; +static const int shadow_blur_sigma_focus = 40;
+static const char *const shadow_ignore_list[] = { "xdg-desktop-portal-gtk", NULL }; /* list of app-id to ignore */
+ +
+static const int corner_radius = 8; /* 0 disables corner_radius */ +static const int corner_radius = 0; /* 0 disables corner_radius */
+static const int corner_radius_inner = 3; /* 0 disables corner_radius */
+ +
+static const int blur = 1; /* flag to enable blur */ +static const int blur = 1; /* flag to enable blur */
+static const int blur_optimized = 1; +static const int blur_optimized = 1;
@ -91,24 +97,21 @@ index 22d2171..a7ebe80 100644
/* tagging - TAGCOUNT must be no greater than 31 */ /* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9) #define TAGCOUNT (9)
diff --git a/dwl.c b/dwl.c diff --git a/dwl.c b/dwl.c
index 5bf995e..a9f8277 100644 index dc0437e..d69054a 100644
--- a/dwl.c --- a/dwl.c
+++ b/dwl.c +++ b/dwl.c
@@ -10,8 +10,13 @@ @@ -10,6 +10,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <time.h> #include <time.h>
+#include <scenefx/render/fx_renderer/fx_renderer.h> +#include <scenefx/render/fx_renderer/fx_renderer.h>
+#include <scenefx/types/fx/blur_data.h> +#include <scenefx/types/fx/blur_data.h>
+#include <scenefx/types/fx/corner_location.h> +#include <scenefx/types/fx/shadow_data.h>
+#include <scenefx/types/wlr_scene.h> +#include <scenefx/types/wlr_scene.h>
#include <unistd.h> #include <unistd.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
+#include <wayland-util.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/backend/libinput.h> @@ -42,7 +46,6 @@
#include <wlr/render/allocator.h>
@@ -43,7 +48,6 @@
#include <wlr/types/wlr_primary_selection.h> #include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_primary_selection_v1.h> #include <wlr/types/wlr_primary_selection_v1.h>
#include <wlr/types/wlr_relative_pointer_v1.h> #include <wlr/types/wlr_relative_pointer_v1.h>
@ -116,98 +119,84 @@ index 5bf995e..a9f8277 100644
#include <wlr/types/wlr_screencopy_v1.h> #include <wlr/types/wlr_screencopy_v1.h>
#include <wlr/types/wlr_seat.h> #include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_server_decoration.h> #include <wlr/types/wlr_server_decoration.h>
@@ -141,6 +145,12 @@ typedef struct { @@ -140,6 +143,10 @@ typedef struct {
uint32_t tags; uint32_t tags;
int isfloating, isurgent, isfullscreen; int isfloating, isurgent, isfullscreen;
uint32_t resize; /* configure serial of a pending resize */ uint32_t resize; /* configure serial of a pending resize */
+ +
+ float opacity; + float opacity;
+ int corner_radius; + int corner_radius;
+ struct wlr_scene_shadow *shadow; + struct shadow_data shadow_data;
+ int has_shadow_enabled;
+ struct wlr_scene_rect *round_border;
} Client; } Client;
typedef struct { typedef struct {
@@ -355,6 +365,9 @@ static Monitor *xytomon(double x, double y); @@ -351,6 +358,9 @@ static Monitor *xytomon(double x, double y);
static void xytonode(double x, double y, struct wlr_surface **psurface, static void xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, double *nx, double *ny); Client **pc, LayerSurface **pl, double *nx, double *ny);
static void zoom(const Arg *arg); static void zoom(const Arg *arg);
+static int in_shadow_ignore_list(const char *str);
+static void iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data); +static void iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data);
+static void iter_xdg_scene_buffers_opacity(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data); +static void iter_xdg_scene_buffers_shadow(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data);
+static void output_configure_scene(struct wlr_scene_node *node, Client *c);
/* variables */ /* variables */
static const char broken[] = "broken"; static const char broken[] = "broken";
@@ -366,6 +379,8 @@ static struct wl_event_loop *event_loop; @@ -1045,6 +1055,13 @@ createnotify(struct wl_listener *listener, void *data)
static struct wlr_backend *backend; wlr_xdg_toplevel_set_wm_capabilities(xdg_surface->toplevel,
static struct wlr_scene *scene; WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);
static struct wlr_scene_tree *layers[NUM_LAYERS];
+/* TODO: implement wlr_scene_optimized_blur */
+/* static struct wlr_scene_optimized_blur *blur_layer; */
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 +428,8 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static float transparent[4] = {0.1f, 0.1f, 0.1f, 0.0f};
+
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -1061,6 +1078,9 @@ createnotify(struct wl_listener *listener, void *data)
c->surface.xdg = toplevel->base;
c->bw = borderpx;
+ c->opacity = opacity; + c->opacity = opacity;
+ c->corner_radius = corner_radius; + c->corner_radius = corner_radius;
+ c->shadow_data = shadow_data_get_default();
+ c->shadow_data.enabled = shadow_only_floating != 1 && !in_shadow_ignore_list(client_get_appid(c));
+ c->shadow_data.blur_sigma = shadow_blur_sigma;
+ c->shadow_data.color = shadow_color;
+ +
LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify); LISTEN(&xdg_surface->events.destroy, &c->destroy, destroynotify);
LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify); LISTEN(&xdg_surface->surface->events.commit, &c->commit, commitnotify);
LISTEN(&toplevel->base->surface->events.unmap, &c->unmap, unmapnotify); LISTEN(&xdg_surface->surface->events.map, &c->map, mapnotify);
@@ -1369,8 +1389,20 @@ focusclient(Client *c, int lift) @@ -1346,8 +1363,21 @@ focusclient(Client *c, int lift)
/* Don't change border color if there is an exclusive focus or we are /* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */ * handling a drag operation */
- if (!exclusive_focus && !seat->drag) - if (!exclusive_focus && !seat->drag)
+ if (!exclusive_focus && !seat->drag) { + if (!exclusive_focus && !seat->drag) {
client_set_border_color(c, focuscolor); client_set_border_color(c, focuscolor);
+
+ if (shadow) { + if (shadow) {
+ wlr_scene_shadow_set_blur_sigma(c->shadow, shadow_blur_sigma_focus); + c->shadow_data.blur_sigma = shadow_blur_sigma_focus;
+ if (c->has_shadow_enabled) { + c->shadow_data.color = shadow_color_focus;
+ wlr_scene_shadow_set_color(c->shadow, shadow_color_focus);
+ }
+ } + }
+ if (opacity) { + if (opacity) {
+ c->opacity = opacity_active; + c->opacity = opacity_active;
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_opacity, c); + }
+ if (opacity) {
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers, c);
+ } else if (shadow) {
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_shadow, c);
+ } + }
+ } + }
} }
/* Deactivate old client if focus is changing */ /* Deactivate old client if focus is changing */
@@ -1389,6 +1421,17 @@ focusclient(Client *c, int lift) @@ -1365,6 +1395,18 @@ focusclient(Client *c, int lift)
* and probably other clients */
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) { } else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
client_set_border_color(old_c, bordercolor); client_set_border_color(old_c, bordercolor);
+ if (shadow) { + if (shadow) {
+ wlr_scene_shadow_set_blur_sigma(old_c->shadow, shadow_blur_sigma); + old_c->shadow_data.blur_sigma = shadow_blur_sigma;
+ if (old_c->has_shadow_enabled) { + old_c->shadow_data.color = shadow_color;
+ wlr_scene_shadow_set_color(old_c->shadow, shadow_color);
+ }
+ } + }
+ if (opacity) { + if (opacity) {
+ old_c->opacity = opacity_inactive; + old_c->opacity = opacity_inactive;
+ wlr_scene_node_for_each_buffer(&old_c->scene_surface->node, iter_xdg_scene_buffers_opacity, old_c);
+ } + }
+ + if (opacity) {
+ wlr_scene_node_for_each_buffer(&old_c->scene_surface->node, iter_xdg_scene_buffers, old_c);
+ } else if (shadow) {
+ wlr_scene_node_for_each_buffer(&old_c->scene_surface->node, iter_xdg_scene_buffers_shadow, old_c);
+ }
client_activate_surface(old, 0); client_activate_surface(old, 0);
} }
} @@ -1653,6 +1695,8 @@ mapnotify(struct wl_listener *listener, void *data)
@@ -1700,6 +1743,8 @@ mapnotify(struct wl_listener *listener, void *data)
client_get_geometry(c, &c->geom); client_get_geometry(c, &c->geom);
@ -216,117 +205,67 @@ index 5bf995e..a9f8277 100644
/* Handle unmanaged clients first so we can return prior create borders */ /* Handle unmanaged clients first so we can return prior create borders */
if (client_is_unmanaged(c)) { if (client_is_unmanaged(c)) {
/* Unmanaged clients always are floating */ /* Unmanaged clients always are floating */
@@ -1718,6 +1763,24 @@ mapnotify(struct wl_listener *listener, void *data) @@ -1692,6 +1736,15 @@ mapnotify(struct wl_listener *listener, void *data)
c->border[i]->node.data = c;
}
+ if (corner_radius > 0) {
+ c->round_border = wlr_scene_rect_create(c->scene, 0, 0, c->isurgent ? urgentcolor : bordercolor);
+ c->round_border->node.data = c;
+ wlr_scene_rect_set_corner_radius(c->round_border, c->corner_radius + c->bw);
+ /* Lower the border below the XDG scene tree */
+ wlr_scene_node_lower_to_bottom(&c->round_border->node);
+ }
+
+ if (shadow) {
+ c->shadow = wlr_scene_shadow_create(c->scene, 0, 0, c->corner_radius, shadow_blur_sigma, shadow_color);
+ c->has_shadow_enabled = shadow_only_floating != 1;
+ if (!c->has_shadow_enabled) {
+ wlr_scene_shadow_set_color(c->shadow, transparent);
+ }
+ /* Lower the shadow below the border */
+ wlr_scene_node_lower_to_bottom(&c->shadow->node);
+ }
+
/* 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 +1802,16 @@ mapnotify(struct wl_listener *listener, void *data)
} }
printstatus(); printstatus();
+ if (shadow && shadow_only_floating) { + if (shadow && shadow_only_floating) {
+ if (c->isfloating) { + if (c->isfloating && !in_shadow_ignore_list(client_get_appid(c))) {
+ c->has_shadow_enabled = 1; + c->shadow_data.enabled = 1;
+ wlr_scene_shadow_set_color(c->shadow, focustop(c->mon) == c ? shadow_color_focus : shadow_color);
+ } else { + } else {
+ c->has_shadow_enabled = 0; + c->shadow_data.enabled = 0;
+ wlr_scene_shadow_set_color(c->shadow, transparent);
+ } + }
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_shadow, c);
+ } + }
+ +
unset_fullscreen: unset_fullscreen:
m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y); m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
wl_list_for_each(w, &clients, link) { wl_list_for_each(w, &clients, link) {
@@ -2113,6 +2186,8 @@ rendermon(struct wl_listener *listener, void *data) @@ -2132,6 +2185,7 @@ resize(Client *c, struct wlr_box geo, int interact)
goto skip;
}
+ output_configure_scene(&m->scene_output->scene->tree.node, NULL);
+
/*
* 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 +2256,8 @@ resize(Client *c, struct wlr_box geo, int interact)
{ {
struct wlr_box *bbox; struct wlr_box *bbox;
struct wlr_box clip; struct wlr_box clip;
+ int blur_sigma; + int should_clip;
+ int i;
if (!c->mon || !c->scene) if (!c->mon || !c->scene)
return; return;
@@ -2207,6 +2284,19 @@ resize(Client *c, struct wlr_box geo, int interact) @@ -2156,8 +2210,12 @@ resize(Client *c, struct wlr_box geo, int interact)
/* this is a no-op if size hasn't changed */
c->resize = client_set_size(c, c->geom.width - 2 * c->bw,
c->geom.height - 2 * c->bw); c->geom.height - 2 * c->bw);
client_get_clip(c, &clip); - client_get_clip(c, &clip);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip); - wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
+ + should_clip = client_get_clip(c, &clip);
+ if (corner_radius > 0) { + if (should_clip) {
+ wlr_scene_node_set_position(&c->round_border->node, 0, 0); + wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
+ wlr_scene_rect_set_size(c->round_border, c->geom.width, c->geom.height); + } else {
+ for (i = 0; i < 4; i++) + wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, NULL);
+ wlr_scene_rect_set_color(c->border[i], transparent);
+ }
+
+ if (shadow) {
+ blur_sigma = (int)round(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);
+ } + }
} }
void void
@@ -2307,6 +2397,21 @@ setfloating(Client *c, int floating) @@ -2258,6 +2316,14 @@ setfloating(Client *c, int floating)
{ {
Client *p = client_get_parent(c); Client *p = client_get_parent(c);
c->isfloating = floating; c->isfloating = floating;
+
+ if (shadow && shadow_only_floating) { + if (shadow && shadow_only_floating) {
+ if (c->isfloating) { + if (c->isfloating && !in_shadow_ignore_list(client_get_appid(c))) {
+ c->has_shadow_enabled = 1; + c->shadow_data.enabled = 1;
+ if (c->shadow != NULL) {
+ wlr_scene_shadow_set_color(c->shadow, focustop(c->mon) == c ? shadow_color_focus : shadow_color);
+ }
+ } else { + } else {
+ c->has_shadow_enabled = 0; + c->shadow_data.enabled = 0;
+ if (c->shadow != NULL) {
+ wlr_scene_shadow_set_color(c->shadow, transparent);
+ }
+ } + }
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_shadow, c);
+ } + }
+
/* If in floating layout do not change the client's layer */ /* 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) if (!c->mon || !client_surface(c)->mapped || !c->mon->lt[c->mon->sellt]->arrange)
return; return;
@@ -2457,11 +2562,17 @@ setup(void) @@ -2407,11 +2473,15 @@ setup(void)
drag_icon = wlr_scene_tree_create(&scene->tree); drag_icon = wlr_scene_tree_create(&scene->tree);
wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node); wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
+ if (blur) { + // if (blur) {
+ /* TODO: implement wlr_scene_optimized_blur_create */ + // wlr_scene_set_blur_data(scene, blur_data);
+ /* blur_layer = wlr_scene_optimized_blur_create(&scene->tree, 0, 0); */ + // }
+ wlr_scene_set_blur_data(scene, blur_data);
+ }
+ +
/* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user /* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user
* can also specify a renderer using the WLR_RENDERER env var. * can also specify a renderer using the WLR_RENDERER env var.
@ -335,47 +274,40 @@ index 5bf995e..a9f8277 100644
- if (!(drw = wlr_renderer_autocreate(backend))) - if (!(drw = wlr_renderer_autocreate(backend)))
+ if (!(drw = fx_renderer_create(backend))) + if (!(drw = fx_renderer_create(backend)))
die("couldn't create renderer"); die("couldn't create renderer");
LISTEN_STATIC(&drw->events.lost, gpureset);
@@ -2871,6 +2982,14 @@ updatemons(struct wl_listener *listener, void *data) /* Create shm, drm and linux_dmabuf interfaces by ourselves.
wlr_scene_node_set_position(&m->fullscreen_bg->node, m->m.x, m->m.y); @@ -2888,8 +2958,14 @@ urgent(struct wl_listener *listener, void *data)
wlr_scene_rect_set_size(m->fullscreen_bg, m->m.width, m->m.height);
+ /*
+ * Sets the blur node size to the outputs size. Assumes there's only one
+ * output. More advanced compositors should either implement per output blur
+ * nodes or set it to the size of all outputs.
+ */
+ /* TODO: implement wlr_scene_optimized_blur_set_size */
+ /* wlr_scene_optimized_blur_set_size(blur_layer, m->wlr_output->width, m->wlr_output->height); */
+
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 +3059,16 @@ urgent(struct wl_listener *listener, void *data)
c->isurgent = 1; c->isurgent = 1;
printstatus(); printstatus();
- if (client_surface(c)->mapped) - if (client_surface(c)->mapped)
+ if (client_surface(c)->mapped) { + if (client_surface(c)->mapped) {
client_set_border_color(c, urgentcolor); client_set_border_color(c, urgentcolor);
+
+ if (shadow) { + if (shadow) {
+ wlr_scene_shadow_set_blur_sigma(c->shadow, shadow_blur_sigma_focus); + c->shadow_data.blur_sigma = shadow_blur_sigma_focus;
+ if (c->has_shadow_enabled) { + c->shadow_data.color = shadow_color_focus;
+ wlr_scene_shadow_set_color(c->shadow, shadow_color_focus); + wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_shadow, c);
+ }
+ } + }
+ } + }
} }
void void
@@ -3053,6 +3180,107 @@ zoom(const Arg *arg) @@ -3001,6 +3077,78 @@ zoom(const Arg *arg)
arrange(selmon); arrange(selmon);
} }
+void +int
+iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data) +in_shadow_ignore_list(const char *str) {
+ for (int i = 0; shadow_ignore_list[i] != NULL; i++) {
+ if (strcmp(shadow_ignore_list[i], str) == 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+void
+iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data)
+{ +{
+ Client *c = user_data; + Client *c = user_data;
+ struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer); + struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer);
@ -387,29 +319,35 @@ index 5bf995e..a9f8277 100644
+ +
+ xdg_surface = wlr_xdg_surface_try_from_wlr_surface(scene_surface->surface); + xdg_surface = wlr_xdg_surface_try_from_wlr_surface(scene_surface->surface);
+ +
+ if (c && xdg_surface && xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) { + if (c &&
+ /* TODO: Be able to set whole decoration_data instead of calling */ + xdg_surface &&
+ /* each individually? */ + xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
+ // TODO: Be able to set whole decoration_data instead of calling
+ // each individually?
+ if (opacity) { + if (opacity) {
+ wlr_scene_buffer_set_opacity(buffer, c->opacity); + wlr_scene_buffer_set_opacity(buffer, c->opacity);
+ } + }
+ +
+ if (!wlr_subsurface_try_from_wlr_surface(xdg_surface->surface)) { + if (!wlr_subsurface_try_from_wlr_surface(xdg_surface->surface)) {
+ if (corner_radius_inner > 0) { + if (corner_radius > 0) {
+ wlr_scene_buffer_set_corner_radius(buffer, corner_radius_inner, CORNER_LOCATION_ALL); + wlr_scene_buffer_set_corner_radius(buffer, c->corner_radius);
+ } + }
+ +
+ if (blur) { + if (shadow) {
+ wlr_scene_buffer_set_backdrop_blur(buffer, 1); + wlr_scene_buffer_set_shadow_data(buffer, c->shadow_data);
+ wlr_scene_buffer_set_backdrop_blur_optimized(buffer, blur_optimized);
+ wlr_scene_buffer_set_backdrop_blur_ignore_transparent(buffer, blur_ignore_transparent);
+ } + }
+
+ // if (blur) {
+ // wlr_scene_buffer_set_backdrop_blur(buffer, 1);
+ // wlr_scene_buffer_set_backdrop_blur_optimized(buffer, blur_optimized);
+ // wlr_scene_buffer_set_backdrop_blur_ignore_transparent(buffer, blur_ignore_transparent);
+ // }
+ } + }
+ } + }
+} +}
+ +
+void +void
+iter_xdg_scene_buffers_opacity(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data) +iter_xdg_scene_buffers_shadow(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data)
+{ +{
+ Client *c = user_data; + Client *c = user_data;
+ struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer); + struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer);
@ -421,60 +359,17 @@ index 5bf995e..a9f8277 100644
+ +
+ xdg_surface = wlr_xdg_surface_try_from_wlr_surface(scene_surface->surface); + xdg_surface = wlr_xdg_surface_try_from_wlr_surface(scene_surface->surface);
+ +
+ if (c && xdg_surface && xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) { + if (c &&
+ /* TODO: Be able to set whole decoration_data instead of calling */ + xdg_surface &&
+ /* each individually? */ + xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
+ if (opacity) { + if (!wlr_subsurface_try_from_wlr_surface(xdg_surface->surface)) {
+ wlr_scene_buffer_set_opacity(buffer, c->opacity); + wlr_scene_buffer_set_shadow_data(buffer, c->shadow_data);
+ }
+ }
+}
+
+void
+output_configure_scene(struct wlr_scene_node *node, Client *c)
+{
+ Client *_c;
+ struct wlr_xdg_surface *xdg_surface;
+ struct wlr_scene_node *_node;
+
+ if (!node->enabled) {
+ return;
+ }
+
+ _c = node->data;
+ if (_c) {
+ c = _c;
+ }
+
+ if (node->type == WLR_SCENE_NODE_BUFFER) {
+ struct wlr_scene_buffer *buffer = wlr_scene_buffer_from_node(node);
+
+ struct wlr_scene_surface *scene_surface = wlr_scene_surface_try_from_buffer(buffer);
+ if (!scene_surface) {
+ return;
+ }
+
+ xdg_surface = wlr_xdg_surface_try_from_wlr_surface(scene_surface->surface);
+
+ if (c && xdg_surface && xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
+ if (opacity) {
+ wlr_scene_buffer_set_opacity(buffer, c->opacity);
+ }
+
+ if (!wlr_subsurface_try_from_wlr_surface(xdg_surface->surface)) {
+ if (corner_radius_inner > 0) {
+ wlr_scene_buffer_set_corner_radius(buffer, corner_radius_inner, CORNER_LOCATION_ALL);
+ }
+ }
+ }
+ } else if (node->type == WLR_SCENE_NODE_TREE) {
+ struct wlr_scene_tree *tree = wl_container_of(node, tree, node);
+ wl_list_for_each(_node, &tree->children, link) {
+ output_configure_scene(_node, c);
+ } + }
+ } + }
+} +}
+ +
#ifdef XWAYLAND #ifdef XWAYLAND
void void
activatex11(struct wl_listener *listener, void *data) activatex11(struct wl_listener *listener, void *data)
--
2.45.1