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

feat(macOS): override ms-appx location when app is bundled #18984

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions src/Uno.UI.Runtime.Skia.MacOS/MacOSWindowNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public MacOSWindowNative(WinUIWindow winUIWindow, Microsoft.UI.Xaml.XamlRoot xam

NativeWindowReady?.Invoke(this, this);

if (NativeUno.uno_application_is_bundled())
{
Windows.Storage.StorageFile.ResourcePathBase = IOPath.Combine(Windows.ApplicationModel.Package.Current.InstalledPath, "..", "Resources");
}
UpdateWindowPropertiesFromPackage();
UpdateWindowPropertiesFromApplicationView();
}
Expand Down
4 changes: 4 additions & 0 deletions src/Uno.UI.Runtime.Skia.MacOS/NativeUno.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ internal static partial class NativeUno
[return: MarshalAs(UnmanagedType.I1)]
internal static partial bool uno_application_query_url_support(string url);

[LibraryImport("libUnoNativeMac.dylib")]
[return: MarshalAs(UnmanagedType.I1)]
internal static partial bool uno_application_is_bundled();

[LibraryImport("libUnoNativeMac.dylib")]
internal static unsafe partial void uno_set_drawing_callbacks(
delegate* unmanaged[Cdecl]<nint, double, double, nint, void> metalCallback,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void uno_application_set_badge(const char *badge);
void uno_application_set_icon(const char *path);
bool uno_application_open_url(const char *url);
bool uno_application_query_url_support(const char *url);
bool uno_application_is_bundled(void);

typedef bool (*application_can_exit_fn_ptr)(void);
application_can_exit_fn_ptr uno_get_application_can_exit_callback(void);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ void uno_set_application_can_exit_callback(application_can_exit_fn_ptr p)
application_can_exit = p;
}

bool uno_application_is_bundled(void)
{
return NSRunningApplication.currentApplication.bundleIdentifier != nil;
}

void uno_application_quit(void)
{
#if DEBUG
Expand Down
4 changes: 3 additions & 1 deletion src/Uno.UWP/Storage/StorageFile.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace Windows.Storage
{
partial class StorageFile
{
internal static string ResourcePathBase { get; set; } = Package.Current.InstalledPath;

private static async Task<StorageFile> GetFileFromApplicationUri(CancellationToken ct, Uri uri)
{
if (uri.Scheme != "ms-appx")
Expand All @@ -22,7 +24,7 @@ private static async Task<StorageFile> GetFileFromApplicationUri(CancellationTok

var path = Uri.UnescapeDataString(uri.PathAndQuery).TrimStart('/');

var resourcePathname = global::System.IO.Path.Combine(Package.Current.InstalledPath, uri.Host, path);
var resourcePathname = global::System.IO.Path.Combine(ResourcePathBase, uri.Host, path);

if (resourcePathname != null)
{
Expand Down
Loading