get_app_for_window_direct search ShellApp by window, before create.

https://bugzilla.gnome.org/show_bug.cgi?id=610324
This commit is contained in:
Maxim Ermilov
2010-02-21 03:16:30 +03:00
parent 1b7c3580e6
commit c793d7d0a4
3 changed files with 30 additions and 5 deletions

View File

@ -484,6 +484,32 @@ shell_app_system_get_app (ShellAppSystem *self,
return app;
}
/**
* shell_app_system_get_app_for_window:
* @self: A #ShellAppSystem
* @window: A #MetaWindow
*
* Find or create a #ShellApp for window
*
* Return value: (transfer full): The #ShellApp for window, or %NULL if none
*/
ShellApp *
shell_app_system_get_app_for_window (ShellAppSystem *self,
MetaWindow *window)
{
char *id = g_strdup_printf ("window:%p", window);
ShellApp *app = g_hash_table_lookup (self->priv->app_id_to_app, id);
if (app)
g_object_ref (G_OBJECT (app));
else
app = _shell_app_new_for_window (window);
g_free (id);
return app;
}
/* ShellAppSystem ensures we have a unique instance of
* apps per id.
*/