AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.17k stars 2.18k forks source link

The modal dialog flashes on macOS when clicking on the parent window #15649

Open baochenw opened 4 months ago

baochenw commented 4 months ago

Describe the bug

The modal dialog flashes on macOS when clicking the parent window.

https://github.com/AvaloniaUI/Avalonia/assets/1419783/55fb6ebe-ea16-4462-aba5-8badde0dfbb2

To Reproduce

  1. Show modal with ShowDialog method.

    var dialog = new Window();
    dialog.ShowDialog(MainWindow);
  2. Click on the main window

Expected behavior

The dialog is modal and no flashes when clicking parent window.

Avalonia version

11.0.9

OS

macOS

Additional context

I've delved deeper into the issue, and it appears that on macOS, Apple's API isn't used to implement the modal dialog. Instead, a trick is used to reactivate the dialog. https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/Window.cs#L905-L926

Is it possible to use system API to show modal dialog?

rabbitism commented 4 months ago

Is this specific to Ursa or all cases?

baochenw commented 4 months ago

It is also reproducible with Avalonia sample app.

https://github.com/AvaloniaUI/Avalonia/assets/1419783/571b7ef3-0f74-4d4f-9006-13167865b3b1