summaryrefslogtreecommitdiff
path: root/gui-libs/pixdecor/files/pixdecor-sculpted-frames.patch
blob: 010bb93c5ecdd9d91a421d4b8481e5be4b67fe97 (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
diff --git a/metadata/pixdecor.xml b/metadata/pixdecor.xml
index 2da2bc4..5ce4729 100644
--- a/metadata/pixdecor.xml
+++ b/metadata/pixdecor.xml
@@ -5,7 +5,7 @@
 		<_long>A highly configurable and optionally fancy decorator plugin for wayfire.</_long>
 		<category>Effects</category>
 		<group>
-			<_short>General</_short>
+			<_short>Window frames</_short>
 			<option name="border_size" type="int">
 				<_short>Border size</_short>
 				<_long>Sets the border size in pixels.</_long>
@@ -43,6 +43,69 @@
 				<_long>Whether or not to allocate space for shadows on maximized windows.</_long>
 				<default>false</default>
 			</option>
+			<option name="fg_color" type="color">
+				<_short>Color when focused</_short>
+				<_long>Color of the window border when it has focus.</_long>
+				<default>0.9 0.65 0.04 1.0</default>
+			</option>
+			<option name="bg_color" type="color">
+				<_short>Color when not focused</_short>
+				<_long>Color of the window border when it does not have focus.</_long>
+				<default>0.07 0.27 0.5 0.85</default>
+			</option>
+			<option name="overlay_engine" type="string">
+				<_short>Overlay Engine</_short>
+				<_long>Sets the overlay engine.</_long>
+				<default>none</default>
+				<desc>
+					<value>none</value>
+					<_name>None</_name>
+				</desc>
+				<desc>
+					<value>rounded_corners</value>
+					<_name>Rounded Corners</_name>
+				</desc>
+				<desc>
+					<value>beveled_glass</value>
+					<_name>Beveled Glass</_name>
+				</desc>
+                <desc><value>sculpted</value><_name>Sculpted</_name></desc>
+			</option>
+            <option name="border_depth" type="double">
+                <_short>Border depth</_short>
+                <_long>Strength of the Sculpted overlay's highlight and shadow. Other overlays retain their own appearance.</_long>
+                <default>0.65</default><min>0.0</min><max>1.0</max>
+            </option>
+            <option name="pinstripe_color" type="color">
+                <_short>Pinstripe color</_short>
+                <_long>Color and opacity of the Sculpted overlay's outer rim, independent of border depth.</_long>
+                <default>#5a718124</default>
+            </option>
+			<option name="rounded_corner_radius" type="int">
+				<_short>Rounded Corner Radius</_short>
+				<_long>The radius for corners.</_long>
+				<default>5</default>
+				<min>0</min>
+			</option>
+			<option name="shadow_radius" type="int">
+				<_short>Shadow Radius</_short>
+				<_long>The radius for shadows.</_long>
+				<default>10</default>
+				<min>0</min>
+			</option>
+			<option name="shadow_color" type="color">
+				<_short>Shadow Color</_short>
+				<_long>Color of the drop shadows.</_long>
+				<default>0.0 0.0 0.0 0.25</default>
+			</option>
+			<option name="inactive_shadow_color" type="color">
+				<_short>Inactive Shadow Color</_short>
+				<_long>Color of the drop shadows for unfocused windows.</_long>
+				<default>0.0 0.0 0.0 0.25</default>
+			</option>
+		</group>
+		<group>
+			<_short>General</_short>
 			<option name="ignore_views" type="string">
 				<_short>Decoration disabled for specified window types</_short>
 				<_long>Disables window decoration for windows matching the specified criteria.</_long>
@@ -58,16 +121,6 @@
 				<_long>Font to use for the titlebar. The font size determines the titlebar height.</_long>
 				<default>sans 12</default>
 			</option>
-			<option name="fg_color" type="color">
-				<_short>Color when focused</_short>
-				<_long>Color of the window border when it has focus.</_long>
-				<default>0.9 0.65 0.04 1.0</default>
-			</option>
-			<option name="bg_color" type="color">
-				<_short>Color when not focused</_short>
-				<_long>Color of the window border when it does not have focus.</_long>
-				<default>0.07 0.27 0.5 0.85</default>
-			</option>
 			<option name="fg_text_color" type="color">
 				<_short>Text color when focused</_short>
 				<_long>Color of the window titlebar text when it has focus.</_long>
@@ -95,23 +148,6 @@
 					<_name>Right</_name>
 				</desc>
 			</option>
-			<option name="overlay_engine" type="string">
-				<_short>Overlay Engine</_short>
-				<_long>Sets the overlay engine.</_long>
-				<default>none</default>
-				<desc>
-					<value>none</value>
-					<_name>None</_name>
-				</desc>
-				<desc>
-					<value>rounded_corners</value>
-					<_name>Rounded Corners</_name>
-				</desc>
-				<desc>
-					<value>beveled_glass</value>
-					<_name>Beveled Glass</_name>
-				</desc>
-			</option>
 			<option name="effect_type" type="string">
 				<_short>Effect Type</_short>
 				<_long>Sets the effect type.</_long>
@@ -187,28 +223,6 @@
 				<_long>WARNING: Enabling this option can use lots of system resources. Enables animating and constant repainting of window decorations.</_long>
 				<default>false</default>
 			</option>
-			<option name="rounded_corner_radius" type="int">
-				<_short>Rounded Corner Radius</_short>
-				<_long>The radius for corners.</_long>
-				<default>5</default>
-				<min>0</min>
-			</option>
-			<option name="shadow_radius" type="int">
-				<_short>Shadow Radius</_short>
-				<_long>The radius for shadows.</_long>
-				<default>10</default>
-				<min>0</min>
-			</option>
-			<option name="shadow_color" type="color">
-				<_short>Shadow Color</_short>
-				<_long>Color of the drop shadows.</_long>
-				<default>0.0 0.0 0.0 0.25</default>
-			</option>
-			<option name="inactive_shadow_color" type="color">
-				<_short>Inactive Shadow Color</_short>
-				<_long>Color of the drop shadows for unfocused windows.</_long>
-				<default>0.0 0.0 0.0 0.25</default>
-			</option>
 		</group>
 		<group>
 			<_short>Buttons</_short>
diff --git a/src/deco-effects.cpp b/src/deco-effects.cpp
index 7aa6393..f092244 100644
--- a/src/deco-effects.cpp
+++ b/src/deco-effects.cpp
@@ -33,6 +33,7 @@
 
 #include "deco-effects.hpp"
 #include "smoke-shaders.hpp"
+#include "sculpted-overlay.hpp"
 
 
 namespace wf
@@ -2206,6 +2207,9 @@ void smoke_t::create_programs()
         if (std::string(overlay_engine) == "rounded_corners")
         {
             setup_shader(&render_overlay_program, rounded_corner_overlay);
+        } else if (std::string(overlay_engine) == "sculpted")
+        {
+            setup_shader(&render_overlay_program, sculpted_overlay);
         } else if (std::string(overlay_engine) == "beveled_glass")
         {
             setup_shader(&render_overlay_program, beveled_glass_overlay);
@@ -2570,7 +2574,7 @@ void smoke_t::step_effect(const wf::scene::render_instruction_t& data, wf::geome
             GL_CALL(glDeleteFramebuffers(1, &fb));
         }
 
-        if ((std::string(overlay_engine) == "rounded_corners") ||
+        if ((uses_shadow_overlay(std::string(overlay_engine))) ||
             (std::string(overlay_engine) == "beveled_glass"))
         {
             GL_CALL(glUseProgram(render_overlay_program));
@@ -2579,13 +2583,20 @@ void smoke_t::step_effect(const wf::scene::render_instruction_t& data, wf::geome
             GL_CALL(glUniform1i(5, rectangle.width));
             GL_CALL(glUniform1i(6, rectangle.height));
             GL_CALL(glUniform1i(7, rounded_corner_radius));
-            if (std::string(overlay_engine) == "rounded_corners")
+            if (uses_shadow_overlay(std::string(overlay_engine)))
             {
                 GLfloat shadow_color_f[4] =
                 {GLfloat(shadow_color.r), GLfloat(shadow_color.g),
                     GLfloat(shadow_color.b), GLfloat(shadow_color.a)};
                 GL_CALL(glUniform1i(8, radius));
                 GL_CALL(glUniform4fv(9, 1, shadow_color_f));
+                if (std::string(overlay_engine) == "sculpted")
+                {
+                    wf::color_t rim = pinstripe_color;
+                    GLfloat rim_f[4] = {GLfloat(rim.r), GLfloat(rim.g), GLfloat(rim.b), GLfloat(rim.a)};
+                    GL_CALL(glUniform1f(10, border_depth));
+                    GL_CALL(glUniform4fv(11, 1, rim_f));
+                }
             }
 
             GL_CALL(glDispatchCompute(round_up_div(rectangle.width, 16), round_up_div(rectangle.height, 16),
diff --git a/src/deco-effects.hpp b/src/deco-effects.hpp
index 94fa248..95e97fb 100644
--- a/src/deco-effects.hpp
+++ b/src/deco-effects.hpp
@@ -10,6 +10,11 @@ namespace wf
 {
 namespace pixdecor
 {
+inline bool uses_shadow_overlay(const std::string& engine)
+{
+    return engine == "rounded_corners" || engine == "sculpted";
+}
+
 class smoke_t
 {
     /** background effects */
@@ -25,6 +30,8 @@ class smoke_t
     wf::option_wrapper_t<std::string> effect_type{"pixdecor/effect_type"};
     wf::option_wrapper_t<std::string> overlay_engine{"pixdecor/overlay_engine"};
     wf::option_wrapper_t<bool> effect_animate{"pixdecor/animate"};
+    wf::option_wrapper_t<double> border_depth{"pixdecor/border_depth"};
+    wf::option_wrapper_t<wf::color_t> pinstripe_color{"pixdecor/pinstripe_color"};
     wf::option_wrapper_t<int> rounded_corner_radius{"pixdecor/rounded_corner_radius"};
 
   public:
diff --git a/src/deco-layout.cpp b/src/deco-layout.cpp
index 394ba37..47b2c7b 100644
--- a/src/deco-layout.cpp
+++ b/src/deco-layout.cpp
@@ -242,7 +242,7 @@ void pixdecor_layout_t::resize(int width, int height)
     wf::option_wrapper_t<int> shadow_radius{"pixdecor/shadow_radius"};
     wf::option_wrapper_t<std::string> overlay_engine{"pixdecor/overlay_engine"};
     wf::option_wrapper_t<bool> maximized_borders{"pixdecor/maximized_borders"};
-    bool rounded_corners = std::string(overlay_engine) == "rounded_corners";
+    bool rounded_corners = uses_shadow_overlay(std::string(overlay_engine));
 
     double border = theme.get_border_size();
     double radius = (rounded_corners && !maximized) ? int(shadow_radius) : 0;
@@ -627,7 +627,7 @@ uint32_t pixdecor_layout_t::calculate_resize_edges() const
 {
     wf::option_wrapper_t<int> shadow_radius{"pixdecor/shadow_radius"};
     wf::option_wrapper_t<std::string> overlay_engine{"pixdecor/overlay_engine"};
-    int radius     = (std::string(overlay_engine) == "rounded_corners") ? int(shadow_radius) : 0;
+    int radius     = (uses_shadow_overlay(std::string(overlay_engine))) ? int(shadow_radius) : 0;
     uint32_t edges = 0;
     for (auto& area : layout_areas)
     {
diff --git a/src/deco-subsurface.cpp b/src/deco-subsurface.cpp
index 5a51dee..f626204 100644
--- a/src/deco-subsurface.cpp
+++ b/src/deco-subsurface.cpp
@@ -6,6 +6,8 @@
 #include "wayfire/signal-provider.hpp"
 #include "wayfire/toplevel.hpp"
 #include <memory>
+#include <algorithm>
+#include <cmath>
 #define GLM_FORCE_RADIANS
 #include <glm/gtc/matrix_transform.hpp>
 
@@ -35,6 +37,7 @@ namespace pixdecor
 {
 wf::option_wrapper_t<wf::color_t> effect_color{"pixdecor/effect_color"};
 wf::option_wrapper_t<int> shadow_radius{"pixdecor/shadow_radius"};
+wf::option_wrapper_t<int> rounded_corner_radius{"pixdecor/rounded_corner_radius"};
 wf::option_wrapper_t<std::string> titlebar_opt{"pixdecor/titlebar"};
 wf::option_wrapper_t<int> csd_titlebar_height{"pixdecor/csd_titlebar_height"};
 wf::option_wrapper_t<bool> enable_shade{"pixdecor/enable_shade"};
@@ -208,7 +211,7 @@ class simple_decoration_node_t : public wf::scene::node_t, public wf::pointer_in
             }
 
             /* Draw title & buttons */
-            auto title_border = border + ((std::string(overlay_engine) == "rounded_corners" &&
+            auto title_border = border + ((uses_shadow_overlay(std::string(overlay_engine)) &&
                 (!maximized || maximized_shadows)) ? int(shadow_radius) * 2 : 0);
             for (auto item : renderables)
             {
@@ -236,7 +239,7 @@ class simple_decoration_node_t : public wf::scene::node_t, public wf::pointer_in
 
         double border = theme.get_border_size();
         double r =
-            (std::string(overlay_engine) == "rounded_corners" &&
+            (uses_shadow_overlay(std::string(overlay_engine)) &&
                 (!maximized || (maximized && maximized_shadows))) ? int(shadow_radius) * 2 : 0;
         r -= MIN_RESIZE_HANDLE_SIZE - std::min((int)border, MIN_RESIZE_HANDLE_SIZE);
         wf::pointf_t local = at - wf::pointf_t{get_offset()};
@@ -249,6 +252,22 @@ class simple_decoration_node_t : public wf::scene::node_t, public wf::pointer_in
 
             if (deco_region.contains_pointf(local))
             {
+                if (std::string(overlay_engine) == "sculpted")
+                {
+                    const double shadow = uses_shadow_overlay(std::string(overlay_engine)) &&
+                        (!maximized || maximized_shadows) ? int(shadow_radius) * 2 : 0;
+                    const double w = g.width + 2 * r - 2 * shadow;
+                    const double h = g.height + 2 * r - 2 * shadow;
+                    const double radius = std::max(0.0, std::min({double(rounded_corner_radius),
+                        w / 2, h / 2, std::floor(border / (1.0 - 1.0 / std::sqrt(2.0)))}));
+                    const double x = local.x - shadow, y = local.y - shadow;
+                    const double dx = std::max({radius - x, 0.0, x - (w - radius)});
+                    const double dy = std::max({radius - y, 0.0, y - (h - radius)});
+                    if (dx > 0 && dy > 0 && dx * dx + dy * dy > radius * radius)
+                    {
+                        return {};
+                    }
+                }
                 return wf::scene::input_node_t{
                     .node = this,
                     .local_coords = local,
@@ -321,7 +340,7 @@ class simple_decoration_node_t : public wf::scene::node_t, public wf::pointer_in
                     self->current_cursor_position, self->theme.get_decor_color(activated),
                     self->theme.get_shadow_color(activated), effect_color,
                     self->theme.get_title_height(), self->theme.get_border_size(),
-                    (std::string(overlay_engine) == "rounded_corners" && !maximized) ? shadow_radius : 0);
+                    (uses_shadow_overlay(std::string(overlay_engine)) && !maximized) ? shadow_radius : 0);
             }
 
             self->render_region(data, offset);
@@ -537,7 +556,7 @@ class simple_decoration_node_t : public wf::scene::node_t, public wf::pointer_in
                 this->cached_region.clear();
             } else
             {
-                int shadow_thickness = std::string(overlay_engine) == "rounded_corners" &&
+                int shadow_thickness = uses_shadow_overlay(std::string(overlay_engine)) &&
                     (!maximized || (maximized && maximized_shadows)) ? int(shadow_radius) * 2 : 0;
 
                 current_thickness = theme.get_border_size() + shadow_thickness;
@@ -649,7 +668,7 @@ wf::decoration_margins_t simple_decorator_t::get_margins(const wf::toplevel_stat
     bool maximized = state.tiled_edges;
     deco->theme.set_maximize(maximized);
 
-    this->shadow_thickness = std::string(overlay_engine) == "rounded_corners" &&
+    this->shadow_thickness = uses_shadow_overlay(std::string(overlay_engine)) &&
         (!state.tiled_edges || (state.tiled_edges && maximized_shadows)) ? int(shadow_radius) * 2 : 0;
 
     double thickness = deco->theme.get_border_size() + this->shadow_thickness;
diff --git a/src/decoration.cpp b/src/decoration.cpp
index e5f3ec2..0ceb16f 100644
--- a/src/decoration.cpp
+++ b/src/decoration.cpp
@@ -19,6 +19,8 @@
 #include <wayfire/bindings-repository.hpp>
 #include <wayfire/plugins/ipc/ipc-activator.hpp>
 #include "shade.hpp"
+#include "deco-effects.hpp"
+#include <wayfire/config/config-manager.hpp>
 
 namespace wf
 {
@@ -57,6 +59,8 @@ class wayfire_pixdecor : public wf::plugin_interface_t
     wf::option_wrapper_t<std::string> effect_type{"pixdecor/effect_type"};
     wf::option_wrapper_t<std::string> overlay_engine{"pixdecor/overlay_engine"};
     wf::option_wrapper_t<bool> effect_animate{"pixdecor/animate"};
+    wf::option_wrapper_t<double> border_depth;
+    wf::option_wrapper_t<wf::color_t> pinstripe_color;
     wf::option_wrapper_t<int> rounded_corner_radius{"pixdecor/rounded_corner_radius"};
     wf::option_wrapper_t<int> shadow_radius{"pixdecor/shadow_radius"};
     wf::option_wrapper_t<wf::color_t> shadow_color{"pixdecor/shadow_color"};
@@ -222,6 +226,23 @@ class wayfire_pixdecor : public wf::plugin_interface_t
 
     void init() override
     {
+        // Promote new options when replacing a module in an older resident core.
+        auto section = wf::get_core().config->get_section("pixdecor");
+        auto promote = [&] (const std::string& name, auto value)
+        {
+            using T = decltype(value);
+            auto previous = section->get_option_or(name);
+            if (!std::dynamic_pointer_cast<wf::config::option_t<T>>(previous))
+            {
+                auto option = std::make_shared<wf::config::option_t<T>>(name, value);
+                if (previous) option->set_value_str(previous->get_value_str());
+                section->register_new_option(option);
+            }
+        };
+        promote("border_depth", 0.65);
+        promote("pinstripe_color", wf::color_t{90.0 / 255, 113.0 / 255, 129.0 / 255, 36.0 / 255});
+        border_depth.load_option("pixdecor/border_depth");
+        pinstripe_color.load_option("pixdecor/pinstripe_color");
         auto& ol = wf::get_core().output_layout;
         ol->connect(&on_output_added);
         ol->connect(&on_output_removed);
@@ -427,7 +448,7 @@ class wayfire_pixdecor : public wf::plugin_interface_t
         title_font.set_callback([=] {recreate_frames();});
         shadow_radius.set_callback([=]
         {
-            option_changed_cb(false, (std::string(overlay_engine) == "rounded_corners"));
+            option_changed_cb(false, (uses_shadow_overlay(std::string(overlay_engine))));
         });
         shadow_color.set_callback([=]
         {
@@ -455,6 +476,21 @@ class wayfire_pixdecor : public wf::plugin_interface_t
                 view->damage();
             }
         });
+        auto repaint_frames = [=] ()
+        {
+            for (auto& view : wf::get_core().get_all_views())
+            {
+                if (auto toplevel = wf::toplevel_cast(view))
+                {
+                    if (toplevel->toplevel()->get_data<simple_decorator_t>())
+                    {
+                        view->damage();
+                    }
+                }
+            }
+        };
+        border_depth.set_callback(repaint_frames);
+        pinstripe_color.set_callback(repaint_frames);
         rounded_corner_radius.set_callback([=]
         {
             for (auto& view : wf::get_core().get_all_views())
@@ -629,7 +665,7 @@ class wayfire_pixdecor : public wf::plugin_interface_t
                 continue;
             }
 
-            if (std::string(overlay_engine) == "rounded_corners")
+            if (uses_shadow_overlay(std::string(overlay_engine)))
             {
                 pending.margins =
                 {double(shadow_radius * 2), double(shadow_radius * 2),
diff --git a/src/meson.build b/src/meson.build
index 000ce95..66f1573 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,5 +1,6 @@
 pixdecor = shared_module('pixdecor',
         ['decoration.cpp', 'deco-subsurface.cpp', 'deco-button.cpp', 'deco-layout.cpp', 'deco-theme.cpp', 'deco-effects.cpp'],
         dependencies: [wayfire],
+        link_args: ['-Wl,-Bsymbolic'],
         install: true,
         install_dir: join_paths(get_option('libdir'), 'wayfire'))
diff --git a/src/sculpted-overlay.hpp b/src/sculpted-overlay.hpp
new file mode 100644
index 0000000..99f0568
--- /dev/null
+++ b/src/sculpted-overlay.hpp
@@ -0,0 +1,84 @@
+#pragma once
+
+namespace wf::pixdecor
+{
+// Static shell material, composed over the selected border effect. Coordinates
+// and shadow margins follow Pixdecor's existing rounded-corner overlay.
+inline constexpr const char *sculpted_overlay = R"(
+#version 320 es
+precision highp float;
+layout(binding = 0, rgba32f) readonly uniform highp image2D in_frame;
+layout(binding = 0, rgba32f) writeonly uniform highp image2D out_frame;
+layout(local_size_x = 16, local_size_y = 16) in;
+layout(location = 1) uniform int title_height;
+layout(location = 2) uniform int border_size;
+layout(location = 5) uniform int width;
+layout(location = 6) uniform int height;
+layout(location = 7) uniform int corner_radius;
+layout(location = 8) uniform int shadow_radius;
+layout(location = 9) uniform vec4 shadow_color;
+layout(location = 10) uniform float border_depth;
+layout(location = 11) uniform vec4 pinstripe_color;
+
+vec4 over(vec4 base, vec4 tint)
+{
+    return vec4(tint.rgb * tint.a + base.rgb * (1.0 - tint.a),
+                tint.a + base.a * (1.0 - tint.a));
+}
+
+void main()
+{
+    ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
+    if (pos.x >= width || pos.y >= height) return;
+    // Application pixels are owned by the child surface, never this overlay.
+    if (pos.x >= border_size && pos.x < width - border_size &&
+        pos.y >= title_height && pos.y < height - border_size) return;
+
+    float margin = 2.0 * float(shadow_radius);
+    float border = max(0.0, float(border_size) - margin);
+    vec2 lo = vec2(margin), hi = vec2(width, height) - lo;
+    vec2 halfsize = max(vec2(0.0), (hi - lo) * 0.5);
+    // Keep a square application's inner corners inside the rounded frame.
+    float radius = clamp(float(corner_radius), 0.0,
+        min(min(halfsize.x, halfsize.y), floor(border / (1.0 - inversesqrt(2.0)))));
+    vec2 p = vec2(pos) + 0.5;
+    vec2 center = (lo + hi) * 0.5;
+    vec2 q = abs(p - center) - (halfsize - radius);
+    float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
+    float coverage = clamp(0.5 - d, 0.0, 1.0);
+    vec4 shadow = vec4(0.0);
+    if (shadow_radius > 0)
+    {
+        float a = shadow_color.a * exp(-pow(max(d, 0.0) / float(shadow_radius), 2.0));
+        shadow = vec4(shadow_color.rgb * a, a);
+    }
+    if (coverage == 0.0)
+    {
+        imageStore(out_frame, pos, shadow);
+        return;
+    }
+
+    vec4 body = imageLoad(in_frame, pos);
+    body.rgb *= body.a;
+    float inset = max(0.0, -d);
+    float strength = clamp(border_depth, 0.0, 1.0) / 0.65;
+    float falloff = border > 0.0 ? clamp(1.0 - inset / border, 0.0, 1.0) : 0.0;
+    vec2 outward = p - clamp(p, lo + radius, hi - radius);
+    if (dot(outward, outward) < 0.0001)
+    {
+        vec2 edges = min(p - lo, hi - p);
+        outward = edges.x < edges.y ? vec2(p.x < center.x ? -1.0 : 1.0, 0.0) :
+                                     vec2(0.0, p.y < center.y ? -1.0 : 1.0);
+    }
+    outward = normalize(outward);
+    float light = max(-outward.y, 0.0) * 0.170 + max(-outward.x, 0.0) * 0.045;
+    float shade = max(outward.y, 0.0) * 0.500 + max(outward.x, 0.0) * 0.160;
+    body = over(body, vec4(1.0, 1.0, 1.0, clamp(light * strength * falloff, 0.0, 1.0)));
+    body = over(body, vec4(0.0, 0.0, 0.0, clamp(shade * strength * falloff, 0.0, 1.0)));
+    vec4 rim = pinstripe_color;
+    rim.a *= 1.0 - smoothstep(0.5, 1.5, inset);
+    body = over(body, rim);
+    imageStore(out_frame, pos, body * coverage + shadow * (1.0 - coverage));
+}
+)";
+}