mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
window: Expose Flatpak application ID
GNOME Shell's window matching currently fails frequently with Flatpak applications, as one of the primary hints used to link windows with .desktop files - the WM_CLASS - no longer matches when flatpak renames the exported .desktop file. Luckily, Flatpak provides us with a fail-safe way to map from the PID to the corresponding application ID, so expose an appropriate method that allows GNOME Shell to reliably match windows to the corresponding Flatpak app. https://bugzilla.gnome.org/show_bug.cgi?id=772614
This commit is contained in:
parent
e9944350d3
commit
bccff5bdd8
@ -164,6 +164,7 @@ struct _MetaWindow
|
||||
|
||||
char *startup_id;
|
||||
char *mutter_hints;
|
||||
char *flatpak_id;
|
||||
char *gtk_theme_variant;
|
||||
char *gtk_application_id;
|
||||
char *gtk_unique_bus_name;
|
||||
|
@ -293,6 +293,7 @@ meta_window_finalize (GObject *object)
|
||||
g_free (window->res_name);
|
||||
g_free (window->title);
|
||||
g_free (window->desc);
|
||||
g_free (window->flatpak_id);
|
||||
g_free (window->gtk_theme_variant);
|
||||
g_free (window->gtk_application_id);
|
||||
g_free (window->gtk_unique_bus_name);
|
||||
@ -764,6 +765,27 @@ sync_client_window_mapped (MetaWindow *window)
|
||||
meta_error_trap_pop (window->display);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_window_update_flatpak_id (MetaWindow *window)
|
||||
{
|
||||
uint32_t pid = meta_window_get_client_pid (window);
|
||||
g_autoptr(GKeyFile) key_file = NULL;
|
||||
g_autofree char *info_filename = NULL;
|
||||
|
||||
g_clear_pointer (&window->flatpak_id, g_free);
|
||||
|
||||
if (pid == 0)
|
||||
return;
|
||||
|
||||
key_file = g_key_file_new ();
|
||||
info_filename = g_strdup_printf ("/proc/%u/root/.flatpak-info", pid);
|
||||
|
||||
if (!g_key_file_load_from_file (key_file, info_filename, G_KEY_FILE_NONE, NULL))
|
||||
return;
|
||||
|
||||
window->flatpak_id = g_key_file_get_string (key_file, "Application", "name", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_window_update_desc (MetaWindow *window)
|
||||
{
|
||||
@ -863,6 +885,7 @@ _meta_window_shared_new (MetaDisplay *display,
|
||||
|
||||
window->screen = screen;
|
||||
|
||||
meta_window_update_flatpak_id (window);
|
||||
meta_window_update_desc (window);
|
||||
|
||||
window->override_redirect = attrs->override_redirect;
|
||||
@ -6897,6 +6920,18 @@ meta_window_get_wm_class_instance (MetaWindow *window)
|
||||
return window->res_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_window_get_flatpak_id:
|
||||
* @window: a #MetaWindow
|
||||
*
|
||||
* Return value: (transfer none): the Flatpak application ID or %NULL
|
||||
**/
|
||||
const char *
|
||||
meta_window_get_flatpak_id (MetaWindow *window)
|
||||
{
|
||||
return window->flatpak_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_window_get_gtk_theme_variant:
|
||||
* @window: a #MetaWindow
|
||||
|
@ -138,6 +138,7 @@ const char * meta_window_get_wm_class (MetaWindow *window);
|
||||
const char * meta_window_get_wm_class_instance (MetaWindow *window);
|
||||
gboolean meta_window_showing_on_its_workspace (MetaWindow *window);
|
||||
|
||||
const char * meta_window_get_flatpak_id (MetaWindow *window);
|
||||
const char * meta_window_get_gtk_theme_variant (MetaWindow *window);
|
||||
const char * meta_window_get_gtk_application_id (MetaWindow *window);
|
||||
const char * meta_window_get_gtk_unique_bus_name (MetaWindow *window);
|
||||
|
Loading…
Reference in New Issue
Block a user