lepoco / wpfui

WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
https://wpfui.lepo.co
MIT License
7.03k stars 666 forks source link

Fix titlebar color when using backdrop in WPF `Window` #1122

Closed pomianowski closed 3 weeks ago

pomianowski commented 3 weeks ago

Pull request type

Please check the type of change your PR introduces:

What is the current behavior?

Window can have a color in custom titlebar when Show accent colors option is enabled in Windows.

Issue Number: N/A

What is the new behavior?

After enabling Mica backdrop, the titlebar color should be removed.

image

pomianowski commented 3 weeks ago

FYI: @Jay-o-Way, @aquinn39 rel.: https://github.com/microsoft/PowerToys/issues/30206

jaimecbernardo commented 2 weeks ago

@pomianowski Awesome work here :) I've added this fix to https://github.com/microsoft/PowerToys/pull/33458 , while 4.0.0 is not released. Thank you!

Quick question: Why uint titlebarPvAttribute = 0xFFFFFFFE; and not uint titlebarPvAttribute = 0xFFFFFFFF; ?

aquinn39 commented 2 weeks ago

Quick question: Why uint titlebarPvAttribute = 0xFFFFFFFE; and not uint titlebarPvAttribute = 0xFFFFFFFF; ?

I got the value (DWMWA_COLOR_NONE) from DWMWA_BORDER_COLOR here. This value appearantly hides the window border, so I thought maybe it might work for DWMWA_CAPTION_COLOR as well, which it did. 0xFFFFFFFF (DWMWA_COLOR_DEFAULT) just resets the title bar colour to the default system behaviour, which means using the accent colour if you have that option enabled - that behaviour actually is documented under DWMWA_CAPTION_COLOR.

Makes me wonder if DWMWA_COLOR_NONE (0xFFFFFFFE) also works on DWMWA_TEXT_COLOR to hide the caption text (not that it's necessary in this case).

aquinn39 commented 2 weeks ago

Interestingly this behaviour is actually correctly documented in dwmapi.h. image