Skip to content

Add initial support for Multiple Windows on MacOS #2260

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6401190
Add initial support for Multiple Windows on MacOS
ne0rrmatrix Oct 5, 2024
e35a411
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Oct 15, 2024
25612f3
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Oct 15, 2024
85c4b2d
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Oct 16, 2024
69134a0
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Oct 20, 2024
1c3a03b
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Oct 31, 2024
861a8ea
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Nov 5, 2024
04a03c0
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Nov 7, 2024
e22d3b8
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Nov 11, 2024
dc85c90
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Nov 11, 2024
9dc8ff2
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Dec 2, 2024
19d39a3
Fix merge conflicts
ne0rrmatrix Dec 18, 2024
8b2b05c
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Dec 19, 2024
a32b73e
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Dec 20, 2024
a3f64ec
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Dec 28, 2024
393d6ee
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Jan 3, 2025
bb5a5d6
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Jan 14, 2025
54cc445
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Jan 20, 2025
88100ce
Merge branch 'main' into AddSupportMacOSMultiWindow
ne0rrmatrix Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion samples/CommunityToolkit.Maui.Sample/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,26 @@ public partial class App : Application
public App(AppShell appShell)
{
InitializeComponent();

this.appShell = appShell;
}

#if MACCATALYST
protected override Window CreateWindow(IActivationState? activationState)
{
Window window = base.CreateWindow(activationState);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, e.g., on Windows the call is new Window(appShell) and on Mac Catalyst it is base.CreateWindow(activationState).

Is this by design that appShell is not passed in? Again honest question.

window.Destroying += (object? sender, EventArgs args) =>
{
if (Current?.Windows?.Count - 1 == 0)
{
// Exit the app when the last window closes
// This ensures app closes when last window closes on Mac
Environment.Exit(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a correct thing to do though? I honestly don't know hence the question.

I ask primarily because of this https://superuser.com/questions/53935/getting-mac-os-x-applications-to-close-after-last-window-closed/53940#53940 answer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^ @ne0rrmatrix friendly ping

}
};
return window;
}

#else
protected override Window CreateWindow(IActivationState? activationState) => new(appShell);
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>__MAUI_DEFAULT_SCENE_CONFIGURATION__</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
<key>NSSpeechRecognitionUsageDescription</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using Foundation;
using Microsoft.Maui;
using ObjCRuntime;
using UIKit;

namespace CommunityToolkit.Maui.Sample.Platforms.MacCatalyst;

[Register("SceneDelegate")]
public class SceneDelegate : MauiUISceneDelegate
{
}
Loading