summaryrefslogtreecommitdiffstats
path: root/dwl-patches/patches/scenefx/scenefx.patch
blob: c556cb4c7bcc2cbfe05292b819868bbe5a74c3d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
From d209aeaee541a045de9dba2154bbbd5475bba2ec Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com>
Date: Sun, 9 Mar 2025 17:26:07 -0500
Subject: [PATCH] implement scenefx

---
 Makefile     |   2 +-
 client.h     |  18 +++
 config.def.h |  30 +++-
 dwl.c        | 414 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 457 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 3358bae..8dc79bd 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ DWLDEVCFLAGS = -g -pedantic -Wall -Wextra -Wdeclaration-after-statement \
 	-Wfloat-conversion
 
 # CFLAGS / LDFLAGS
-PKGS      = wlroots-0.18 wayland-server xkbcommon libinput $(XLIBS)
+PKGS      = scenefx-0.2 wlroots-0.18 wayland-server xkbcommon libinput $(XLIBS)
 DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
 LDLIBS    = `$(PKG_CONFIG) --libs $(PKGS)` -lm $(LIBS)
 
diff --git a/client.h b/client.h
index 42f225f..4e8f016 100644
--- a/client.h
+++ b/client.h
@@ -147,6 +147,13 @@ client_get_clip(Client *c, struct wlr_box *clip)
 		return;
 #endif
 
+	*clip = (struct wlr_box){
+		.x = c->bw,
+		.y = c->bw,
+		.width = c->geom.width - c->bw * 2,
+		.height = c->geom.height - c->bw * 2,
+	};
+
 	wlr_xdg_surface_get_geometry(c->surface.xdg, &xdg_geom);
 	clip->x = xdg_geom.x;
 	clip->y = xdg_geom.y;
@@ -328,6 +335,17 @@ static inline void
 client_set_border_color(Client *c, const float color[static 4])
 {
 	int i;
+
+#ifdef XWAYLAND
+	if (!client_is_x11(c)) {
+#endif
+	if (corner_radius > 0) {
+		return;
+	}
+#ifdef XWAYLAND
+	}
+#endif
+
 	for (i = 0; i < 4; i++)
 		wlr_scene_rect_set_color(c->border[i], color);
 }
diff --git a/config.def.h b/config.def.h
index 22d2171..8c50932 100644
--- a/config.def.h
+++ b/config.def.h
@@ -12,7 +12,35 @@ static const float bordercolor[]           = COLOR(0x444444ff);
 static const float focuscolor[]            = COLOR(0x005577ff);
 static const float urgentcolor[]           = COLOR(0xff0000ff);
 /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
-static const float fullscreen_bg[]         = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
+static const float fullscreen_bg[]         = {0.1f, 0.1f, 0.1f, 0.0f}; /* You can also use glsl colors */
+
+static const int opacity = 0; /* flag to enable opacity */
+static const float opacity_inactive = 0.5;
+static const float opacity_active = 1.0;
+
+static const int shadow = 1; /* flag to enable shadow */
+static const int shadow_only_floating = 0; /* only apply shadow to floating windows */
+static const float shadow_color[4] = COLOR(0x0000FFff);
+static const float shadow_color_focus[4] = COLOR(0xFF0000ff);
+static const int shadow_blur_sigma = 20;
+static const int shadow_blur_sigma_focus = 40;
+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 = 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 */
+static const int blur_xray = 0; /* flag to make transparent fs and floating windows display your background */
+static const int blur_ignore_transparent = 1;
+static const struct blur_data blur_data = {
+	.radius = 5,
+	.num_passes = 3,
+	.noise = (float)0.02,
+	.brightness = (float)0.9,
+	.contrast = (float)0.9,
+	.saturation = (float)1.1,
+};
 
 /* tagging - TAGCOUNT must be no greater than 31 */
 #define TAGCOUNT (9)
diff --git a/dwl.c b/dwl.c
index 5bf995e..655e175 100644
--- a/dwl.c
+++ b/dwl.c
@@ -10,8 +10,14 @@
 #include <stdlib.h>
 #include <sys/wait.h>
 #include <time.h>
+#include <scenefx/render/fx_renderer/fx_renderer.h>
+#include <scenefx/types/fx/blur_data.h>
+#include <scenefx/types/fx/clipped_region.h>
+#include <scenefx/types/fx/corner_location.h>
+#include <scenefx/types/wlr_scene.h>
 #include <unistd.h>
 #include <wayland-server-core.h>
+#include <wayland-util.h>
 #include <wlr/backend.h>
 #include <wlr/backend/libinput.h>
 #include <wlr/render/allocator.h>
@@ -43,7 +49,6 @@
 #include <wlr/types/wlr_primary_selection.h>
 #include <wlr/types/wlr_primary_selection_v1.h>
 #include <wlr/types/wlr_relative_pointer_v1.h>
-#include <wlr/types/wlr_scene.h>
 #include <wlr/types/wlr_screencopy_v1.h>
 #include <wlr/types/wlr_seat.h>
 #include <wlr/types/wlr_server_decoration.h>
@@ -83,7 +88,7 @@
 /* enums */
 enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
 enum { XDGShell, LayerShell, X11 }; /* client types */
-enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
+enum { LyrBg, LyrBlur, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
 #ifdef XWAYLAND
 enum { NetWMWindowTypeDialog, NetWMWindowTypeSplash, NetWMWindowTypeToolbar,
 	NetWMWindowTypeUtility, NetLast }; /* EWMH atoms */
@@ -141,6 +146,12 @@ typedef struct {
 	uint32_t tags;
 	int isfloating, isurgent, isfullscreen;
 	uint32_t resize; /* configure serial of a pending resize */
+
+	float opacity;
+	int corner_radius;
+	struct wlr_scene_shadow *shadow;
+	int has_shadow_enabled;
+	struct wlr_scene_rect *round_border;
 } Client;
 
 typedef struct {
@@ -208,6 +219,7 @@ struct Monitor {
 	int nmaster;
 	char ltsymbol[16];
 	int asleep;
+	struct wlr_scene_optimized_blur *blur_layer;
 };
 
 typedef struct {
@@ -355,6 +367,18 @@ 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);
+static void iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data);
+static void iter_xdg_scene_buffers_blur(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_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);
+static void update_client_corner_radius(Client *c);
+static void update_client_shadow_color(Client *c);
+static void update_client_focus_decorations(Client *c, int focused, int urgent);
+static void update_client_blur(Client *c);
+static void update_buffer_corner_radius(Client *c, struct wlr_scene_buffer *buffer);
 
 /* variables */
 static const char broken[] = "broken";
@@ -413,6 +437,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);
@@ -499,6 +525,10 @@ arrange(Monitor *m)
 	wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
 			(c = focustop(m)) && c->isfullscreen);
 
+	if (blur) {
+		wlr_scene_node_set_enabled(&m->blur_layer->node, 1);
+	}
+
 	strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
 
 	/* We move all clients (except fullscreen and unmanaged) to LyrTile while
@@ -722,6 +752,11 @@ cleanupmon(struct wl_listener *listener, void *data)
 
 	closemon(m);
 	wlr_scene_node_destroy(&m->fullscreen_bg->node);
+
+	if (blur) {
+		wlr_scene_node_destroy(&m->blur_layer->node);
+	}
+
 	free(m);
 }
 
@@ -785,6 +820,18 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
 	}
 
 	arrangelayers(l->mon);
+
+	if (blur) {
+		// Rerender the optimized blur on change
+		struct wlr_layer_surface_v1 *wlr_layer_surface = l->layer_surface;
+		if (wlr_layer_surface->current.layer ==
+				ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND ||
+			wlr_layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM) {
+			if (l->mon) {
+				wlr_scene_optimized_blur_mark_dirty(l->mon->blur_layer);
+			}
+		}
+	}
 }
 
 void
@@ -1036,6 +1083,12 @@ createmon(struct wl_listener *listener, void *data)
 	m->fullscreen_bg = wlr_scene_rect_create(layers[LyrFS], 0, 0, fullscreen_bg);
 	wlr_scene_node_set_enabled(&m->fullscreen_bg->node, 0);
 
+	if (blur) {
+		m->blur_layer = wlr_scene_optimized_blur_create(&scene->tree, 0, 0);
+		wlr_scene_node_reparent(&m->blur_layer->node, layers[LyrBlur]);
+		wlr_scene_node_set_enabled(&m->blur_layer->node, 0);
+	}
+
 	/* Adds this to the output layout in the order it was configured.
 	 *
 	 * The output layout utility automatically adds a wl_output global to the
@@ -1061,6 +1114,9 @@ createnotify(struct wl_listener *listener, void *data)
 	c->surface.xdg = toplevel->base;
 	c->bw = borderpx;
 
+	c->opacity = opacity;
+	c->corner_radius = corner_radius;
+
 	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 +1425,11 @@ focusclient(Client *c, int lift)
 
 		/* Don't change border color if there is an exclusive focus or we are
 		 * handling a drag operation */
-		if (!exclusive_focus && !seat->drag)
+		if (!exclusive_focus && !seat->drag) {
 			client_set_border_color(c, focuscolor);
+
+			update_client_focus_decorations(c, 1, 0);
+		}
 	}
 
 	/* Deactivate old client if focus is changing */
@@ -1389,6 +1448,8 @@ 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);
 
+			update_client_focus_decorations(old_c, 0, 0);
+
 			client_activate_surface(old, 0);
 		}
 	}
@@ -1718,6 +1779,38 @@ mapnotify(struct wl_listener *listener, void *data)
 		c->border[i]->node.data = c;
 	}
 
+	wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers, c);
+
+#ifdef XWAYLAND
+	if (!client_is_x11(c)) {
+#endif
+	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;
+		/* Lower the border below the XDG scene tree */
+		wlr_scene_node_lower_to_bottom(&c->round_border->node);
+
+		/* hide original border */
+		for (i = 0; i < 4; i++) {
+			wlr_scene_rect_set_color(c->border[i], transparent);
+		}
+	}
+#ifdef XWAYLAND
+	}
+#endif
+
+#ifdef XWAYLAND
+	if (!client_is_x11(c)) {
+#endif
+	if (shadow) {
+		c->shadow = wlr_scene_shadow_create(c->scene, 0, 0, c->corner_radius, shadow_blur_sigma, shadow_color);
+		/* Lower the shadow below the border */
+		wlr_scene_node_lower_to_bottom(&c->shadow->node);
+	}
+#ifdef XWAYLAND
+	}
+#endif
+
 	/* 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 +1832,13 @@ mapnotify(struct wl_listener *listener, void *data)
 	}
 	printstatus();
 
+	/* TODO: shouldn't we call iter_xdg_scene_buffers_corner_radius? */
+	update_client_corner_radius(c);
+
+	update_client_shadow_color(c);
+
+	update_client_blur(c);
+
 unset_fullscreen:
 	m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
 	wl_list_for_each(w, &clients, link) {
@@ -2113,6 +2213,8 @@ rendermon(struct wl_listener *listener, void *data)
 			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
@@ -2207,6 +2309,21 @@ 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);
+
+	if (corner_radius > 0 && c->round_border) {
+		wlr_scene_node_set_position(&c->round_border->node, 0, 0);
+		wlr_scene_rect_set_size(c->round_border, c->geom.width, c->geom.height);
+		wlr_scene_rect_set_clipped_region(c->round_border, (struct clipped_region) {
+			.corner_radius = c->corner_radius,
+			.corners = CORNER_LOCATION_ALL,
+			.area = { c->bw, c->bw, c->geom.width - c->bw * 2, c->geom.height - c->bw * 2 }
+		});
+	}
+
+	if (shadow && c->shadow) {
+		/* TODO: shouldn't we call wlr_scene_shadow_set_blur_sigma? */
+		client_set_shadow_blur_sigma(c, (int)round(c->shadow->blur_sigma));
+	}
 }
 
 void
@@ -2307,6 +2424,13 @@ setfloating(Client *c, int floating)
 {
 	Client *p = client_get_parent(c);
 	c->isfloating = floating;
+
+	update_client_corner_radius(c);
+
+	update_client_shadow_color(c);
+
+	update_client_blur(c);
+
 	/* 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 +2460,13 @@ setfullscreen(Client *c, int fullscreen)
 		 * client positions are set by the user and cannot be recalculated */
 		resize(c, c->prev, 0);
 	}
+
+	update_client_corner_radius(c);
+
+	update_client_shadow_color(c);
+
+	update_client_blur(c);
+
 	arrange(c->mon);
 	printstatus();
 }
@@ -2457,11 +2588,15 @@ setup(void)
 	drag_icon = wlr_scene_tree_create(&scene->tree);
 	wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
 
+	if (blur) {
+		wlr_scene_set_blur_data(scene, blur_data);
+	}
+
 	/* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user
 	 * can also specify a renderer using the WLR_RENDERER env var.
 	 * The renderer is responsible for defining the various pixel formats it
 	 * supports for shared memory, this configures that for clients. */
-	if (!(drw = wlr_renderer_autocreate(backend)))
+	if (!(drw = fx_renderer_create(backend)))
 		die("couldn't create renderer");
 	LISTEN_STATIC(&drw->events.lost, gpureset);
 
@@ -2870,6 +3005,10 @@ 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);
+		
+		if (blur) {
+			wlr_scene_optimized_blur_set_size(m->blur_layer, m->m.width, m->m.height);
+		}
 
 		if (m->lock_surface) {
 			struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data;
@@ -2940,8 +3079,11 @@ urgent(struct wl_listener *listener, void *data)
 	c->isurgent = 1;
 	printstatus();
 
-	if (client_surface(c)->mapped)
+	if (client_surface(c)->mapped) {
 		client_set_border_color(c, urgentcolor);
+
+		update_client_focus_decorations(c, 1, 1);
+	}
 }
 
 void
@@ -3053,6 +3195,268 @@ zoom(const Arg *arg)
 	arrange(selmon);
 }
 
+void
+iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data)
+{
+	Client *c = user_data;
+	struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer);
+	struct wlr_xdg_surface *xdg_surface;
+
+	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) {
+		/* TODO: Be able to set whole decoration_data instead of calling */
+		/* each individually? */
+		if (opacity) {
+			wlr_scene_buffer_set_opacity(buffer, c->opacity);
+		}
+
+		if (!wlr_subsurface_try_from_wlr_surface(xdg_surface->surface)) {
+			update_buffer_corner_radius(c, buffer);
+
+			if (blur) {
+				int blur_optimized = !c->isfloating || blur_xray;
+				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
+iter_xdg_scene_buffers_blur(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data)
+{
+	Client *c = user_data;
+	struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer);
+	struct wlr_xdg_surface *xdg_surface;
+
+	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 (!wlr_subsurface_try_from_wlr_surface(xdg_surface->surface)) {
+			if (blur) {
+				int blur_optimized = !c->isfloating || blur_xray;
+				wlr_scene_buffer_set_backdrop_blur_optimized(buffer, blur_optimized);
+			}
+		}
+	}
+}
+
+void
+iter_xdg_scene_buffers_opacity(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data)
+{
+	Client *c = user_data;
+	struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer);
+	struct wlr_xdg_surface *xdg_surface;
+
+	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) {
+		/* TODO: Be able to set whole decoration_data instead of calling */
+		/* each individually? */
+		if (opacity) {
+			wlr_scene_buffer_set_opacity(buffer, c->opacity);
+		}
+	}
+}
+
+void
+iter_xdg_scene_buffers_corner_radius(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data)
+{
+	Client *c = user_data;
+	struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer);
+	struct wlr_xdg_surface *xdg_surface;
+
+	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) {
+		/* TODO: Be able to set whole decoration_data instead of calling */
+		/* each individually? */
+		update_buffer_corner_radius(c, buffer);
+	}
+}
+
+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)) {
+				update_buffer_corner_radius(c, buffer);
+			}
+		}
+	} 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);
+		}
+	}
+}
+
+int
+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
+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);
+	wlr_scene_shadow_set_clipped_region(c->shadow, (struct clipped_region) {
+		.corner_radius = c->corner_radius + c->bw,
+		.corners = CORNER_LOCATION_ALL,
+		.area = { blur_sigma, blur_sigma, c->geom.width, c->geom.height }
+	});
+}
+
+void
+update_client_corner_radius(Client *c)
+{
+	if (corner_radius && c->round_border) {
+		int radius = c->corner_radius + c->bw;
+		if ((corner_radius_only_floating && !c->isfloating) || c->isfullscreen) {
+			radius = 0;
+		}
+		wlr_scene_rect_set_corner_radius(c->round_border, radius, CORNER_LOCATION_ALL);
+	}
+
+#ifdef XWAYLAND
+	if (!client_is_x11(c)) {
+#endif
+	if (corner_radius_inner > 0 && c->scene) {
+		wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_corner_radius, c);
+	}
+#ifdef XWAYLAND
+	}
+#endif
+}
+
+void
+update_client_blur(Client *c)
+{
+	if (!blur) {
+		return;
+	}
+
+	if (c->scene) {
+		wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_blur, c);
+	}
+}
+
+void
+update_buffer_corner_radius(Client *c, struct wlr_scene_buffer *buffer)
+{
+	int radius;
+
+#ifdef XWAYLAND
+	if (client_is_x11(c)) {
+		return;
+	}
+#endif
+
+	if (!corner_radius_inner) {
+		return;
+	}
+
+	radius = corner_radius_inner;
+	if ((corner_radius_only_floating && !c->isfloating) || c->isfullscreen) {
+		radius = 0;
+	}
+	wlr_scene_buffer_set_corner_radius(buffer, radius, CORNER_LOCATION_ALL);
+}
+
+void
+update_client_shadow_color(Client *c)
+{
+	int has_shadow_enabled = 1;
+	const float *color;
+
+	if (!shadow || !c->shadow) {
+		return;
+	}
+
+	color = focustop(c->mon) == c ? shadow_color_focus : shadow_color;
+
+	if ((shadow_only_floating && !c->isfloating) ||
+		in_shadow_ignore_list(client_get_appid(c)) ||
+		c->isfullscreen) {
+		color = transparent;
+		has_shadow_enabled = 0;
+	}
+
+	wlr_scene_shadow_set_color(c->shadow, color);
+	c->has_shadow_enabled = has_shadow_enabled;
+}
+
+void
+update_client_focus_decorations(Client *c, int focused, int urgent)
+{
+	if (corner_radius > 0 && c->round_border) {
+		wlr_scene_rect_set_color(c->round_border, urgent ? urgentcolor : (focused ? focuscolor : bordercolor));
+	}
+	if (shadow && c->shadow) {
+		client_set_shadow_blur_sigma(c, (int)round(focused ? shadow_blur_sigma_focus : shadow_blur_sigma));
+		if (c->has_shadow_enabled) {
+			wlr_scene_shadow_set_color(c->shadow, focused ? shadow_color_focus : shadow_color);
+		}
+	}
+	if (opacity) {
+		c->opacity = focused ? opacity_active : opacity_inactive;
+		wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_opacity, c);
+	}
+}
+
 #ifdef XWAYLAND
 void
 activatex11(struct wl_listener *listener, void *data)
-- 
2.47.2