mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[Settings]WinAppSDK 1.6 Flyout Fix (#34821)
Fixed titlebar and reverted W10 border hack
This commit is contained in:
committed by
GitHub
parent
5b0f3f64d4
commit
7640258c10
@@ -10,8 +10,9 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
|
|||||||
{
|
{
|
||||||
public static class NativeMethods
|
public static class NativeMethods
|
||||||
{
|
{
|
||||||
private const int GWL_STYLE = -16;
|
|
||||||
private const int WS_POPUP = 1 << 31; // 0x80000000
|
private const int WS_POPUP = 1 << 31; // 0x80000000
|
||||||
|
internal const int GWL_STYLE = -16;
|
||||||
|
internal const int WS_CAPTION = 0x00C00000;
|
||||||
internal const int SPI_GETDESKWALLPAPER = 0x0073;
|
internal const int SPI_GETDESKWALLPAPER = 0x0073;
|
||||||
internal const int SW_SHOWNORMAL = 1;
|
internal const int SW_SHOWNORMAL = 1;
|
||||||
internal const int SW_SHOWMAXIMIZED = 3;
|
internal const int SW_SHOWMAXIMIZED = 3;
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:flyout="using:Microsoft.PowerToys.Settings.UI.Flyout"
|
xmlns:flyout="using:Microsoft.PowerToys.Settings.UI.Flyout"
|
||||||
xmlns:i="using:Microsoft.Xaml.Interactivity"
|
|
||||||
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
|
|
||||||
xmlns:local="using:Microsoft.PowerToys.Settings.UI"
|
xmlns:local="using:Microsoft.PowerToys.Settings.UI"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:winuiex="using:WinUIEx"
|
xmlns:winuiex="using:WinUIEx"
|
||||||
@@ -29,17 +27,6 @@
|
|||||||
LightTintOpacity="0" />
|
LightTintOpacity="0" />
|
||||||
</winuiex:WindowEx.Backdrop>
|
</winuiex:WindowEx.Backdrop>
|
||||||
<Grid>
|
<Grid>
|
||||||
<!-- HACK: https://github.com/microsoft/microsoft-ui-xaml/issues/7629 -->
|
|
||||||
<!-- W11 grey border, W10: no border -->
|
|
||||||
<i:Interaction.Behaviors>
|
|
||||||
<ic:DataTriggerBehavior
|
|
||||||
Binding="{x:Bind ViewModel.Windows10}"
|
|
||||||
ComparisonCondition="Equal"
|
|
||||||
Value="True">
|
|
||||||
<ic:ChangePropertyAction PropertyName="BorderThickness" Value="1" />
|
|
||||||
<ic:ChangePropertyAction PropertyName="BorderBrush" Value="{ThemeResource SurfaceStrokeColorDefaultBrush}" />
|
|
||||||
</ic:DataTriggerBehavior>
|
|
||||||
</i:Interaction.Behaviors>
|
|
||||||
<flyout:ShellPage x:Name="FlyoutShellPage" />
|
<flyout:ShellPage x:Name="FlyoutShellPage" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</winuiex:WindowEx>
|
</winuiex:WindowEx>
|
||||||
|
|||||||
@@ -28,6 +28,13 @@ namespace Microsoft.PowerToys.Settings.UI
|
|||||||
public FlyoutWindow(POINT? initialPosition)
|
public FlyoutWindow(POINT? initialPosition)
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
|
|
||||||
|
// Remove the caption style from the window style. Windows App SDK 1.6 added it, which made the title bar and borders appear for the Flyout. This code removes it.
|
||||||
|
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
|
||||||
|
var windowStyle = NativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_STYLE);
|
||||||
|
windowStyle &= ~NativeMethods.WS_CAPTION;
|
||||||
|
_ = NativeMethods.SetWindowLong(hwnd, NativeMethods.GWL_STYLE, windowStyle);
|
||||||
|
|
||||||
this.Activated += FlyoutWindow_Activated;
|
this.Activated += FlyoutWindow_Activated;
|
||||||
FlyoutAppearPosition = initialPosition;
|
FlyoutAppearPosition = initialPosition;
|
||||||
ViewModel = new FlyoutViewModel();
|
ViewModel = new FlyoutViewModel();
|
||||||
|
|||||||
@@ -3,11 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using Common.UI;
|
|
||||||
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
|
||||||
|
|
||||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
|
namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
|
||||||
{
|
{
|
||||||
@@ -18,21 +14,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
|
|||||||
|
|
||||||
public bool CanHide { get; set; }
|
public bool CanHide { get; set; }
|
||||||
|
|
||||||
private bool _windows10;
|
|
||||||
|
|
||||||
public bool Windows10
|
|
||||||
{
|
|
||||||
get => _windows10;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_windows10 != value)
|
|
||||||
{
|
|
||||||
_windows10 = value;
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FlyoutViewModel()
|
public FlyoutViewModel()
|
||||||
{
|
{
|
||||||
CanHide = true;
|
CanHide = true;
|
||||||
@@ -40,7 +21,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
|
|||||||
_hideTimer.Elapsed += HideTimer_Elapsed;
|
_hideTimer.Elapsed += HideTimer_Elapsed;
|
||||||
_hideTimer.Interval = 1000;
|
_hideTimer.Interval = 1000;
|
||||||
_hideTimer.Enabled = false;
|
_hideTimer.Enabled = false;
|
||||||
_windows10 = !OSVersionHelper.IsWindows11();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HideTimer_Elapsed(object sender, ElapsedEventArgs e)
|
private void HideTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||||
@@ -56,13 +36,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
|
|||||||
_hideTimer.Start();
|
_hideTimer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
|
||||||
|
|
||||||
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
||||||
{
|
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user