-
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
Changes from 9 commits
ecf0f78
9b1161b
b2fe2b1
2cd50e5
0da6d7f
623b84e
01caed5
f5dbc57
1b5906c
18d0b8b
74c9408
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. The docs for
...however, the docs for
...so I don't think we need to handle this in Window.Activated--just one call at creation time seems to be enough. |
||
} | ||
|
||
private void OnActivated(object sender, WindowActivatedEventArgs args) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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? |
||
// renders as black on Windows 10. | ||
WindowHelpers.ForceTopBorder1PixelInset(WindowNative.GetWindowHandle(settingsWindow)); | ||
} | ||
else | ||
{ | ||
|
@@ -255,6 +259,7 @@ private void OnLaunchedFromRunner(string[] cmdArgs) | |
OobeWindow oobeWindow = new OobeWindow(OOBE.Enums.PowerToysModules.Overview); | ||
oobeWindow.Activate(); | ||
oobeWindow.ExtendsContentIntoTitleBar = true; | ||
WindowHelpers.ForceTopBorder1PixelInset(WindowNative.GetWindowHandle(settingsWindow)); | ||
SetOobeWindow(oobeWindow); | ||
} | ||
else if (ShowScoobe) | ||
|
@@ -263,6 +268,7 @@ private void OnLaunchedFromRunner(string[] cmdArgs) | |
OobeWindow scoobeWindow = new OobeWindow(OOBE.Enums.PowerToysModules.WhatsNew); | ||
scoobeWindow.Activate(); | ||
scoobeWindow.ExtendsContentIntoTitleBar = true; | ||
WindowHelpers.ForceTopBorder1PixelInset(WindowNative.GetWindowHandle(settingsWindow)); | ||
SetOobeWindow(scoobeWindow); | ||
} | ||
else if (ShowFlyout) | ||
|
@@ -310,6 +316,7 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar | |
// Window is also needed to show MessageDialog | ||
settingsWindow = new MainWindow(); | ||
settingsWindow.ExtendsContentIntoTitleBar = true; | ||
WindowHelpers.ForceTopBorder1PixelInset(WindowNative.GetWindowHandle(settingsWindow)); | ||
settingsWindow.Activate(); | ||
settingsWindow.NavigateToSection(StartupPage); | ||
ShowMessageDialog("The application is running in Debug mode.", "DEBUG"); | ||
|
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.
As a safety measure, I think we should still only run this on Windows 10. Perhaps a check to a check like the "IsWindows11" function and renaming this function to ForceTopBorder1PixelInsetOnWindows10. Thoughts?
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.
I'm in favor, but since OSVersionHelper is down in Common.UI, it'd mean:
a) moving
WindowHelpers
down intoCommon.UI
b) moving
OSVersionHelper
up intoManagedCommon
c) Moving
ForceTopBorder1PixelInset()
out ofWindowHelpers
and into some new class inCommon.UI
.I think I have a slight preference for b), because it makes sense to me to keep an OS version check in the top level helper library, instead of a UI-specific one (as Common.UI appears to be). I'm not super familiar with conventions in this repo though, so is there any particular preference?
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.
I think b) makes sense, since it doesn't make sense it's on a UI library. ManagedCommon makes more sense.