Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mac Catalyst] DeviceDisplay.MainDisplayInfoChanged event not getting raised #22634

Open
mikeparker104 opened this issue May 24, 2024 · 1 comment
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with partner Issue or Request from a partner team platform/macOS 🍏 macOS / Mac Catalyst t/bug Something isn't working
Milestone

Comments

@mikeparker104
Copy link
Contributor

Description

The DeviceDisplay.MainDisplayInfoChanged event is not getting raised when the main display information changes on macOS. For example, when changing display options (in Settings > Displays) like resolution, scaling, rotation, etc., or when switching the display that is designated as the Main display.

By way of comparison, the same event does get raised when changes are made on Windows. In multi-display setups, the event will also get raised on Windows when moving an application Window from one display to another.

Overarching expectation is that the behavior is consistent between Windows and Mac Catalyst where platform SDKs support detection of changes to those display screen metrics represented in the DisplayInfo

Steps to Reproduce

Subscribe the DeviceDisplay.MainDisplayInfoChanged event in the MainPage.xaml.cs class of a file -> new .NET MAUI app outputting the serialized DeviceInfo provided by the DisplayInfoChangedEventArgs.

readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
{
    WriteIndented = true,
    PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};

public MainPage()
{
    InitializeComponent();
    DeviceDisplay.Current.MainDisplayInfoChanged += OnMainDisplayInfoChanged;
}

void OnMainDisplayInfoChanged(object sender, DisplayInfoChangedEventArgs e)
{
    var updateTextBuilder = new StringBuilder();

    updateTextBuilder.AppendLine($"Raised {nameof(OnMainDisplayInfoChanged)} : {DateTimeOffset.Now.ToLocalTime()}");
    updateTextBuilder.AppendLine($"");
    updateTextBuilder.Append(JsonSerializer.Serialize(e.DisplayInfo, _serializerOptions));

    System.Diagnostics.Debug.WriteLine(updateTextBuilder.ToString());
}

Using screen resolution as the example of a change to display information expected to raise the event.

  1. Run the .NET MAUI app on macOS
  2. Open the Settings app and change the screen resolution for the designated Main display

EXPECTED

The DeviceDisplay.MainDisplayInfoChanged event gets raised

ACTUAL

The event does not get raised

Link to public reproduction project repository

No response

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

Mac Catalyst 13.1

Did you find any workaround?

No response

Relevant log output

No response

@mikeparker104 mikeparker104 added t/bug Something isn't working platform/macOS 🍏 macOS / Mac Catalyst area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with labels May 24, 2024
@dotnet-policy-service dotnet-policy-service bot added the partner Issue or Request from a partner team label May 24, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with partner Issue or Request from a partner team platform/macOS 🍏 macOS / Mac Catalyst t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants