Skip to content

Refactor AutoDropShadow logic for clarity and correctness#4330

Open
Jack251970 wants to merge 1 commit intodevfrom
AutoDropShadow
Open

Refactor AutoDropShadow logic for clarity and correctness#4330
Jack251970 wants to merge 1 commit intodevfrom
AutoDropShadow

Conversation

@Jack251970
Copy link
Member

@Jack251970 Jack251970 commented Mar 9, 2026

Separated from #4302.

TEST

  • Query window shadow effect still works.

Summary by cubic

Summary of changes

Refactors AutoDropShadow to remove redundant calls and make the blur/backdrop vs. shadow behavior explicit and correct. Improves readability and avoids rendering glitches when blur is enabled.

  • Changed
    • Reworked branching so corner preference and shadow effect are set only within the relevant paths.
    • Behavior mapping:
      • Blur enabled + backdrop supported + shadow enabled → Set corners to Round; remove drop shadow.
      • Blur disabled (or backdrop unsupported) + shadow enabled → Set corners to Default; add drop shadow.
      • Shadow disabled → Set corners to Default; remove drop shadow.
  • Added
    • Clear inline comments explaining each case to prevent future regressions.
  • Removed
    • Unconditional SetWindowCornerPreference("Default") and RemoveDropShadowEffectFromCurrentTheme() at method start.
    • Convoluted branching that duplicated operations.
  • Memory impact
    • None. Fewer calls; no allocations added.
  • Security risks
    • None. UI-only refactor; no new inputs or surfaces.
  • Unit tests
    • No new unit tests. UI behavior validated via manual testing paths.

Written for commit b5d372e. Summary will update on new commits.

Simplified the AutoDropShadow method to avoid redundant operations and improve readability. Now, window corner preference and drop shadow effects are set based on blur and backdrop support, with clear comments explaining each case. Removed convoluted branching for more direct logic.
Copilot AI review requested due to automatic review settings March 9, 2026 10:31
@prlabeler prlabeler bot added Code Refactor enhancement New feature or request labels Mar 9, 2026
@github-actions github-actions bot added this to the 2.2.0 milestone Mar 9, 2026
@gitstream-cm
Copy link

gitstream-cm bot commented Mar 9, 2026

🥷 Code experts: no user but you matched threshold 10

Jack251970 has most 👩‍💻 activity in the files.
Jack251970 has most 🧠 knowledge in the files.

See details

Flow.Launcher.Core/Resource/Theme.cs

Activity based on git-commit:

Jack251970
MAR 64 additions & 79 deletions
FEB
JAN
DEC
NOV
OCT 12 additions & 2 deletions

Knowledge based on git-blame:
Jack251970: 100%

✨ Comment /gs review for LinearB AI review. Learn how to automate it here.

@gitstream-cm
Copy link

gitstream-cm bot commented Mar 9, 2026

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

@coderabbitai coderabbitai bot added bug Something isn't working and removed enhancement New feature or request labels Mar 9, 2026
Copy link
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

Refactors the window corner + drop shadow toggle logic in Theme.AutoDropShadow to be more explicit about blur vs non-blur behavior and to avoid rendering artifacts on blurred themes.

Changes:

  • Reworks AutoDropShadow branching to explicitly handle blur-supported themes by rounding corners and removing WPF drop shadow.
  • Simplifies the “drop shadow disabled” path to always reset corner preference and remove the shadow effect.
  • Adds inline comments documenting the intended behavior differences between blur and non-blur themes.

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

Copy link
Contributor

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

Choose a reason for hiding this comment

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

No issues found across 1 file

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

Refactors AutoDropShadow logic in Theme.cs to simplify corner preference and drop-shadow application based on blur enablement and backdrop support conditions. Centralizes behavior around useDropShadowEffect with conditional handling for blurred versus non-blurred themes.

Changes

Cohort / File(s) Summary
Theme Configuration Refactoring
Flow.Launcher.Core/Resource/Theme.cs
Refactors AutoDropShadow logic to determine corner preferences (Round vs Default) based on blur and backdrop support. When drop-shadow effect is enabled and blur is active with backdrop support, applies Round corners and removes shadow; otherwise defaults to Default corners with conditional shadow application. Simplifies control flow by eliminating pre-branch operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Improve code quality #4312 — Modifies blur/drop-shadow handling in Theme.cs and refactors how blur detection (IsThemeBlurEnabled) is implemented, directly related to the corner and shadow preference logic being adjusted in this PR.

Suggested labels

bug

Suggested reviewers

  • taooceros
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The pull request has no description provided by the author, making it impossible to assess whether the intent aligns with the changeset. Add a pull request description that explains the purpose of the AutoDropShadow logic refactoring and why these changes improve clarity and correctness.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Refactor AutoDropShadow logic for clarity and correctness' directly reflects the main change—refactoring the AutoDropShadow logic to improve clarity and fix correctness issues, as confirmed by the detailed summary.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch AutoDropShadow

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
Flow.Launcher.Core/Resource/Theme.cs (1)

709-723: Logic is correct; consider simplifying redundant condition.

The refactored structure clearly separates the three scenarios. However, the condition on line 711 BlurEnabled && Win32Helper.IsBackdropSupported() is redundant—BlurEnabled is only set to true when IsBackdropSupported() returns true (see line 435).

You could simplify to just if (BlurEnabled):

♻️ Optional simplification
         if (useDropShadowEffect)
         {
-            if (BlurEnabled && Win32Helper.IsBackdropSupported())
+            if (BlurEnabled)
             {
                 // For themes with blur enabled, the window border is rendered by the system,
                 // so we set corner preference to round and remove drop shadow effect to avoid rendering issues.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Flow.Launcher.Core/Resource/Theme.cs` around lines 709 - 723, The if
condition inside the useDropShadowEffect block redundantly checks "BlurEnabled
&& Win32Helper.IsBackdropSupported()" even though BlurEnabled is only set true
when IsBackdropSupported() is true; simplify the condition to just "if
(BlurEnabled)" in the block that calls SetWindowCornerPreference,
RemoveDropShadowEffectFromCurrentTheme, and AddDropShadowEffectToCurrentTheme so
behavior remains identical but the check is clearer and less redundant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Flow.Launcher.Core/Resource/Theme.cs`:
- Around line 709-723: The if condition inside the useDropShadowEffect block
redundantly checks "BlurEnabled && Win32Helper.IsBackdropSupported()" even
though BlurEnabled is only set true when IsBackdropSupported() is true; simplify
the condition to just "if (BlurEnabled)" in the block that calls
SetWindowCornerPreference, RemoveDropShadowEffectFromCurrentTheme, and
AddDropShadowEffectToCurrentTheme so behavior remains identical but the check is
clearer and less redundant.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 50fe9948-6917-4f1b-886a-145f9874788c

📥 Commits

Reviewing files that changed from the base of the PR and between 916b4ff and b5d372e.

📒 Files selected for processing (1)
  • Flow.Launcher.Core/Resource/Theme.cs

@Jack251970 Jack251970 added Small PR Items that are short and don't have much impact. Quick reviews are good. and removed bug Something isn't working labels Mar 9, 2026
@Jack251970 Jack251970 enabled auto-merge March 9, 2026 10:39
@Jack251970 Jack251970 mentioned this pull request Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Refactor Small PR Items that are short and don't have much impact. Quick reviews are good.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants