-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Windows 10 title bar borders #36429
base: main
Are you sure you want to change the base?
Conversation
@@ -82,6 +82,7 @@ double GetHeight(int maxCustomActionCount) => | |||
}; | |||
|
|||
WindowHelpers.BringToForeground(this.GetWindowHandle()); | |||
WindowHelpers.ForceTopBorder1PixelInset(this.GetWindowHandle()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs for DwmExtendFrameIntoClientArea()
say that:
This function must be called whenever Desktop Window Manager (DWM) composition is toggled. Handle the WM_DWMCOMPOSITIONCHANGED message for composition change notification.
...however, the docs for WM_DWMCOMPOSITIONCHANGED
go on to note that:
As of Windows 8, DWM composition is always enabled, so this message is not sent regardless of video mode changes.
...so I don't think we need to handle this in Window.Activated--just one call at creation time seems to be enough.
@@ -241,6 +241,10 @@ private void OnLaunchedFromRunner(string[] cmdArgs) | |||
// https://github.com/microsoft/microsoft-ui-xaml/issues/7595 - Activate doesn't bring window to the foreground | |||
// Need to call SetForegroundWindow to actually gain focus. | |||
WindowHelpers.BringToForeground(settingsWindow.GetWindowHandle()); | |||
|
|||
// https://github.com/microsoft/microsoft-ui-xaml/issues/8948 - A window's top border incorrectly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this note be inline at call sites, or on the function itself?
Summary of the Pull Request
The top border of windows in Windows 10 will no longer always be black, instead of the appropriate color. Specifically, it fixes the following windows:
PR Checklist
Detailed Description of the Pull Request / Additional comments
This adds a bit of extra code to make any window that's using WinUI and
ExtendsContentIntoTitleBar
also callDwmExtendFrameIntoClientArea()
on that window. This does nothing on Windows 11, but on Windows 10, resolves the "top 1px border is black" bug, with one caveat.That caveat is visible in my changes to the Peek module: I changed it from using
AppWindow.TitleBar.ExtendsContentIntoTitleBar
to just using theExtendsContentIntoTitleBar
property directly on theMUX.Window
. This is because, for some reason, using theAppWindow.TitleBar
's version of the property makesDwmExtendFrameIntoClientArea()
suddenly do nothing. No clue why.This is not ideal, because it's my understanding that
AppWindow.TitleBar
is The Future(tm), and the oldExtendsContentIntoTitleBar
is probably going to be deprecated soon.Other thoughts:
ForceTopBorder1PixelInset()
is kind of a stupid name. Open to suggestions.ForceTopBorder1PixelInset()
so it's a no-op on W11?Validation Steps Performed
Opened each of:
...on Windows 10 and verified that the top borders all showed correctly.
I also validated (just for the Settings Window and HOSTS editor window) that the appearance on Windows 11 was unchanged.