MetaShadowFactory: convert to a GObject
https://bugzilla.gnome.org/show_bug.cgi?id=592382
This commit is contained in:
parent
8eb31944a5
commit
d56d267f7d
@ -84,11 +84,20 @@ struct _MetaShadow
|
|||||||
|
|
||||||
struct _MetaShadowFactory
|
struct _MetaShadowFactory
|
||||||
{
|
{
|
||||||
|
GObject parent_instance;
|
||||||
|
|
||||||
/* MetaShadowCacheKey => MetaShadow; the shadows are not referenced
|
/* MetaShadowCacheKey => MetaShadow; the shadows are not referenced
|
||||||
* by the factory, they are simply removed from the table when freed */
|
* by the factory, they are simply removed from the table when freed */
|
||||||
GHashTable *shadows;
|
GHashTable *shadows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _MetaShadowFactoryClass
|
||||||
|
{
|
||||||
|
GObjectClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (MetaShadowFactory, meta_shadow_factory, G_TYPE_OBJECT);
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
meta_shadow_cache_key_hash (gconstpointer val)
|
meta_shadow_cache_key_hash (gconstpointer val)
|
||||||
{
|
{
|
||||||
@ -253,27 +262,22 @@ meta_shadow_get_bounds (MetaShadow *shadow,
|
|||||||
bounds->height = window_height + shadow->outer_border_top + shadow->outer_border_bottom;
|
bounds->height = window_height + shadow->outer_border_top + shadow->outer_border_bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaShadowFactory *
|
static void
|
||||||
meta_shadow_factory_new (void)
|
meta_shadow_factory_init (MetaShadowFactory *factory)
|
||||||
{
|
{
|
||||||
MetaShadowFactory *factory;
|
|
||||||
|
|
||||||
factory = g_slice_new0 (MetaShadowFactory);
|
|
||||||
|
|
||||||
factory->shadows = g_hash_table_new (meta_shadow_cache_key_hash,
|
factory->shadows = g_hash_table_new (meta_shadow_cache_key_hash,
|
||||||
meta_shadow_cache_key_equal);
|
meta_shadow_cache_key_equal);
|
||||||
|
|
||||||
return factory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
meta_shadow_factory_free (MetaShadowFactory *factory)
|
meta_shadow_factory_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
|
MetaShadowFactory *factory = META_SHADOW_FACTORY (object);
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key, value;
|
gpointer key, value;
|
||||||
|
|
||||||
/* Detach from the shadows in the table so we won't try to
|
/* Detach from the shadows in the table so we won't try to
|
||||||
* remove them when they freed. */
|
* remove them when they're freed. */
|
||||||
g_hash_table_iter_init (&iter, factory->shadows);
|
g_hash_table_iter_init (&iter, factory->shadows);
|
||||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||||
{
|
{
|
||||||
@ -283,7 +287,21 @@ meta_shadow_factory_free (MetaShadowFactory *factory)
|
|||||||
|
|
||||||
g_hash_table_destroy (factory->shadows);
|
g_hash_table_destroy (factory->shadows);
|
||||||
|
|
||||||
g_slice_free (MetaShadowFactory, factory);
|
G_OBJECT_CLASS (meta_shadow_factory_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_shadow_factory_class_init (MetaShadowFactoryClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->finalize = meta_shadow_factory_finalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
MetaShadowFactory *
|
||||||
|
meta_shadow_factory_new (void)
|
||||||
|
{
|
||||||
|
return g_object_new (META_TYPE_SHADOW_FACTORY, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaShadowFactory *
|
MetaShadowFactory *
|
||||||
@ -672,6 +690,9 @@ meta_shadow_factory_get_shadow (MetaShadowFactory *factory,
|
|||||||
gboolean cacheable;
|
gboolean cacheable;
|
||||||
int center_width, center_height;
|
int center_width, center_height;
|
||||||
|
|
||||||
|
g_return_val_if_fail (META_IS_SHADOW_FACTORY (factory), NULL);
|
||||||
|
g_return_val_if_fail (shape != NULL, NULL);
|
||||||
|
|
||||||
/* Using a single shadow texture for different window sizes only works
|
/* Using a single shadow texture for different window sizes only works
|
||||||
* when there is a central scaled area that is greater than twice
|
* when there is a central scaled area that is greater than twice
|
||||||
* the spread of the gaussian blur we are applying to get to the
|
* the spread of the gaussian blur we are applying to get to the
|
||||||
|
@ -28,6 +28,13 @@
|
|||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
#include "meta-window-shape.h"
|
#include "meta-window-shape.h"
|
||||||
|
|
||||||
|
#define META_TYPE_SHADOW_FACTORY (meta_shadow_factory_get_type ())
|
||||||
|
#define META_SHADOW_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_SHADOW_FACTORY, MetaShadowFactory))
|
||||||
|
#define META_SHADOW_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_SHADOW_FACTORY, MetaShadowFactoryClass))
|
||||||
|
#define META_IS_SHADOW_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_SHADOW_FACTORY))
|
||||||
|
#define META_IS_SHADOW_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_SHADOW_FACTORY))
|
||||||
|
#define META_SHADOW_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_SHADOW_FACTORY, MetaShadowFactoryClass))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MetaShadow:
|
* MetaShadow:
|
||||||
* #MetaShadow holds a shadow texture along with information about how to
|
* #MetaShadow holds a shadow texture along with information about how to
|
||||||
@ -59,11 +66,13 @@ void meta_shadow_get_bounds (MetaShadow *shadow,
|
|||||||
* share the same MetaShadow.
|
* share the same MetaShadow.
|
||||||
*/
|
*/
|
||||||
typedef struct _MetaShadowFactory MetaShadowFactory;
|
typedef struct _MetaShadowFactory MetaShadowFactory;
|
||||||
|
typedef struct _MetaShadowFactoryClass MetaShadowFactoryClass;
|
||||||
|
|
||||||
MetaShadowFactory *meta_shadow_factory_get_default (void);
|
MetaShadowFactory *meta_shadow_factory_get_default (void);
|
||||||
|
|
||||||
|
GType meta_shadow_factory_get_type (void);
|
||||||
|
|
||||||
MetaShadowFactory *meta_shadow_factory_new (void);
|
MetaShadowFactory *meta_shadow_factory_new (void);
|
||||||
void meta_shadow_factory_free (MetaShadowFactory *factory);
|
|
||||||
MetaShadow * meta_shadow_factory_get_shadow (MetaShadowFactory *factory,
|
MetaShadow * meta_shadow_factory_get_shadow (MetaShadowFactory *factory,
|
||||||
MetaWindowShape *shape,
|
MetaWindowShape *shape,
|
||||||
int width,
|
int width,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user