Open Bug 1794159 Opened 2 years ago Updated 27 days ago

support pinning to taskbar in msix builds

Categories

(Firefox :: Shell Integration, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: bhearsum, Assigned: mhughes)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fidedi-ope])

Attachments

(1 file)

(Essentially a clone of https://bugzilla.mozilla.org/show_bug.cgi?id=1712628, because we already landed a patch there, which will mess up bug flags if we land additional ones.)

nsWindowsShellService.isCurrentAppPinnedToTaskbarAsync() currently relies on matching paths in the shortcut. This does not work for a packaged app. The UWP API TaskbarManager.IsCurrentAppPinnedAsync is the way to handle this for a packaged app.

I have a rough WIP, from trying to get RequestPinCurrentAppAsync working. It would need to be in addition to the existing implementation since this is only available from within a package.

This would only really be of use for telemetry. Aside: os.environment.launch_method is always Other when launching a package, whether it was opened from a taskbar pin, start menu shortcut, or desktop shortcut; there must be some amount of indirection so that we don't know the shortcut that opened us.

I've been digging into this a bit. It's not too difficult to call the TaskbarManager methods -- but per this tutorial on pinning - RequestPinCurrentAppAsync must be called from a "foreground UI thread" because it prompts the user to confirm the request. It's not clear to me how to do this, or even if we can -- all examples I've found use cppwinrt methods with co_await (eg: https://learn.microsoft.com/en-us/archive/msdn-magazine/2018/june/c-effective-async-with-coroutines-and-c-winrt) -- which we're unable to do.

Even calling it from our own "main thread" causes it the async operation to never complete, and never show the UI.

(In reply to bhearsum@mozilla.com (:bhearsum) from comment #1)

I've been digging into this a bit. It's not too difficult to call the TaskbarManager methods -- but per this tutorial on pinning - RequestPinCurrentAppAsync must be called from a "foreground UI thread" because it prompts the user to confirm the request. It's not clear to me how to do this, or even if we can -- all examples I've found use cppwinrt methods with co_await (eg: https://learn.microsoft.com/en-us/archive/msdn-magazine/2018/june/c-effective-async-with-coroutines-and-c-winrt) -- which we're unable to do.

Even calling it from our own "main thread" causes it the async operation to never complete, and never show the UI.

Correction: it does complete, but with AsyncStatus::Error. There doesn't appear to be any way to get more detailed information, but my best guess is that it's throwing an error because it was unable to throw up the consent dialog for whatever reason.

Severity: -- → S3
Priority: -- → P3

After a bit of research I'm circling around an understanding that this is a UWP API that is not accessible from Win32 - albeit I think there is an escape hatch in XAML Islands. I'm not versed in XAML Islands and a cursory investigation suggests this is another half built bridge between Win32 and UWP that works for some APIs and not others, but this is likely the most fruitful direction for further investigation.

FYI: Microsoft seems to consider adding a new public API to pin apps to the taskbar.
https://blogs.windows.com/windowsexperience/2023/03/17/a-principled-approach-to-app-pinning-and-app-defaults-in-windows/
But I could not find any documentation yet.

:emk, thanks for the link. At this time the API discussed doesn't yet exist, afaik not even in the Insider channel. If you notice a change definitely bring it to our attention.

Follow up on XAML Islands, after testing it seems to be another dead end.

Duplicate of this bug: 1854516
Assignee: nobody → mhughes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: