St: fix container paint volumes

If a container is not clip-to-allocation, then its get_paint_volume()
needs to include the paint volumes of all of its children, since they
(or their children) may paint outside the container's allocation.

Also, if the superclass get_paint_volume() returns FALSE, then the
subclass should return FALSE too.

https://bugzilla.gnome.org/show_bug.cgi?id=655812
This commit is contained in:
Dan Winship 2011-08-01 15:16:45 -04:00
parent 7765d6a08f
commit dbeab0ef87
4 changed files with 36 additions and 59 deletions

View File

@ -247,34 +247,6 @@ shell_generic_container_finalize (GObject *object)
G_OBJECT_CLASS (shell_generic_container_parent_class)->finalize (object);
}
/* Based on implementation from clutter-group.c */
static gboolean
shell_generic_container_get_paint_volume (ClutterActor *actor,
ClutterPaintVolume *volume)
{
GList *l, *children;
children = st_container_get_children_list (ST_CONTAINER (actor));
CLUTTER_ACTOR_CLASS (shell_generic_container_parent_class)->get_paint_volume (actor, volume);
for (l = children; l != NULL; l = l->next)
{
ClutterActor *child = l->data;
const ClutterPaintVolume *child_volume;
/* This gets the paint volume of the child transformed into the
* group's coordinate space... */
child_volume = clutter_actor_get_transformed_paint_volume (child, actor);
if (!child_volume)
return FALSE;
clutter_paint_volume_union (volume, child_volume);
}
return TRUE;
}
static void
shell_generic_container_class_init (ShellGenericContainerClass *klass)
{
@ -287,7 +259,6 @@ shell_generic_container_class_init (ShellGenericContainerClass *klass)
actor_class->get_preferred_width = shell_generic_container_get_preferred_width;
actor_class->get_preferred_height = shell_generic_container_get_preferred_height;
actor_class->allocate = shell_generic_container_allocate;
actor_class->get_paint_volume = shell_generic_container_get_paint_volume;
actor_class->paint = shell_generic_container_paint;
actor_class->pick = shell_generic_container_pick;

View File

@ -1020,7 +1020,8 @@ st_box_layout_get_paint_volume (ClutterActor *actor,
StBoxLayout *self = ST_BOX_LAYOUT (actor);
gdouble x, y;
CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->get_paint_volume (actor, volume);
if (!CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->get_paint_volume (actor, volume))
return FALSE;
/* When scrolled, st_box_layout_apply_transform() includes the scroll offset
* and affects paint volumes. This is right for our children, but our paint volume

View File

@ -427,6 +427,37 @@ st_container_dispose (GObject *object)
G_OBJECT_CLASS (st_container_parent_class)->dispose (object);
}
static gboolean
st_container_get_paint_volume (ClutterActor *actor,
ClutterPaintVolume *volume)
{
StContainerPrivate *priv = ST_CONTAINER (actor)->priv;
GList *l;
if (!CLUTTER_ACTOR_CLASS (st_container_parent_class)->get_paint_volume (actor, volume))
return FALSE;
if (!clutter_actor_get_clip_to_allocation (actor))
{
/* Based on ClutterGroup/ClutterBox; include the children's
* paint volumes, since they may paint outside our allocation.
*/
for (l = priv->children; l != NULL; l = l->next)
{
ClutterActor *child = l->data;
const ClutterPaintVolume *child_volume;
child_volume = clutter_actor_get_transformed_paint_volume (child, actor);
if (!child_volume)
return FALSE;
clutter_paint_volume_union (volume, child_volume);
}
}
return TRUE;
}
/* filter @children to contain only only actors that overlap @rbox
* when moving in @direction. (Assuming no transformations.)
*/
@ -719,6 +750,7 @@ static void
st_container_class_init (StContainerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
StContainerClass *container_class = ST_CONTAINER_CLASS (klass);
@ -726,6 +758,8 @@ st_container_class_init (StContainerClass *klass)
object_class->dispose = st_container_dispose;
actor_class->get_paint_volume = st_container_get_paint_volume;
widget_class->navigate_focus = st_container_navigate_focus;
container_class->get_focus_chain = st_container_real_get_focus_chain;

View File

@ -231,34 +231,6 @@ st_group_hide_all (ClutterActor *actor)
NULL);
}
/* Based on implementation from clutter-group.c */
static gboolean
st_group_get_paint_volume (ClutterActor *actor,
ClutterPaintVolume *volume)
{
GList *l, *children;
children = st_container_get_children_list (ST_CONTAINER (actor));
CLUTTER_ACTOR_CLASS (st_group_parent_class)->get_paint_volume (actor, volume);
for (l = children; l != NULL; l = l->next)
{
ClutterActor *child = l->data;
const ClutterPaintVolume *child_volume;
/* This gets the paint volume of the child transformed into the
* group's coordinate space... */
child_volume = clutter_actor_get_transformed_paint_volume (child, actor);
if (!child_volume)
return FALSE;
clutter_paint_volume_union (volume, child_volume);
}
return TRUE;
}
static void
st_group_class_init (StGroupClass *klass)
@ -269,7 +241,6 @@ st_group_class_init (StGroupClass *klass)
actor_class->get_preferred_height = st_group_get_preferred_height;
actor_class->allocate = st_group_allocate;
actor_class->paint = st_group_paint;
actor_class->get_paint_volume = st_group_get_paint_volume;
actor_class->pick = st_group_pick;
actor_class->show_all = st_group_show_all;
actor_class->hide_all = st_group_hide_all;