From f0f84454a8b06bf61d4de56418d80edffa7fc0df Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Sat, 20 Jul 2024 12:33:19 +0100 Subject: [PATCH] Avoid using overlay window when not necessary --- src/Ryujinx/UI/Helpers/ContentDialogHelper.cs | 69 ++++++++++--------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs index 2ff57322e..aa1a28f50 100644 --- a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs +++ b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs @@ -342,49 +342,56 @@ namespace Ryujinx.Ava.UI.Helpers isTopDialog = false; } - parent.Activate(); - - _contentDialogOverlayWindow = new ContentDialogOverlayWindow + if (parent is MainWindow) { - Height = parent.Bounds.Height, - Width = parent.Bounds.Width, - Position = parent.PointToScreen(new Point()), - ShowInTaskbar = false, - }; + parent.Activate(); - parent.PositionChanged += OverlayOnPositionChanged; - - void OverlayOnPositionChanged(object sender, PixelPointEventArgs e) - { - if (_contentDialogOverlayWindow is null) + _contentDialogOverlayWindow = new ContentDialogOverlayWindow { - return; + Height = parent.Bounds.Height, + Width = parent.Bounds.Width, + Position = parent.PointToScreen(new Point()), + ShowInTaskbar = false, + }; + + parent.PositionChanged += OverlayOnPositionChanged; + + void OverlayOnPositionChanged(object sender, PixelPointEventArgs e) + { + if (_contentDialogOverlayWindow is null) + { + return; + } + + _contentDialogOverlayWindow.Position = parent.PointToScreen(new Point()); } - _contentDialogOverlayWindow.Position = parent.PointToScreen(new Point()); - } + _contentDialogOverlayWindow.ContentDialog = contentDialog; - _contentDialogOverlayWindow.ContentDialog = contentDialog; + bool opened = false; - bool opened = false; + _contentDialogOverlayWindow.Opened += OverlayOnActivated; - _contentDialogOverlayWindow.Opened += OverlayOnActivated; - - async void OverlayOnActivated(object sender, EventArgs e) - { - if (opened) + async void OverlayOnActivated(object sender, EventArgs e) { - return; + if (opened) + { + return; + } + + opened = true; + + _contentDialogOverlayWindow.Position = parent.PointToScreen(new Point()); + + result = await ShowDialog(); } - opened = true; - - _contentDialogOverlayWindow.Position = parent.PointToScreen(new Point()); - - result = await ShowDialog(); + result = await _contentDialogOverlayWindow.ShowDialog(parent); + } + else + { + result = await contentDialog.ShowAsync(parent); } - - result = await _contentDialogOverlayWindow.ShowDialog(parent); async Task ShowDialog() {