[mutter/wip/gcampax/background: 5/8] MetaWindowGroup: store aside the background actor
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/gcampax/background: 5/8] MetaWindowGroup: store aside the background actor
- Date: Mon, 4 Feb 2013 23:12:31 +0000 (UTC)
commit 51f6a4cb0e7969750bd3c7e9ff12725d2d3caee7
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Mon Dec 17 19:17:46 2012 +0100
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
src/compositor/compositor.c | 5 +-
src/compositor/meta-window-group.c | 75 ++++++++++++++++++++++++++++++++++--
src/compositor/meta-window-group.h | 4 ++
3 files changed, 77 insertions(+), 7 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 444d6d7..c74119d 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -557,9 +557,8 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
info->background_actor = meta_background_actor_new (screen, NULL);
info->overlay_group = clutter_group_new ();
- clutter_container_add (CLUTTER_CONTAINER (info->window_group),
- info->background_actor,
- NULL);
+ meta_window_group_set_background (META_WINDOW_GROUP (info->window_group),
+ META_BACKGROUND_ACTOR (info->background_actor));
clutter_container_add (CLUTTER_CONTAINER (info->stage),
info->window_group,
diff --git a/src/compositor/meta-window-group.c b/src/compositor/meta-window-group.c
index 2b423ea..8de5c44 100644
--- a/src/compositor/meta-window-group.c
+++ b/src/compositor/meta-window-group.c
@@ -22,6 +22,13 @@ struct _MetaWindowGroup
ClutterGroup parent;
MetaScreen *screen;
+ MetaBackgroundActor *background;
+};
+
+enum {
+ PROP_0,
+ PROP_BACKGROUND,
+ PROP_LAST
};
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))
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;
int x, y;
@@ -296,7 +304,7 @@ meta_window_group_paint (ClutterActor *actor)
meta_window_actor_set_visible_region_beneath (window_actor, visible_region);
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;
int x, y;
@@ -322,12 +330,13 @@ meta_window_group_paint (ClutterActor *actor)
*/
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;
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;
meta_background_actor_set_visible_region (background_actor, NULL);
@@ -337,12 +346,70 @@ meta_window_group_paint (ClutterActor *actor)
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
meta_window_group_class_init (MetaWindowGroupClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_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;
+
+ 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
diff --git a/src/compositor/meta-window-group.h b/src/compositor/meta-window-group.h
index 0e0dc18..5a7b90e 100644
--- a/src/compositor/meta-window-group.h
+++ b/src/compositor/meta-window-group.h
@@ -6,6 +6,7 @@
#include <clutter/clutter.h>
#include <meta/screen.h>
+#include <meta/meta-background-actor.h>
/**
* MetaWindowGroup:
@@ -49,4 +50,7 @@ GType meta_window_group_get_type (void);
ClutterActor *meta_window_group_new (MetaScreen *screen);
+void meta_window_group_set_background (MetaWindowGroup *group,
+ MetaBackgroundActor *background);
+
#endif /* META_WINDOW_GROUP_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]