dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.82k stars 1.66k forks source link

Implement invocation of IWindow.DisplayDensityChanged() on MACCATALYST #19884

Open taublast opened 5 months ago

taublast commented 5 months ago

Description

Microsoft.Maui.IWindow.DisplayDensityChanged() invocation is not implemented for MACCATALYST. So when an MAUI app is dragged from one Mac display to the other the app cannot react to the display density change. This works actually fine in Windows so the lack of the same feature on Mac seemed obvious.

Public API Changes

 appWindow.DisplayDensityChanged += (sender, args) =>
                    {
                        //never gets called on Catalyst when changing display, while on Windows it does.
                    };

Intended Use-Case

Need to change rendering scale when app is dragged from one Mac display to another.

jfversluis commented 5 months ago

With what version have you been testing this? I see this related issue that seems to mention this is fixed: https://github.com/dotnet/maui/issues/5315

ghost commented 5 months ago

Hi @taublast. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost commented 5 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

taublast commented 5 months ago
  1. The event handler is never called when dragging app window across different displays, one has scale 1, another is 2.
  public partial class App : Application
    {
        public App()
        {
            InitializeComponent();

            MainPage = new AppShell();
        }       

        protected override Window CreateWindow(IActivationState activationState)
        {
            var appWindow = base.CreateWindow(activationState);

#if MACCATALYST

            appWindow.DisplayDensityChanged += (s, a) =>
            {
                var stop = "breakpoint never gets hit";
            };

#endif

            return appWindow;
        }
    }
  1. Looking at the dontnetmaui repo code can't see this invocation for catalyst anywhere and it looks like not implemented.

  2. Have created my implementation to workaround this issue, not sure if it's the most effective one but it's working, will share in case it is needed.

Versions:

Visual Studio Community 2022 for Mac Preview
Version 17.6 Preview (17.6 build 1569)
Installation UUID: 5394dd16-540f-47a1-8ba1-8037a702831d

Runtime
.NET 7.0.3 (64-bit)
Architecture: Arm64
Microsoft.macOS.Sdk 13.1.1007; git-rev-head:8afca776a0a96613dfb7200e0917bb57f9ed5583; git-branch:release/7.0.1xx-xcode14.2

Roslyn (Language Service)
4.6.0-3.23180.6+99e956e42697a6dd886d1e12478ea2b27cceacfa

NuGet
Version: 6.4.0.117

.NET SDK (Arm64)
SDK: /usr/local/share/dotnet/sdk/7.0.309/Sdks
SDK Versions:
    7.0.309
    7.0.304
    7.0.302
    7.0.203
    7.0.202
    7.0.200
    7.0.102
    7.0.101
    7.0.100
    6.0.415
    6.0.410
    6.0.408
    6.0.407
    6.0.406
    6.0.405
    6.0.404
    6.0.403
    6.0.402
    6.0.401
    6.0.400
    6.0.400-preview.22330.6
    6.0.302
MSBuild SDKs: /Applications/Visual Studio (Preview).app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET SDK (x64)
SDK Versions:
    7.0.309
    7.0.304
    7.0.302
    7.0.203
    7.0.202
    7.0.200
    7.0.200-preview.22628.1
    7.0.102
    3.1.426
    3.1.425
    3.1.424
    3.1.423
    3.1.422
    3.1.421

.NET Runtime (Arm64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    7.0.12
    7.0.7
    7.0.5
    7.0.4
    7.0.3
    7.0.2
    7.0.1
    6.0.23
    6.0.18
    6.0.16
    6.0.15
    6.0.14
    6.0.13
    6.0.12
    6.0.11
    6.0.10
    6.0.9
    6.0.8
    6.0.7
    6.0.6

.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/x64/dotnet
Runtime Versions:
    7.0.12
    7.0.7
    7.0.5
    7.0.4
    7.0.3
    7.0.2
    3.1.32
    3.1.31
    3.1.30
    3.1.29
    3.1.28
    3.1.27

Xamarin.Profiler
Version: 1.8.0.49
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode: 15.0 22265
Build: 15A240d

Xamarin.Mac
Version: 9.3.0.6 Visual Studio Community
Hash: 97731c92c
Branch: xcode14.3
Build date: 2023-04-11 22:38:35-0400

Xamarin.iOS
Version: 16.4.0.6 Visual Studio Community
Hash: 97731c92c
Branch: xcode14.3
Build date: 2023-04-11 22:38:36-0400

Xamarin Designer
Version: 17.6.3.9
Hash: 2648399ae8
Branch: remotes/origin/d17-6
Build date: 2023-06-07 19:09:46 UTC

Xamarin.Android
Version: 13.2.0.6 (Visual Studio Community)
Commit: xamarin-android/d17-5/a200af1
Android SDK: /Users/nickyboom/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        12.0 (API level 31)
        13.0 (API level 33)

SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 34.0.3
SDK Build Tools Version: 33.0.1

Build Information: 
Mono: 6dd9def
Java.Interop: xamarin/java.interop/d17-5@149d70fe
SQLite: xamarin/sqlite/3.40.1@68c69d8
Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@9f02d77

Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.16.1
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 17.6.0.50
Hash: a715dca
Branch: HEAD
Build date: 2023-06-07 19:09:51 UTC

Android Device Manager
Version: 0.0.0.1309
Hash: 06e3e77
Branch: HEAD
Build date: 2023-06-07 19:09:51 UTC

Build Information
Release ID: 1706001569
Git revision: c51ed514fc64c7e298fdb6e199ffec2133ae500c
Build date: 2023-06-07 19:07:58+00
Build branch: release-17.6
Build lane: release-17.6

Operating System
Mac OS X 14.0.0
Darwin 23.0.0 Darwin Kernel Version 23.0.0
    Fri Sep 15 14:41:34 PDT 2023
    root:xnu-10002.1.13~1/RELEASE_ARM64_T8103 arm64

Enabled user installed extensions
.NET Core Extensions 0.7