From 313a292fc4d37c1f1130a571764c59929766648c Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 14 May 2020 13:36:48 -0300 Subject: [PATCH] extend api so that when a parent is set you can state if the current window becomes modal. --- src/Avalonia.Controls/Platform/IWindowImpl.cs | 3 ++- src/Avalonia.Controls/Window.cs | 2 +- src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs | 2 +- src/Avalonia.DesignerSupport/Remote/Stubs.cs | 2 +- src/Avalonia.Native/WindowImpl.cs | 2 +- src/Avalonia.X11/X11Window.cs | 2 +- src/Windows/Avalonia.Win32/WindowImpl.cs | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Controls/Platform/IWindowImpl.cs b/src/Avalonia.Controls/Platform/IWindowImpl.cs index cf31d30332..6bd64ad809 100644 --- a/src/Avalonia.Controls/Platform/IWindowImpl.cs +++ b/src/Avalonia.Controls/Platform/IWindowImpl.cs @@ -29,7 +29,8 @@ namespace Avalonia.Platform /// Sets the parent of the window. /// /// The parent . - void SetParent(IWindowImpl parent); + /// If this window is modal or not. + void SetParent(IWindowImpl parent, bool isModal); /// /// Disables the window for example when a modal dialog is open. diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index 74b12cc2be..b45e8cb4c4 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -539,7 +539,7 @@ namespace Avalonia.Controls using (BeginAutoSizing()) { - PlatformImpl.SetParent(owner.PlatformImpl); + PlatformImpl.SetParent(owner.PlatformImpl, true); Owner = owner; owner.AddChild(this); PlatformImpl?.Show(); diff --git a/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs b/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs index 844489ef97..b7299fc9e4 100644 --- a/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs +++ b/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs @@ -117,7 +117,7 @@ namespace Avalonia.DesignerSupport.Remote { } - public void SetParent(IWindowImpl parent) + public void SetParent(IWindowImpl parent, bool isModal) { } diff --git a/src/Avalonia.DesignerSupport/Remote/Stubs.cs b/src/Avalonia.DesignerSupport/Remote/Stubs.cs index 484cf3bc97..3512320dc0 100644 --- a/src/Avalonia.DesignerSupport/Remote/Stubs.cs +++ b/src/Avalonia.DesignerSupport/Remote/Stubs.cs @@ -130,7 +130,7 @@ namespace Avalonia.DesignerSupport.Remote { } - public void SetParent(IWindowImpl parent) + public void SetParent(IWindowImpl parent, bool isModal) { } diff --git a/src/Avalonia.Native/WindowImpl.cs b/src/Avalonia.Native/WindowImpl.cs index 25cccb6140..bbacff7988 100644 --- a/src/Avalonia.Native/WindowImpl.cs +++ b/src/Avalonia.Native/WindowImpl.cs @@ -114,7 +114,7 @@ namespace Avalonia.Native public Action GotInputWhenDisabled { get; set; } - public void SetParent(IWindowImpl parent) + public void SetParent(IWindowImpl parent, bool isModal) { } diff --git a/src/Avalonia.X11/X11Window.cs b/src/Avalonia.X11/X11Window.cs index 97ba99c3dd..a0da7a282a 100644 --- a/src/Avalonia.X11/X11Window.cs +++ b/src/Avalonia.X11/X11Window.cs @@ -1033,7 +1033,7 @@ namespace Avalonia.X11 ChangeWMAtoms(value, _x11.Atoms._NET_WM_STATE_ABOVE); } - public void SetParent(IWindowImpl parent) + public void SetParent(IWindowImpl parent, bool isModal) { SetTransientParent((X11Window)parent); } diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 192fa2ec0e..8ba3a87b8f 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -351,7 +351,7 @@ namespace Avalonia.Win32 public Action GotInputWhenDisabled { get; set; } - public void SetParent(IWindowImpl parent) + public void SetParent(IWindowImpl parent, bool isModal) { _parent = (WindowImpl)parent; SetOwnerHandle(_parent._hwnd);