/** * get_app_from_window_wmclass: * * Looks only at the given window, and attempts to determine * an application based on WM_CLASS. If one can't be determined, * return %NULL. * * Return value: (transfer full): A newly-referenced #ShellApp, or %NULL */ static ShellApp * get_app_from_window_wmclass (MetaWindow *window) { ShellApp *app; ShellAppSystem *appsys; char *wmclass; char *with_desktop; appsys = shell_app_system_get_default (); wmclass = get_appid_from_window (window); if (!wmclass) return NULL; with_desktop = g_strjoin (NULL, wmclass, ".desktop", NULL); g_free (wmclass); app = shell_app_system_lookup_heuristic_basename (appsys, with_desktop); g_free (with_desktop); if (app == NULL) { const char *id = get_app_id_from_title (window); if (id != NULL) app = shell_app_system_get_app (appsys, id); } return app; }
/** * shell_app_system_lookup_wmclass: * @system: a #ShellAppSystem * @wmclass: A WM_CLASS value * * Find a valid application corresponding to a WM_CLASS value. * * Returns: (transfer none): A #ShellApp for @wmclass */ ShellApp * shell_app_system_lookup_wmclass (ShellAppSystem *system, const char *wmclass) { char *canonicalized; char *desktop_file; ShellApp *app; if (wmclass == NULL) return NULL; canonicalized = g_ascii_strdown (wmclass, -1); /* This handles "Fedora Eclipse", probably others. * Note g_strdelimit is modify-in-place. */ g_strdelimit (canonicalized, " ", '-'); desktop_file = g_strconcat (canonicalized, ".desktop", NULL); app = shell_app_system_lookup_heuristic_basename (system, desktop_file); g_free (canonicalized); g_free (desktop_file); return app; }
/** * shell_app_system_lookup_desktop_wmclass: * @system: a #ShellAppSystem * @wmclass: (nullable): A WM_CLASS value * * Find a valid application whose .desktop file, without the extension * and properly canonicalized, matches @wmclass. * * Returns: (transfer none): A #ShellApp for @wmclass */ ShellApp * shell_app_system_lookup_desktop_wmclass (ShellAppSystem *system, const char *wmclass) { char *canonicalized; char *desktop_file; ShellApp *app; if (wmclass == NULL) return NULL; /* First try without changing the case (this handles org.example.Foo.Bar.desktop applications) Note that is slightly wrong in that Gtk+ would set the WM_CLASS to Org.example.Foo.Bar, but it also sets the instance part to org.example.Foo.Bar, so we're ok */ desktop_file = g_strconcat (wmclass, ".desktop", NULL); app = shell_app_system_lookup_heuristic_basename (system, desktop_file); g_free (desktop_file); if (app) return app; canonicalized = g_ascii_strdown (wmclass, -1); /* This handles "Fedora Eclipse", probably others. * Note g_strdelimit is modify-in-place. */ g_strdelimit (canonicalized, " ", '-'); desktop_file = g_strconcat (canonicalized, ".desktop", NULL); app = shell_app_system_lookup_heuristic_basename (system, desktop_file); g_free (canonicalized); g_free (desktop_file); return app; }