Skip to content

Fix blur theme backdrop, corners, margin issues & simplify AutoDropShadow#4513

Merged
DavidGBrett merged 6 commits into
devfrom
fix-theme-issues
Jun 7, 2026
Merged

Fix blur theme backdrop, corners, margin issues & simplify AutoDropShadow#4513
DavidGBrett merged 6 commits into
devfrom
fix-theme-issues

Conversation

@DavidGBrett

@DavidGBrett DavidGBrett commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Closes #4457 and #4512
Potentially also closes #3624

Bug Fixes

  • Fixes the double corners issue by removing the call to RemoveDropShadowEffectFromCurrentTheme for blur themes as they both made conflicting modifications to the style - instead just clear all window border styles in the SetBlurForWindow method
  • Improves RemoveDropShadowEffectFromCurrentTheme so that it only removes the drop shadow margin if necessary - avoiding shrinking of the main window
  • Calls DwmExtendFrameIntoClientArea when using blur themes so that removal of non client area by WindowStyle=None is not an issue

Minor Refactor

Simplified AutoDropShadow by moving any non drop shadow related code to SetBlurForWindow, including the cleanup for it in the now removed BlurEnabled branch but also the DWM corner prefernce as that only needs to consider if the theme has blur or not.


Summary by cubic

Fixes blur/backdrop and drop shadow interactions so Windows themes render correctly. Mica/Acrylic now cover the full window with WindowStyle=None; corners, margins, and resize borders are correct.

Summary of changes

  • Changed: Always call AutoDropShadow after SetBlurForWindow; it only adds/removes the effect and no-ops on blur.
  • Changed: SetBlurForWindow now sets corner preference (Round for blur, Default otherwise), clears any directly set WindowBorderStyle, and resets resize border to system default.
  • Changed: RemoveDropShadowEffectFromCurrentTheme subtracts shadow margin only when an Effect setter exists to avoid cumulative shrink.
  • Added: Extend the DWM frame into the client area via DwmExtendFrameIntoClientArea (MARGINS = -1) so backdrops render across the entire window.
  • Removed: Calling RemoveDropShadowEffectFromCurrentTheme for blur themes; removed stale commented code in RefreshFrameAsync.
  • Memory: Negligible; one extra P/Invoke per refresh, no long-lived allocations.
  • Security: Low risk; uses OS APIs only, no new inputs.
  • Tests: None.

Release Note
Windows blur themes now render full-window Mica/Acrylic with correct corners, shadows, margins, and resize borders.

Written for commit 7cf0b97. Summary will update on new commits.

Review in cubic

@github-actions github-actions Bot added this to the 2.2.0 milestone Jun 6, 2026
@Jack251970 Jack251970 added bug Something isn't working kind/ui related to UI, icons, themes, etc labels Jun 6, 2026
@DavidGBrett DavidGBrett linked an issue Jun 6, 2026 that may be closed by this pull request
3 tasks
@DavidGBrett DavidGBrett marked this pull request as ready for review June 6, 2026 14:30
@DavidGBrett DavidGBrett marked this pull request as draft June 6, 2026 14:30
@coderabbitai coderabbitai Bot removed the bug Something isn't working label Jun 6, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 issues found across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread Flow.Launcher.Infrastructure/Win32Helper.cs Outdated
Comment thread Flow.Launcher.Core/Resource/Theme.cs Outdated
@DavidGBrett DavidGBrett added the bug Something isn't working label Jun 6, 2026
@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e90f0cc4-7715-4b88-9586-5b273e1fc523

📥 Commits

Reviewing files that changed from the base of the PR and between 68b9169 and 7cf0b97.

📒 Files selected for processing (3)
  • Flow.Launcher.Core/Resource/Theme.cs
  • Flow.Launcher.Infrastructure/NativeMethods.txt
  • Flow.Launcher.Infrastructure/Win32Helper.cs
✅ Files skipped from review due to trivial changes (1)
  • Flow.Launcher.Infrastructure/NativeMethods.txt
🚧 Files skipped from review as they are similar to previous changes (2)
  • Flow.Launcher.Infrastructure/Win32Helper.cs
  • Flow.Launcher.Core/Resource/Theme.cs

📝 Walkthrough

Walkthrough

Extends DWM backdrop into the full client area, always applies blur before drop-shadow during frame refresh, and adjusts theme resource/effect handling to avoid double-corner rendering and prevent repeated margin shrinking.

Changes

Blur Theme Double-Corner Fix

Layer / File(s) Summary
DWM backdrop extension infrastructure
Flow.Launcher.Infrastructure/NativeMethods.txt, Flow.Launcher.Infrastructure/Win32Helper.cs
Adds DwmExtendFrameIntoClientArea entry, imports Windows.Win32.UI.Controls, and updates DWMSetBackdropForWindow to call DwmExtendFrameIntoClientArea with MARGINS = -1 before setting DWMWA_SYSTEMBACKDROP_TYPE.
Frame refresh orchestration
Flow.Launcher.Core/Resource/Theme.cs
RefreshFrameAsync now dispatches SetBlurForWindow(...) first, then AutoDropShadow(useDropShadowEffect) unconditionally.
SetBlurForWindow: blur resource and corner handling
Flow.Launcher.Core/Resource/Theme.cs
In blur path, set window corner preference to "Round", remove Application.Current.Resources["WindowBorderStyle"] if present so merged dictionary style wins, and reset resize-border thickness.
AutoDropShadow behavior simplification
Flow.Launcher.Core/Resource/Theme.cs
When BlurEnabled is true, AutoDropShadow returns early; otherwise it only adds/removes drop-shadow based on useDropShadowEffect.
RemoveDropShadowEffect margin guard
Flow.Launcher.Core/Resource/Theme.cs
RemoveDropShadowEffectFromCurrentTheme checks whether WindowBorderStyle actually has an UIElement.EffectProperty setter and only then subtracts ShadowExtraMargin from the margin to avoid repeated shrinking.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

Suggested reviewers

  • Jack251970
  • jjw24
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main changes: fixing blur theme backdrop, corners, margin issues and simplifying AutoDropShadow, which aligns with the changeset.
Description check ✅ Passed The description is related to the changeset, explaining bug fixes for blur theme backdrop and corners, improvements to RemoveDropShadowEffectFromCurrentTheme, and simplification of AutoDropShadow.
Linked Issues check ✅ Passed The changes address the core requirements from linked issues #4457 and #4512: fixing duplicated corners on blur themes by clearing WindowBorderStyle conflicts, improving margin handling, and extending DWM frame for proper backdrop rendering.
Out of Scope Changes check ✅ Passed All changes are within scope: Theme.cs modifications for blur/drop-shadow handling, Win32Helper changes for DwmExtendFrameIntoClientArea, and NativeMethods.txt addition of the native method name are all directly related to fixing the linked issues.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-theme-issues

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Flow.Launcher.Infrastructure/Win32Helper.cs (1)

65-78: ⚠️ Potential issue | 🟠 Major

Retract DWM client-area frame on BackdropTypes.None and include DwmExtendFrameIntoClientArea success in the return value

DWMSetBackdropForWindow(...) calls DwmExtendFrameIntoClientArea(...) only when backdrop is not BackdropTypes.None (using -1 margins), so switching to BackdropTypes.None never retracts the previous client-area extension. Also, the method’s bool return currently reflects only DwmSetWindowAttribute(...); the DwmExtendFrameIntoClientArea(...) result is ignored.

Suggested fix
         public static unsafe bool DWMSetBackdropForWindow(Window window, BackdropTypes backdrop)
         {
+            var hwnd = GetWindowHandle(window);
             var backdropType = backdrop switch
             {
                 BackdropTypes.Acrylic => DWM_SYSTEMBACKDROP_TYPE.DWMSBT_TRANSIENTWINDOW,
                 BackdropTypes.Mica => DWM_SYSTEMBACKDROP_TYPE.DWMSBT_MAINWINDOW,
                 BackdropTypes.MicaAlt => DWM_SYSTEMBACKDROP_TYPE.DWMSBT_TABBEDWINDOW,
                 _ => DWM_SYSTEMBACKDROP_TYPE.DWMSBT_AUTO
             };
 
-            // The backdrop renders in the non-client frame area. WindowStyle=None
-            // removes that area, so we extend it across the entire client area.
-            // https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmextendframeintoclientarea
-            if (backdrop is not BackdropTypes.None)
-            {
-                var margins = new MARGINS { cxLeftWidth = -1, cxRightWidth = -1, cyTopHeight = -1, cyBottomHeight = -1 };
-                PInvoke.DwmExtendFrameIntoClientArea(GetWindowHandle(window), in margins);
-            }
+            var margins = backdrop is BackdropTypes.None
+                ? new MARGINS()
+                : new MARGINS { cxLeftWidth = -1, cxRightWidth = -1, cyTopHeight = -1, cyBottomHeight = -1 };
+
+            var extendResult = PInvoke.DwmExtendFrameIntoClientArea(hwnd, in margins);
 
-            return PInvoke.DwmSetWindowAttribute(
-                GetWindowHandle(window),
+            return extendResult.Succeeded && PInvoke.DwmSetWindowAttribute(
+                hwnd,
                 DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE,
                 &backdropType,
                 (uint)Marshal.SizeOf<int>()).Succeeded;
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Flow.Launcher.Infrastructure/Win32Helper.cs` around lines 65 - 78, The method
currently only extends the frame when backdrop != BackdropTypes.None and ignores
that call's result; update the logic in DWMSetBackdropForWindow so that when
backdrop == BackdropTypes.None you call
PInvoke.DwmExtendFrameIntoClientArea(GetWindowHandle(window), in margins) with
margins set to zeros to retract the extension, capture the HRESULT/return value
of that call, and then return a combined success boolean that requires both the
DwmExtendFrameIntoClientArea call and the subsequent
PInvoke.DwmSetWindowAttribute(GetWindowHandle(window),
DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, &backdropType,
(uint)Marshal.SizeOf<int>()) to have Succeeded; use the existing
GetWindowHandle(window), backdropType and DWMWINDOWATTRIBUTE symbols to locate
the code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Flow.Launcher.Core/Resource/Theme.cs`:
- Around line 741-745: The blur-theme branch removed the WindowBorderStyle
override but forgot to restore the resize border cleanup that
RemoveDropShadowEffectFromCurrentTheme() used to perform; update the same block
that calls SetWindowCornerPreference("Round") and removes "WindowBorderStyle" to
also call SetResizeBoarderThickness(null) (or invoke
RemoveDropShadowEffectFromCurrentTheme() if that function contains the correct
cleanup) so the enlarged resize border is cleared when switching to blur themes.

---

Outside diff comments:
In `@Flow.Launcher.Infrastructure/Win32Helper.cs`:
- Around line 65-78: The method currently only extends the frame when backdrop
!= BackdropTypes.None and ignores that call's result; update the logic in
DWMSetBackdropForWindow so that when backdrop == BackdropTypes.None you call
PInvoke.DwmExtendFrameIntoClientArea(GetWindowHandle(window), in margins) with
margins set to zeros to retract the extension, capture the HRESULT/return value
of that call, and then return a combined success boolean that requires both the
DwmExtendFrameIntoClientArea call and the subsequent
PInvoke.DwmSetWindowAttribute(GetWindowHandle(window),
DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, &backdropType,
(uint)Marshal.SizeOf<int>()) to have Succeeded; use the existing
GetWindowHandle(window), backdropType and DWMWINDOWATTRIBUTE symbols to locate
the code.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9fd603f2-aef7-4031-9480-c557f3d25b91

📥 Commits

Reviewing files that changed from the base of the PR and between 0f2bc99 and 6f6d5fc.

📒 Files selected for processing (3)
  • Flow.Launcher.Core/Resource/Theme.cs
  • Flow.Launcher.Infrastructure/NativeMethods.txt
  • Flow.Launcher.Infrastructure/Win32Helper.cs

Comment thread Flow.Launcher.Core/Resource/Theme.cs Outdated
@DavidGBrett DavidGBrett force-pushed the fix-theme-issues branch 2 times, most recently from 64a50d8 to 68b9169 Compare June 6, 2026 19:44
@DavidGBrett DavidGBrett marked this pull request as ready for review June 6, 2026 19:44
@coderabbitai coderabbitai Bot removed the bug Something isn't working label Jun 6, 2026
@DavidGBrett DavidGBrett changed the title Fix theme issues Fix blur theme backdrop, corners, margin issues & clean up AutoDropShadow Jun 6, 2026
@DavidGBrett DavidGBrett changed the title Fix blur theme backdrop, corners, margin issues & clean up AutoDropShadow Fix blur theme backdrop, corners, margin issues & simplify AutoDropShadow Jun 6, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Re-trigger cubic

@DavidGBrett DavidGBrett added bug Something isn't working Code Refactor labels Jun 6, 2026
@DavidGBrett DavidGBrett requested a review from Jack251970 June 6, 2026 19:56
…der reset from AutoDropShadow to SetBlurForWindow

- AutoDropShadow is now simplified to only handle adding or removing the drop shadow effect.
- The WindowBorderStyle removal, and resize border reset were just cleanup
for SetBlurForWindow so make more sense to be there.
- The Corner prefernce was only really a binary choice between blur
enabled or not - so SetBlurForWindow can also handle that.
@coderabbitai coderabbitai Bot removed the bug Something isn't working label Jun 7, 2026

@Jack251970 Jack251970 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@DavidGBrett DavidGBrett merged commit 493f16c into dev Jun 7, 2026
3 checks passed
@DavidGBrett DavidGBrett deleted the fix-theme-issues branch June 7, 2026 08:54
@jjw24 jjw24 added the bug Something isn't working label Jun 7, 2026
@jjw24 jjw24 modified the milestones: 2.2.0, 2.1.3 Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Code Refactor kind/ui related to UI, icons, themes, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Backdrop not applying on 2.1.2 BUG: CornerRadius declaration not ignored for blur themes BUG: Recent Update Broke Some Acrylic/Blur Themes

3 participants