Repository: zng-ui/zng (language: rust)

Issue:
Countdown example window is not sized correctly in Wayland
#### Following these steps:

1 - Run the `countdown` example.

Issue is that an exact `size` is set, in other platforms this is the inner size, in Wayland the custom chrome is included.


Discussion / hints:
The `shortcut` example has a similar issue, but it is `auto_size`
Current impl of custom chrome also overrides window `padding`, this is the main cause of the visual  change.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4b1b897d6..787cc2ed8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
 # Unreleased
 
+* Fix Wayland custom chrome breaking window padding.
 * Fix window text properties affecting the Wayland fallback chrome text.
 * Fix `swgl` build error.
 * Changed how relative lengths are computed in `offset`, `x` and `y`, now uses the maximum bounded length from constraint, the same as `size` properties.
diff --git a/crates/zng-wgt-window/src/lib.rs b/crates/zng-wgt-window/src/lib.rs
index f9f6e4c1d..b5174b2d9 100644
--- a/crates/zng-wgt-window/src/lib.rs
+++ b/crates/zng-wgt-window/src/lib.rs
@@ -85,7 +85,7 @@ impl Window {
                 custom_chrome_adorner_fn = wgt_fn!(|_| {
                     fallback_chrome()
                 });
-                padding = ContextualizedVar::new(|| {
+                custom_chrome_padding_fn = ContextualizedVar::new(|| {
                     let vars = WINDOW.vars();
                     expr_var! {
                         let title_padding = SideOffsets::new(28, 0, 0, 0);
diff --git a/crates/zng-wgt-window/src/window_properties.rs b/crates/zng-wgt-window/src/window_properties.rs
index e1e79142b..7111b68e2 100644
--- a/crates/zng-wgt-window/src/window_properties.rs
+++ b/crates/zng-wgt-window/src/window_properties.rs
@@ -499,8 +499,18 @@ pub fn prefer_custom_chrome(child: impl UiNode, prefer: impl IntoVar<bool>) -> i
 /// This property behaves exactly like [`adorner_fn`]. Using it instead of adorner frees the adorner property
 /// for other usage in the window instance or in derived window types.
 ///
+/// Note that you can also set the `custom_chrome_padding_fn` to ensure that the content is not hidden behind the adorner.
+///
 /// [`adorner_fn`]: fn@adorner_fn
 #[property(FILL, default(WidgetFn::nil()), widget_impl(Window))]
 pub fn custom_chrome_adorner_fn(child: impl UiNode, custom_chrome: impl IntoVar<WidgetFn<()>>) -> impl UiNode {
     adorner_fn(child, custom_chrome)
 }
+
+/// Extra padding for window content in windows that display a [`custom_chrome_adorner_fn`].
+///
+/// [`custom_chrome_adorner_fn`]: fn@custom_chrome_adorner_fn
+#[property(CHILD_LAYOUT, default(0), widget_impl(Window))]
+pub fn custom_chrome_padding_fn(child: impl UiNode, padding: impl IntoVar<SideOffsets>) -> impl UiNode {
+    zng_wgt_container::padding(child, padding)
+}


Test patch: