GWin32AppInfo: Fixes for UWP (packaged) apps activation
Currently there are two issues with activation of UWP apps:
-
g_app_info_launch_uris
(and related) only launches the first URI when the target application is UWP, others are ignored. -
g_app_info_launch_uris
(and related) does not work when passing file URI's and the target application is UWP. The target app is launched, but no file is opened in the app. As en example, if you have the MS Photos app as the registered handler for PNG images, and you callgtk_show_uri ("file:///C:\\path\\to\\image.png")
, the MS Photos app will be launched but no file will show up.
This MR accounts for the two issues:
-
For launching UWP apps we create an IShellItemArray which wraps all the passed-in
URI
's orGFiles
, then call either ActivateForProtocol() or ActivateForFile(). For the latter (ActivateForFile
) that's entirely fine, however the former,ActivateForProtocol
, wants anIShellItemArray
consisting of only one item. This is documented on MSDN:itemArray: a pointer to an array of a single Shell item. The first item in the array is converted into a Uri object that is passed to the app through Protocol- ActivatedEventArgs. Any items in the array except for the first element are ignored.
Here we fix that by calling
ActivateForProtocol
repeatedly in a loop for each passed URI. -
UWP apps support many URI protocols for opening different "activities". Most also support opening files, however not through the
file:///
protocol. As an exaxmple, the Microsoft Photos app supports the following protocols:- microsoft.windows.photos.picker
- ms-wcrv
- microsoft.windows.photos.crop
- microsoft.windows.photos.videoedit
- ms-wpdrmv
- ms-photos
It also supports opening files, but doesn't support the file:/// protocol. Handle that case by checking if
supports_files ()
isTRUE
and callingActivateForFiles ()
.