[Settings]WinAppSDK 1.6 Flyout Fix (#34821)

Fixed titlebar and reverted W10 border hack
This commit is contained in:
Davide Giacometti 2024-09-12 18:31:06 +02:00 коммит произвёл GitHub
Родитель 5b0f3f64d4
Коммит 7640258c10
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 9 добавлений и 41 удалений

Просмотреть файл

@ -10,8 +10,9 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
{
public static class NativeMethods
{
private const int GWL_STYLE = -16;
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 SW_SHOWNORMAL = 1;
internal const int SW_SHOWMAXIMIZED = 3;

Просмотреть файл

@ -4,8 +4,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:winuiex="using:WinUIEx"
@ -29,17 +27,6 @@
LightTintOpacity="0" />
</winuiex:WindowEx.Backdrop>
<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" />
</Grid>
</winuiex:WindowEx>

Просмотреть файл

@ -28,6 +28,13 @@ namespace Microsoft.PowerToys.Settings.UI
public FlyoutWindow(POINT? initialPosition)
{
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;
FlyoutAppearPosition = initialPosition;
ViewModel = new FlyoutViewModel();

Просмотреть файл

@ -3,11 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Timers;
using Common.UI;
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
{
@ -18,21 +14,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
public bool CanHide { get; set; }
private bool _windows10;
public bool Windows10
{
get => _windows10;
set
{
if (_windows10 != value)
{
_windows10 = value;
OnPropertyChanged();
}
}
}
public FlyoutViewModel()
{
CanHide = true;
@ -40,7 +21,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
_hideTimer.Elapsed += HideTimer_Elapsed;
_hideTimer.Interval = 1000;
_hideTimer.Enabled = false;
_windows10 = !OSVersionHelper.IsWindows11();
}
private void HideTimer_Elapsed(object sender, ElapsedEventArgs e)
@ -56,13 +36,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
_hideTimer.Start();
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public void Dispose()
{
Dispose(true);