xilem: WindowView::with_default_properties for runtime theme swap#1822
Open
mark-ik wants to merge 2 commits into
Open
xilem: WindowView::with_default_properties for runtime theme swap#1822mark-ik wants to merge 2 commits into
mark-ik wants to merge 2 commits into
Conversation
Surfaces `RenderRoot::set_default_properties` (added in linebender#1821) reactively on `WindowView`, so a Xilem app can swap its theme's default property set mid-session without restarting. `WindowView` gains a reactive `default_properties: Option<Arc<DefaultProperties>>` field plus `with_default_properties(..)`. The new set is pushed to the render root in `rebuild` only when the `Arc` identity changes (`Arc::ptr_eq`), so steady-state frames don't re-apply. `None` (the default) leaves the startup set untouched. Signed-off-by: Markik <54276851+mark-ik@users.noreply.github.com>
mark-ik
added a commit
to mark-ik/xilem
that referenced
this pull request
May 31, 2026
Trim verbose field/builder docs and replace the match-style rebuild block with the upstream-idiomatic if-let chain + `is_none_or`, matching linebender#1822. Behavior unchanged; verified live: woodshed theme toggle still recolors default-driven widgets.
mark-ik
marked this pull request as ready for review
May 31, 2026 21:22
PoignardAzur
approved these changes
Jul 3, 2026
Comment on lines
+127
to
+134
| if let Some(props) = &self.default_properties | ||
| && prev | ||
| .default_properties | ||
| .as_ref() | ||
| .is_none_or(|p| !Arc::ptr_eq(p, props)) | ||
| { | ||
| window.render_root().set_default_properties(props.clone()); | ||
| } |
Contributor
There was a problem hiding this comment.
I think this is fine for now, but I'd add a TODO comment to mention the case where default_properties go from Some to None.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
One file:
xilem/src/window_view.rs.Background
[
RenderRoot::set_default_properties] (added in #1821) lets a host swap the tree-wide default property set at runtime, but it's only reachable from code that holds aRenderRoot. Xilem apps go throughWindowView, so they can't reach the new method at the moment.Fix
Adds
WindowView::with_default_properties(Arc<DefaultProperties>). The new set gets pushed to the render root inrebuildonly when theArcidentity changes (Arc::ptr_eq), so steady-state frames don't re-apply.None(the default) leaves the startup set untouched.Testing
No tests in this PR. Xilem doesn't have masonry's
TestHarness, and the propagation invariant is already covered by the test that landed with #1821. Anecdotally, when applied to my fork in my app, a theme toggle correctly recolors ContentColor-defaulted widgets without restart. I have screenshots or screen recordings available if desired.Disclosure: AI-assisted; still my responsibility.
Closes #1819.
Relevant issues:
background_color(), system light/dark detection, and the per-widget override API to that issue.