From 3cb54f6707aeab0a36d325bb169d5798da4062b2 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 26 Aug 2009 23:15:47 -0400 Subject: [PATCH] Fix allocation implementations for ShellStack and ShellDrawingArea In both, using our allocation directly for the child is wrong; we should create a new allocation that's our width and height. In ShellDrawingArea, also need to chain up to parent. --- src/shell-drawing-area.c | 12 +++++++++++- src/shell-stack.c | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/shell-drawing-area.c b/src/shell-drawing-area.c index 78a7e94e8..04505bb50 100644 --- a/src/shell-drawing-area.c +++ b/src/shell-drawing-area.c @@ -40,8 +40,18 @@ shell_drawing_area_allocate (ClutterActor *self, ShellDrawingArea *area = SHELL_DRAWING_AREA (self); int width = box->x2 - box->x1; int height = box->y2 - box->y1; + ClutterActorBox child_box; - clutter_actor_allocate (CLUTTER_ACTOR (area->priv->texture), box, flags); + /* Chain up directly to ClutterActor to set actor->allocation. We explicitly skip our parent class + * ClutterGroup here because we want to override the allocate function. */ + (CLUTTER_ACTOR_CLASS (g_type_class_peek (clutter_actor_get_type ())))->allocate (self, box, flags); + + child_box.x1 = 0; + child_box.x2 = width; + child_box.y1 = 0; + child_box.y2 = height; + + clutter_actor_allocate (CLUTTER_ACTOR (area->priv->texture), &child_box, flags); if (width > 0 && height > 0) { clutter_cairo_texture_set_surface_size (area->priv->texture, diff --git a/src/shell-stack.c b/src/shell-stack.c index e0a5b4bc8..ea3ec2c33 100644 --- a/src/shell-stack.c +++ b/src/shell-stack.c @@ -24,15 +24,25 @@ shell_stack_allocate (ClutterActor *self, ClutterAllocationFlags flags) { GList *children, *iter; + float width, height; - /* chain up to set actor->allocation */ + width = box->x2 - box->x1; + height = box->y2 - box->y1; + + /* Chain up directly to ClutterActor to set actor->allocation. We explicitly skip our parent class + * ClutterGroup here because we want to override the allocate function. */ (CLUTTER_ACTOR_CLASS (g_type_class_peek (clutter_actor_get_type ())))->allocate (self, box, flags); children = clutter_container_get_children (CLUTTER_CONTAINER (self)); for (iter = children; iter; iter = iter->next) { ClutterActor *actor = CLUTTER_ACTOR (iter->data); - clutter_actor_allocate (actor, box, flags); + ClutterActorBox child_box; + child_box.x1 = 0; + child_box.x2 = width; + child_box.y1 = 0; + child_box.y2 = height; + clutter_actor_allocate (actor, &child_box, flags); } g_list_free (children); }