texture-cache: Load bound surfaces into StWidgets
Using widgets instead of plain actors will allow us to set the size from CSS. https://gitlab.gnome.org/GNOME/gnome-shell/issues/1027
This commit is contained in:
parent
ef7a93bb07
commit
6f794738e8
@ -184,7 +184,7 @@ window_backed_app_get_icon (ShellApp *app,
|
|||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
MetaWindow *window = NULL;
|
MetaWindow *window = NULL;
|
||||||
ClutterActor *actor;
|
StWidget *widget;
|
||||||
gint scale;
|
gint scale;
|
||||||
ShellGlobal *global;
|
ShellGlobal *global;
|
||||||
StThemeContext *context;
|
StThemeContext *context;
|
||||||
@ -204,16 +204,18 @@ window_backed_app_get_icon (ShellApp *app,
|
|||||||
|
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
{
|
{
|
||||||
|
ClutterActor *actor;
|
||||||
|
|
||||||
actor = clutter_actor_new ();
|
actor = clutter_actor_new ();
|
||||||
g_object_set (actor, "opacity", 0, "width", (float) size, "height", (float) size, NULL);
|
g_object_set (actor, "opacity", 0, "width", (float) size, "height", (float) size, NULL);
|
||||||
return actor;
|
return actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
actor = st_texture_cache_bind_cairo_surface_property (st_texture_cache_get_default (),
|
widget = st_texture_cache_bind_cairo_surface_property (st_texture_cache_get_default (),
|
||||||
G_OBJECT (window),
|
G_OBJECT (window),
|
||||||
"icon",
|
"icon",
|
||||||
size);
|
size);
|
||||||
return actor;
|
return CLUTTER_ACTOR (widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -767,27 +767,30 @@ st_texture_cache_free_bind (gpointer data)
|
|||||||
* If the source object is destroyed, the texture will continue to show the last
|
* If the source object is destroyed, the texture will continue to show the last
|
||||||
* value of the property.
|
* value of the property.
|
||||||
*
|
*
|
||||||
* Return value: (transfer none): A new #ClutterActor
|
* Return value: (transfer none): A new #StWidget
|
||||||
*/
|
*/
|
||||||
ClutterActor *
|
StWidget *
|
||||||
st_texture_cache_bind_cairo_surface_property (StTextureCache *cache,
|
st_texture_cache_bind_cairo_surface_property (StTextureCache *cache,
|
||||||
GObject *object,
|
GObject *object,
|
||||||
const char *property_name,
|
const char *property_name,
|
||||||
gint size)
|
gint size)
|
||||||
{
|
{
|
||||||
ClutterActor *actor;
|
StWidget *widget;
|
||||||
gchar *notify_key;
|
gchar *notify_key;
|
||||||
StTextureCachePropertyBind *bind;
|
StTextureCachePropertyBind *bind;
|
||||||
|
|
||||||
actor = create_invisible_actor ();
|
widget = g_object_new (ST_TYPE_WIDGET,
|
||||||
clutter_actor_set_size (actor, size, size);
|
"opacity", 0,
|
||||||
|
"width", (float)size,
|
||||||
|
"height", (float)size,
|
||||||
|
NULL);
|
||||||
|
|
||||||
bind = g_slice_new0 (StTextureCachePropertyBind);
|
bind = g_slice_new0 (StTextureCachePropertyBind);
|
||||||
bind->cache = cache;
|
bind->cache = cache;
|
||||||
bind->actor = actor;
|
bind->actor = CLUTTER_ACTOR (widget);
|
||||||
bind->size = size;
|
bind->size = size;
|
||||||
bind->source = object;
|
bind->source = object;
|
||||||
g_object_weak_ref (G_OBJECT (actor), st_texture_cache_bind_weak_notify, bind);
|
g_object_weak_ref (G_OBJECT (widget), st_texture_cache_bind_weak_notify, bind);
|
||||||
bind->weakref_active = TRUE;
|
bind->weakref_active = TRUE;
|
||||||
|
|
||||||
st_texture_cache_reset_texture (bind, property_name);
|
st_texture_cache_reset_texture (bind, property_name);
|
||||||
@ -797,7 +800,7 @@ st_texture_cache_bind_cairo_surface_property (StTextureCache *cache,
|
|||||||
bind, (GClosureNotify)st_texture_cache_free_bind, 0);
|
bind, (GClosureNotify)st_texture_cache_free_bind, 0);
|
||||||
g_free (notify_key);
|
g_free (notify_key);
|
||||||
|
|
||||||
return actor;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <st/st-types.h>
|
#include <st/st-types.h>
|
||||||
#include <st/st-theme-node.h>
|
#include <st/st-theme-node.h>
|
||||||
|
#include <st/st-widget.h>
|
||||||
|
|
||||||
#define ST_TYPE_TEXTURE_CACHE (st_texture_cache_get_type ())
|
#define ST_TYPE_TEXTURE_CACHE (st_texture_cache_get_type ())
|
||||||
G_DECLARE_FINAL_TYPE (StTextureCache, st_texture_cache,
|
G_DECLARE_FINAL_TYPE (StTextureCache, st_texture_cache,
|
||||||
@ -63,7 +64,7 @@ st_texture_cache_load_sliced_image (StTextureCache *cache,
|
|||||||
GFunc load_callback,
|
GFunc load_callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
ClutterActor *st_texture_cache_bind_cairo_surface_property (StTextureCache *cache,
|
StWidget *st_texture_cache_bind_cairo_surface_property (StTextureCache *cache,
|
||||||
GObject *object,
|
GObject *object,
|
||||||
const char *property_name,
|
const char *property_name,
|
||||||
gint size);
|
gint size);
|
||||||
|
Loading…
Reference in New Issue
Block a user