Skip to content

Make main window border follow the system accent color setting#5174

Merged
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/window-border-follow-accent-color
Jul 22, 2026
Merged

Make main window border follow the system accent color setting#5174
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/window-border-follow-accent-color

Conversation

@GabrielDuf

Copy link
Copy Markdown
Contributor

This pull request enhances the window border color handling in MainWindow.axaml.cs to better match Windows 11 system accent and theme changes. The code now reads Windows DWM registry values to use the system accent color for the window border when enabled, and ensures the border color updates dynamically in response to system color or theme changes.

Window border color improvements:

  • The ApplyWindowBorderColor method now attempts to read the ColorPrevalence and AccentColor values from the Windows DWM registry. If accent color is enabled, it uses the system accent color for the window border; otherwise, it falls back to the per-theme neutral color.
  • Added the TryReadDwmDword helper method to safely read DWORD values from the registry.
  • Added necessary P/Invoke definitions for registry access (RegGetValueW, constants, and HKEY_CURRENT_USER) in the NativeMethods class.

Dynamic update on system changes:

  • The window now listens for WM_DWMCOLORIZATIONCOLORCHANGED and WM_SETTINGCHANGE messages, and reapplies the border color when these occur, ensuring the border stays in sync with system changes.

Code cleanup:

  • Removed outdated comments and clarified the logic around theme and accent color handling for the window border.

Copilot AI 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.

Pull request overview

Updates the main window border to follow Windows 11 accent-color preferences and react to system changes.

Changes:

  • Reads DWM accent settings with a neutral theme fallback.
  • Reapplies border colors after theme or DWM setting changes.
  • Adds registry-access interop.

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

Comment thread src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@GabrielDuf
Gabriel Dufresne (GabrielDuf) merged commit 82a038f into main Jul 22, 2026
5 checks passed
@GabrielDuf
Gabriel Dufresne (GabrielDuf) deleted the fix/window-border-follow-accent-color branch July 22, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants