mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-01 21:33:09 +02:00
GWin32AppInfo: Prefer file activation over URI activation for file URI's
(...unless file:// URI's are actually supported by the target app) References: [1] - https://learn.microsoft.com/en-us/windows/uwp/launch-resume/handle-uri-activation [2] - https://learn.microsoft.com/en-us/windows/uwp/launch-resume/handle-file-activation
This commit is contained in:
parent
02417db370
commit
86fccfcb70
@ -5005,11 +5005,23 @@ g_win32_app_info_launch_uwp_single (IApplicationActivationManager *app_activati
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
g_win32_app_info_supports_files (GAppInfo *appinfo);
|
||||||
|
|
||||||
static IShellItemArray *
|
static IShellItemArray *
|
||||||
make_item_array (gboolean for_files,
|
make_item_array (gboolean for_files,
|
||||||
GList *objs,
|
GList *objs,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
static inline GList
|
||||||
|
make_single_entry_list (gpointer data)
|
||||||
|
{
|
||||||
|
GList l = { NULL, NULL, NULL };
|
||||||
|
l.data = data;
|
||||||
|
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
g_win32_app_info_launch_uwp_internal (GWin32AppInfo *info,
|
g_win32_app_info_launch_uwp_internal (GWin32AppInfo *info,
|
||||||
gboolean for_files,
|
gboolean for_files,
|
||||||
@ -5084,19 +5096,39 @@ g_win32_app_info_launch_uwp_internal (GWin32AppInfo *info,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
gboolean supports_files;
|
||||||
|
gboolean supports_file_uris;
|
||||||
gboolean outcome = TRUE;
|
gboolean outcome = TRUE;
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
|
supports_files = g_win32_app_info_supports_files (G_APP_INFO (info));
|
||||||
|
supports_file_uris = info->app &&
|
||||||
|
info->app->supported_urls &&
|
||||||
|
g_hash_table_lookup (info->app->supported_urls, "file");
|
||||||
|
|
||||||
for (l = objs; l != NULL; l = l->next)
|
for (l = objs; l != NULL; l = l->next)
|
||||||
{
|
{
|
||||||
IShellItemArray *item;
|
file_or_uri *obj = (file_or_uri*) l->data;
|
||||||
GList single;
|
GList single = make_single_entry_list (obj);
|
||||||
|
IShellItemArray *item = NULL;
|
||||||
|
UwpActivationType type;
|
||||||
|
|
||||||
single.data = l->data;
|
/* Most UWP applications support opening files but do not support
|
||||||
single.prev = NULL;
|
* the file:// protocol in URI's. That's because the UWP platform
|
||||||
single.next = NULL;
|
* has a specific activation for files (see FileActivatedEventArgs)
|
||||||
|
* which is different from protocol activation. Here we check for
|
||||||
|
* that. */
|
||||||
|
|
||||||
item = make_item_array (FALSE, &single, error);
|
if (!supports_file_uris && supports_files && obj->file)
|
||||||
|
{
|
||||||
|
type = UWP_ACTIVATION_TYPE_FILE;
|
||||||
|
item = make_item_array (TRUE, &single, error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type = UWP_ACTIVATION_TYPE_PROTOCOL;
|
||||||
|
item = make_item_array (FALSE, &single, error);
|
||||||
|
}
|
||||||
|
|
||||||
if (!item)
|
if (!item)
|
||||||
{
|
{
|
||||||
@ -5104,7 +5136,7 @@ g_win32_app_info_launch_uwp_internal (GWin32AppInfo *info,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_win32_app_info_launch_uwp_single (paam, UWP_ACTIVATION_TYPE_PROTOCOL,
|
if (!g_win32_app_info_launch_uwp_single (paam, type,
|
||||||
item, shverb->verb_name, info,
|
item, shverb->verb_name, info,
|
||||||
launch_context, from_task, error))
|
launch_context, from_task, error))
|
||||||
outcome = FALSE;
|
outcome = FALSE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user