shell-app: finish support for loading with scale

https://bugzilla.gnome.org/show_bug.cgi?id=705410
This commit is contained in:
Cosimo Cecchi 2014-02-15 19:44:55 -08:00
parent e5e764b402
commit 407dc74502

View File

@ -160,6 +160,15 @@ window_backed_app_get_icon (ShellApp *app,
{ {
MetaWindow *window; MetaWindow *window;
ClutterActor *actor; ClutterActor *actor;
gint scale;
ShellGlobal *global;
StThemeContext *context;
global = shell_global_get ();
context = st_theme_context_get_for_stage (shell_global_get_stage (global));
g_object_get (context, "scale-factor", &scale, NULL);
size *= scale;
/* During a state transition from running to not-running for /* During a state transition from running to not-running for
* window-backend apps, it's possible we get a request for the icon. * window-backend apps, it's possible we get a request for the icon.
@ -223,6 +232,7 @@ shell_app_create_icon_texture (ShellApp *app,
typedef struct { typedef struct {
ShellApp *app; ShellApp *app;
int size; int size;
int scale;
ClutterTextDirection direction; ClutterTextDirection direction;
} CreateFadedIconData; } CreateFadedIconData;
@ -236,6 +246,7 @@ shell_app_create_faded_icon_cpu (StTextureCache *cache,
ShellApp *app; ShellApp *app;
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
int size; int size;
int scale;
CoglHandle texture; CoglHandle texture;
gint width, height, rowstride; gint width, height, rowstride;
guint8 n_channels; guint8 n_channels;
@ -251,22 +262,23 @@ shell_app_create_faded_icon_cpu (StTextureCache *cache,
app = data->app; app = data->app;
size = data->size; size = data->size;
scale = data->scale;
info = NULL; info = NULL;
icon = g_app_info_get_icon (G_APP_INFO (app->info)); icon = g_app_info_get_icon (G_APP_INFO (app->info));
if (icon != NULL) if (icon != NULL)
{ {
info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), info = gtk_icon_theme_lookup_by_gicon_for_scale (gtk_icon_theme_get_default (),
icon, size, icon, size, scale,
GTK_ICON_LOOKUP_FORCE_SIZE); GTK_ICON_LOOKUP_FORCE_SIZE);
} }
if (info == NULL) if (info == NULL)
{ {
icon = g_themed_icon_new ("application-x-executable"); icon = g_themed_icon_new ("application-x-executable");
info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), info = gtk_icon_theme_lookup_by_gicon_for_scale (gtk_icon_theme_get_default (),
icon, size, icon, size, scale,
GTK_ICON_LOOKUP_FORCE_SIZE); GTK_ICON_LOOKUP_FORCE_SIZE);
g_object_unref (icon); g_object_unref (icon);
} }
@ -351,6 +363,9 @@ shell_app_get_faded_icon (ShellApp *app, int size, ClutterTextDirection directio
ClutterActor *result; ClutterActor *result;
char *cache_key; char *cache_key;
CreateFadedIconData data; CreateFadedIconData data;
gint scale;
ShellGlobal *global;
StThemeContext *context;
/* Don't fade for window backed apps for now...easier to reuse the /* Don't fade for window backed apps for now...easier to reuse the
* property tracking bits, and this helps us visually distinguish * property tracking bits, and this helps us visually distinguish
@ -359,14 +374,19 @@ shell_app_get_faded_icon (ShellApp *app, int size, ClutterTextDirection directio
if (!app->info) if (!app->info)
return window_backed_app_get_icon (app, size); return window_backed_app_get_icon (app, size);
global = shell_global_get ();
context = st_theme_context_get_for_stage (shell_global_get_stage (global));
g_object_get (context, "scale-factor", &scale, NULL);
/* Use icon: prefix so that we get evicted from the cache on /* Use icon: prefix so that we get evicted from the cache on
* icon theme changes. */ * icon theme changes. */
cache_key = g_strdup_printf ("icon:%s,size=%d,faded-%s", cache_key = g_strdup_printf ("icon:%s,size=%d,scale=%d,faded-%s",
shell_app_get_id (app), shell_app_get_id (app),
size, size, scale,
direction == CLUTTER_TEXT_DIRECTION_RTL ? "rtl" : "ltr"); direction == CLUTTER_TEXT_DIRECTION_RTL ? "rtl" : "ltr");
data.app = app; data.app = app;
data.size = size; data.size = size;
data.scale = scale;
data.direction = direction; data.direction = direction;
texture = st_texture_cache_load (st_texture_cache_get_default (), texture = st_texture_cache_load (st_texture_cache_get_default (),
cache_key, cache_key,
@ -384,7 +404,7 @@ shell_app_get_faded_icon (ShellApp *app, int size, ClutterTextDirection directio
else else
{ {
result = clutter_texture_new (); result = clutter_texture_new ();
g_object_set (result, "opacity", 0, "width", (float) size, "height", (float) size, NULL); g_object_set (result, "opacity", 0, "width", (float) size * scale, "height", (float) size * scale, NULL);
} }
return result; return result;