MetaWindowGroup: store aside the background actor

This allows to retrieve the background actor from the window group
(which is useful for a plugin), and to replace some of the expensive
GType checks with a pointer comparison. Not all of them because sadly
we allow plugins to put random stuff in the window_group...

https://bugzilla.gnome.org/show_bug.cgi?id=688210
This commit is contained in:
Giovanni Campagna 2012-12-17 19:17:46 +01:00
parent 0a1ee4aa54
commit f278fd92d5
3 changed files with 77 additions and 7 deletions

View File

@ -576,9 +576,8 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
info->background_actor = meta_background_actor_new (screen, NULL); info->background_actor = meta_background_actor_new (screen, NULL);
info->overlay_group = clutter_group_new (); info->overlay_group = clutter_group_new ();
clutter_container_add (CLUTTER_CONTAINER (info->window_group), meta_window_group_set_background (META_WINDOW_GROUP (info->window_group),
info->background_actor, META_BACKGROUND_ACTOR (info->background_actor));
NULL);
clutter_container_add (CLUTTER_CONTAINER (info->stage), clutter_container_add (CLUTTER_CONTAINER (info->stage),
info->window_group, info->window_group,

View File

@ -22,6 +22,13 @@ struct _MetaWindowGroup
ClutterGroup parent; ClutterGroup parent;
MetaScreen *screen; MetaScreen *screen;
MetaBackgroundActor *background;
};
enum {
PROP_0,
PROP_BACKGROUND,
PROP_LAST
}; };
G_DEFINE_TYPE (MetaWindowGroup, meta_window_group, CLUTTER_TYPE_GROUP); G_DEFINE_TYPE (MetaWindowGroup, meta_window_group, CLUTTER_TYPE_GROUP);
@ -270,7 +277,8 @@ meta_window_group_paint (ClutterActor *actor)
if (clutter_actor_has_effects (l->data)) if (clutter_actor_has_effects (l->data))
continue; continue;
if (META_IS_WINDOW_ACTOR (l->data)) if (l->data != window_group->background &&
META_IS_WINDOW_ACTOR (l->data))
{ {
MetaWindowActor *window_actor = l->data; MetaWindowActor *window_actor = l->data;
int x, y; int x, y;
@ -296,7 +304,7 @@ meta_window_group_paint (ClutterActor *actor)
meta_window_actor_set_visible_region_beneath (window_actor, visible_region); meta_window_actor_set_visible_region_beneath (window_actor, visible_region);
cairo_region_translate (visible_region, x, y); cairo_region_translate (visible_region, x, y);
} }
else if (META_IS_BACKGROUND_ACTOR (l->data)) else if (l->data == window_group->background)
{ {
MetaBackgroundActor *background_actor = l->data; MetaBackgroundActor *background_actor = l->data;
int x, y; int x, y;
@ -322,12 +330,13 @@ meta_window_group_paint (ClutterActor *actor)
*/ */
for (l = children; l; l = l->next) for (l = children; l; l = l->next)
{ {
if (META_IS_WINDOW_ACTOR (l->data)) if (l->data != window_group->background &&
META_IS_WINDOW_ACTOR (l->data))
{ {
MetaWindowActor *window_actor = l->data; MetaWindowActor *window_actor = l->data;
meta_window_actor_reset_visible_regions (window_actor); meta_window_actor_reset_visible_regions (window_actor);
} }
else if (META_IS_BACKGROUND_ACTOR (l->data)) else if (l->data == window_group->background)
{ {
MetaBackgroundActor *background_actor = l->data; MetaBackgroundActor *background_actor = l->data;
meta_background_actor_set_visible_region (background_actor, NULL); meta_background_actor_set_visible_region (background_actor, NULL);
@ -337,12 +346,70 @@ meta_window_group_paint (ClutterActor *actor)
g_list_free (children); g_list_free (children);
} }
void
meta_window_group_set_background (MetaWindowGroup *self,
MetaBackgroundActor *actor)
{
self->background = actor;
clutter_actor_add_child (CLUTTER_ACTOR (self),
CLUTTER_ACTOR (actor));
}
static void
meta_window_group_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
MetaWindowGroup *self = META_WINDOW_GROUP (object);
switch (prop_id)
{
case PROP_BACKGROUND:
g_value_set_object (value, self->background);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
meta_window_group_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
MetaWindowGroup *self = META_WINDOW_GROUP (object);
switch (prop_id)
{
case PROP_BACKGROUND:
meta_window_group_set_background (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void static void
meta_window_group_class_init (MetaWindowGroupClass *klass) meta_window_group_class_init (MetaWindowGroupClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
object_class->get_property = meta_window_group_get_property;
object_class->set_property = meta_window_group_set_property;
actor_class->paint = meta_window_group_paint; actor_class->paint = meta_window_group_paint;
g_object_class_install_property (object_class, PROP_BACKGROUND,
g_param_spec_object ("background",
"Background actor",
"The primary background actor",
META_TYPE_BACKGROUND_ACTOR,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
} }
static void static void

View File

@ -6,6 +6,7 @@
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include <meta/screen.h> #include <meta/screen.h>
#include <meta/meta-background-actor.h>
/** /**
* MetaWindowGroup: * MetaWindowGroup:
@ -49,4 +50,7 @@ GType meta_window_group_get_type (void);
ClutterActor *meta_window_group_new (MetaScreen *screen); ClutterActor *meta_window_group_new (MetaScreen *screen);
void meta_window_group_set_background (MetaWindowGroup *group,
MetaBackgroundActor *background);
#endif /* META_WINDOW_GROUP_H */ #endif /* META_WINDOW_GROUP_H */