Skip to content

Allow adjusting window background blur#30

Draft
omeriadon wants to merge 3 commits intoMrKai77:mainfrom
omeriadon:window-background-blur
Draft

Allow adjusting window background blur#30
omeriadon wants to merge 3 commits intoMrKai77:mainfrom
omeriadon:window-background-blur

Conversation

@omeriadon
Copy link
Copy Markdown
Contributor

This PR adds the ability for LuminareWindow to have a custom blur style, with the default being the existing version.

When initialising LuminareWindow, you can also set a blur style from LuminareBackgroundBlurStyle:

LuminareWindow { ... } // existing material
LuminareWindow(backgroundBlurStyle: .regular) { ... } // existing material
LuminareWindow(backgroundBlurStyle: .custom(radius: CGFloat)) { ... } // custom blur

.luminareBackground() pulls this value from the environment, and I didn't make it locally-overrideable because it doesn't make sense to change the value in one place.

These two options exist because .custom uses private APIs, that are relatively stable, but nonetheless private. the .regular version uses the existing version and is stable.

@omeriadon omeriadon marked this pull request as ready for review March 23, 2026 12:52
Copilot AI review requested due to automatic review settings March 23, 2026 12:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a configurable background blur style for LuminareWindow and Luminare backgrounds, including an opt-in custom blur radius that relies on private APIs.

Changes:

  • Introduces LuminareBackgroundBlurStyle and stores it in EnvironmentValues.
  • Extends LuminareWindow to accept and inject a default backgroundBlurStyle into the root LuminareView.
  • Updates VisualEffectView to optionally apply a custom blur radius and factors the tint overlay into LuminareBackgroundTintOverlay.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Sources/Luminare/Utilities/LuminareBackgroundBlurStyle.swift Adds a public enum describing blur style options (regular/custom).
Sources/Luminare/Utilities/Extensions/View+Extensions.swift Documents that luminareBackground() uses the blur style from the environment.
Sources/Luminare/Utilities/Extensions/EnvironmentValues+Extensions.swift Adds luminareBackgroundBlurStyle environment entry with default .regular.
Sources/Luminare/Main Window/LuminareWindow.swift Adds init parameter to set the blur style and injects it into the root view environment.
Sources/Luminare/Main Window/LuminareView.swift Adds a custom-blur background behind the root view when .custom is selected.
Sources/Luminare/Components/Auxiliary/VisualEffectView.swift Adds blurStyle support and applies a custom blur radius via private layer keys.
Sources/Luminare/Components/Auxiliary/Modifiers/LuminareBackgroundEffectModifier.swift Makes luminareBackground() conditional on .regular and reuses the new tint overlay view.
Sources/Luminare/Components/Auxiliary/LuminareBackgroundTintOverlay.swift New shared view for the tint overlay previously inlined in the modifier.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/Luminare/Main Window/LuminareWindow.swift Outdated
Comment thread Sources/Luminare/Main Window/LuminareWindow.swift
Comment on lines +19 to +26
if blurStyle == .regular {
VisualEffectView(
material: .menu,
blendingMode: .behindWindow
)

Rectangle()
.foregroundStyle(.tint)
.opacity(colorscheme == .light ? 0.025 : 0.1)
.blendMode(.multiply)
LuminareBackgroundTintOverlay()
}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When blurStyle is .custom, luminareBackground() now renders no background at all (the entire ZStack becomes empty). Since the PR description says .luminareBackground() pulls the style from the environment, it should also render a blur for .custom (likely by passing blurStyle into VisualEffectView) rather than becoming a no-op.

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +55
private func applyCustomBlurIfNeeded(to view: NSVisualEffectView) {
guard case let .custom(radius) = blurStyle else {
return
}

view.wantsLayer = true

DispatchQueue.main.async {
guard let backdropLayer = backdropLayer(in: view) else {
return
}

backdropLayer.setValue(radius, forKeyPath: "filters.gaussianBlur.inputRadius")
}
}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateNSView calls applyCustomBlurIfNeeded each time, which schedules an async block and then performs a recursive subview/sublayer search to find the backdrop layer. This can become expensive during frequent SwiftUI updates. Consider caching the resolved backdrop layer in a Coordinator (or associating it with the view once found) and only re-applying the radius when it changes, to avoid repeated tree traversal and repeated async scheduling.

Copilot uses AI. Check for mistakes.
Comment thread Sources/Luminare/Utilities/LuminareBackgroundBlurStyle.swift Outdated
@omeriadon omeriadon marked this pull request as draft March 23, 2026 12:56
omeriadon and others added 2 commits March 23, 2026 20:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants