From 95555ef1d537d38e7bb4bdec4602bdc53513e20e Mon Sep 17 00:00:00 2001 From: MartyIX <203266+MartyIX@users.noreply.github.com> Date: Thu, 21 Mar 2024 14:16:17 +0100 Subject: [PATCH 1/3] fix? --- src/Controls/src/Core/Window/Window.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controls/src/Core/Window/Window.cs b/src/Controls/src/Core/Window/Window.cs index be74cc503588..dd82c2ee1c05 100644 --- a/src/Controls/src/Core/Window/Window.cs +++ b/src/Controls/src/Core/Window/Window.cs @@ -221,11 +221,11 @@ void IWindow.FrameChanged(Rect frame) SetValueCore(WidthProperty, frame.Width, SetValueFlags.None, SetValuePrivateFlags.Silent, SetterSpecificity.FromHandler); SetValueCore(HeightProperty, frame.Height, SetValueFlags.None, SetValuePrivateFlags.Silent, SetterSpecificity.FromHandler); - _batchFrameUpdate--; + int previousValue = _batchFrameUpdate--; if (_batchFrameUpdate < 0) _batchFrameUpdate = 0; - if (_batchFrameUpdate == 0) + if (previousValue == 1) { SetPropertyChanged(XProperty, nameof(X), x, frame.X); SetPropertyChanged(YProperty, nameof(Y), y, frame.Y); From 1362fb6587d68acdf5ad56f515467a73a3aec2b7 Mon Sep 17 00:00:00 2001 From: MartyIX <203266+MartyIX@users.noreply.github.com> Date: Thu, 21 Mar 2024 14:56:45 +0100 Subject: [PATCH 2/3] Another approach --- src/Controls/src/Core/Window/Window.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Controls/src/Core/Window/Window.cs b/src/Controls/src/Core/Window/Window.cs index dd82c2ee1c05..f40b4b88e20d 100644 --- a/src/Controls/src/Core/Window/Window.cs +++ b/src/Controls/src/Core/Window/Window.cs @@ -198,6 +198,8 @@ double GetSizeCoordinate(BindableProperty property) return ValidatePositive(coord); } + bool _frameUpdateInProgress = false; + int _batchFrameUpdate = 0; void IWindow.FrameChanged(Rect frame) @@ -206,9 +208,23 @@ void IWindow.FrameChanged(Rect frame) var y = Y; var width = Width; var height = Height; + +#if MACCATALYST + // MacCatalyst does not support setting window properties: X, Y, width, and height. + if (_frameUpdateInProgress) { + X = frame.X; + Y = frame.Y; + Width = frame.Width; + Height = frame.Height; + + return; + } +#endif + if (new Rect(x, y, width, height) == frame) return; + _frameUpdateInProgress = true; _batchFrameUpdate++; SetPropertyChanging(XProperty, nameof(X), x, frame.X); @@ -221,11 +237,11 @@ void IWindow.FrameChanged(Rect frame) SetValueCore(WidthProperty, frame.Width, SetValueFlags.None, SetValuePrivateFlags.Silent, SetterSpecificity.FromHandler); SetValueCore(HeightProperty, frame.Height, SetValueFlags.None, SetValuePrivateFlags.Silent, SetterSpecificity.FromHandler); - int previousValue = _batchFrameUpdate--; + _batchFrameUpdate--; if (_batchFrameUpdate < 0) _batchFrameUpdate = 0; - if (previousValue == 1) + if (_batchFrameUpdate == 0) { SetPropertyChanged(XProperty, nameof(X), x, frame.X); SetPropertyChanged(YProperty, nameof(Y), y, frame.Y); @@ -235,6 +251,8 @@ void IWindow.FrameChanged(Rect frame) SizeChanged?.Invoke(this, EventArgs.Empty); } + _frameUpdateInProgress = false; + [MethodImpl(MethodImplOptions.AggressiveInlining)] void SetPropertyChanging(BindableProperty property, string name, double oldValue, double newValue) { From 1ebaaa08e7eff24cb2d7e1fe5abf2cc12ba1dbd3 Mon Sep 17 00:00:00 2001 From: MartyIX <203266+MartyIX@users.noreply.github.com> Date: Thu, 28 Mar 2024 10:22:22 +0100 Subject: [PATCH 3/3] Fix warnings in CI --- src/Controls/src/Core/Window/Window.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Controls/src/Core/Window/Window.cs b/src/Controls/src/Core/Window/Window.cs index f40b4b88e20d..541dca3733c7 100644 --- a/src/Controls/src/Core/Window/Window.cs +++ b/src/Controls/src/Core/Window/Window.cs @@ -198,7 +198,9 @@ double GetSizeCoordinate(BindableProperty property) return ValidatePositive(coord); } +#if MACCATALYST bool _frameUpdateInProgress = false; +#endif int _batchFrameUpdate = 0; @@ -224,7 +226,10 @@ void IWindow.FrameChanged(Rect frame) if (new Rect(x, y, width, height) == frame) return; +#if MACCATALYST _frameUpdateInProgress = true; +#endif + _batchFrameUpdate++; SetPropertyChanging(XProperty, nameof(X), x, frame.X); @@ -251,7 +256,9 @@ void IWindow.FrameChanged(Rect frame) SizeChanged?.Invoke(this, EventArgs.Empty); } +#if MACCATALYST _frameUpdateInProgress = false; +#endif [MethodImpl(MethodImplOptions.AggressiveInlining)] void SetPropertyChanging(BindableProperty property, string name, double oldValue, double newValue)