From 786fb5a6ba3e053439b2347a873683222202139e Mon Sep 17 00:00:00 2001 From: rabbitism Date: Tue, 16 Jul 2024 22:11:04 +0800 Subject: [PATCH] fix: fix host detection. --- src/Ursa/Controls/TitleBar/CaptionButtons.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Ursa/Controls/TitleBar/CaptionButtons.cs b/src/Ursa/Controls/TitleBar/CaptionButtons.cs index 96c9a46..3fd913c 100644 --- a/src/Ursa/Controls/TitleBar/CaptionButtons.cs +++ b/src/Ursa/Controls/TitleBar/CaptionButtons.cs @@ -41,7 +41,7 @@ public class CaptionButtons: Avalonia.Controls.Chrome.CaptionButtons Button.ClickEvent.AddHandler((o, args) => OnMinimize(), _minimizeButton); Button.ClickEvent.AddHandler((o, args) => OnToggleFullScreen(), _fullScreenButton); - Window.WindowStateProperty.Changed.Subscribe(WindowStateChanged); + Window.WindowStateProperty.Changed.AddClassHandler(WindowStateChanged); if (this.HostWindow is not null && !HostWindow.CanResize) { _restoreButton.IsEnabled = false; @@ -49,8 +49,9 @@ public class CaptionButtons: Avalonia.Controls.Chrome.CaptionButtons UpdateVisibility(); } - private void WindowStateChanged(AvaloniaPropertyChangedEventArgs e) + private void WindowStateChanged(Window window, AvaloniaPropertyChangedEventArgs e) { + if (window != HostWindow) return; if (e.NewValue.Value == WindowState.FullScreen) { _oldWindowState = e.OldValue.Value;