Skip to content

Commit

Permalink
fix: Avoid assigning secondary window in Uno Islands Main window ID
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Aug 17, 2024
1 parent 651e39e commit 1c62c54
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Uno.UI.XamlHost.Skia.Wpf/UnoXamlHostBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Uno.UI.Xaml.Controls;
using Microsoft.UI.Content;
using Uno.UI.Xaml.Core;
using Microsoft.UI.Windowing;

namespace Uno.UI.XamlHost.Skia.Wpf
{
Expand Down Expand Up @@ -76,6 +77,8 @@ static UnoXamlHostBase()
application = (WUX.Application)Activator.CreateInstance(type);
});

AppWindow.SkipMainWindowId();

return (WUX.Markup.IXamlMetadataProvider)application;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/Window/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ partial class Window

internal Window(WindowType windowType)
{
if (_current is null)
if (_current is null && CoreApplication.IsFullFledgedApp)
{
windowType = WindowType.CoreWindow;
}
Expand Down
13 changes: 13 additions & 0 deletions src/Uno.UWP/Microsoft/UI/Windowing/AppWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Windows.Graphics;
using Windows.UI.ViewManagement;
using MUXWindowId = Microsoft.UI.WindowId;
using Windows.ApplicationModel.Core;


#if HAS_UNO_WINUI
using Microsoft.UI.Dispatching;
Expand Down Expand Up @@ -103,6 +105,17 @@ public string Title
}
}

internal static void SkipMainWindowId()
{
// In case of Uno Islands we currently have no "main window",
// so we must avoid assigning the first created secondary window
// Id = 1, otherwise it would be considered as the main window.
if (!CoreApplication.IsFullFledgedApp && _windowIdIterator == 0)
{
_windowIdIterator++;
}
}

internal void SetNativeWindow(INativeAppWindow nativeAppWindow)
{
if (nativeAppWindow is null)
Expand Down

0 comments on commit 1c62c54

Please sign in to comment.