From ef3ac7a7f6a828e5fcdd1a635773ef79613c54f9 Mon Sep 17 00:00:00 2001 From: Milan Bouchet-Valat Date: Mon, 1 Jun 2009 21:43:45 +0200 Subject: [PATCH 1/6] Fix crash in app monitor on 64 bits CPUs Pointers and integers are not the same size, use GPOINTER_TO_INT() for conversion. http://bugzilla.gnome.org/show_bug.cgi?id=584539 --- src/shell-app-monitor.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/shell-app-monitor.c b/src/shell-app-monitor.c index 048e2eab5..95c7a264e 100644 --- a/src/shell-app-monitor.c +++ b/src/shell-app-monitor.c @@ -693,6 +693,8 @@ static void save_to_file (ShellAppMonitor *monitor) { GHashTableIter iter; + gpointer key; + gpointer value; int activity; GSList *popularity; AppPopularity *app_popularity; @@ -721,9 +723,11 @@ save_to_file (ShellAppMonitor *monitor) g_object_unref (output); g_hash_table_iter_init (&iter, monitor->popularities); - while (g_hash_table_iter_next (&iter, (gpointer *) &activity, (gpointer *) &popularity) - && popularity) + while (g_hash_table_iter_next (&iter, &key, &value) && value) { + activity = GPOINTER_TO_INT (key); + popularity = value; + line = g_strdup_printf ("%i\n", activity); g_data_output_stream_put_string (data_output, "--\n", NULL, NULL); g_data_output_stream_put_string (data_output, line, NULL, NULL); From 9c859caf30e90d77a2bfb46462719c61e60c24a3 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 6 Jun 2009 12:33:45 -0400 Subject: [PATCH 2/6] Port BigBox, BigRectangle, BigThemeImage to Clutter-1.0 API - ClutterUnit is now replaced with float - allocate() now takes flags rather than absolute_origin_changed boolean - cogl_texture_new_from_data() signature changed http://bugzilla.gnome.org/show_bug.cgi?id=585007 --- src/big/box.c | 80 ++++++++++++++++++++----------------------- src/big/rectangle.c | 11 +++--- src/big/theme-image.c | 30 ++++++++-------- 3 files changed, 57 insertions(+), 64 deletions(-) diff --git a/src/big/box.c b/src/big/box.c index 3c0bf1b5c..a2c216621 100644 --- a/src/big/box.c +++ b/src/big/box.c @@ -1086,8 +1086,8 @@ big_box_get_content_width_request (ClutterActor *self, for (c = priv->children; c != NULL; c = c->next) { BigBoxChild *child = (BigBoxChild *) c->data; - ClutterUnit min_width; - ClutterUnit natural_width; + float min_width; + float natural_width; if (!BOX_CHILD_IN_LAYOUT (child)) continue; @@ -1308,7 +1308,7 @@ big_box_get_content_area_vertical (ClutterActor *self, } static BigBoxAdjustInfo * big_box_adjust_infos_new (BigBox *box, - ClutterUnit for_content_width) + float for_content_width) { BigBoxPrivate *priv = box->priv; BigBoxAdjustInfo *adjusts = g_new0 (BigBoxAdjustInfo, g_list_length (priv->children)); @@ -1402,7 +1402,7 @@ big_box_adjust_up_to_natural_size (GList *children, ((!child->if_fits && !if_fits) || (child->if_fits && if_fits && !adjusts[i].does_not_fit))) { - ClutterUnit needed_increase; + float needed_increase; g_assert (adjusts[i].adjustment >= 0); @@ -1446,7 +1446,7 @@ big_box_adjust_up_to_natural_size (GList *children, ((!child->if_fits && !if_fits) || (child->if_fits && if_fits && !adjusts[i].does_not_fit))) { - ClutterUnit needed_increase; + float needed_increase; g_assert (adjusts[i].adjustment >= 0); @@ -1459,7 +1459,7 @@ big_box_adjust_up_to_natural_size (GList *children, if (needed_increase > 0) { - ClutterUnit extra; + float extra; extra = (space_to_distribute / n_needing_increase); @@ -1605,7 +1605,7 @@ big_box_adjust_for_expandable (GList *children, if (box_child_is_expandable (child, &(adjusts[i])) && !adjusts[i].does_not_fit) { - ClutterUnit extra; + float extra; extra = (expand_space / expand_count); @@ -1719,7 +1719,7 @@ big_box_get_hbox_height_request (ClutterActor *self, for (c = priv->children; c != NULL; c = c->next) { BigBoxChild *child = c->data; - ClutterUnit min_height, natural_height; + float min_height, natural_height; int req = 0; if (!BOX_CHILD_IN_LAYOUT (child)) @@ -1734,10 +1734,8 @@ big_box_get_hbox_height_request (ClutterActor *self, &min_height, &natural_height); if (priv->debug) - g_debug ("H - Child %p min height %d natural %d", - child->actor, - CLUTTER_UNITS_TO_DEVICE (min_height), - CLUTTER_UNITS_TO_DEVICE (natural_height)); + g_debug ("H - Child %p min height %g natural %g", + child->actor, min_height, natural_height); total_min = MAX (total_min, min_height); total_natural = MAX (total_natural, natural_height); @@ -1786,10 +1784,8 @@ big_box_get_vbox_height_request (ClutterActor *self, &min_height, &natural_height); if (priv->debug) - g_debug ("V - Child %p min height %d natural %d", - child->actor, - CLUTTER_UNITS_TO_DEVICE (min_height), - CLUTTER_UNITS_TO_DEVICE (natural_height)); + g_debug ("V - Child %p min height %g natural %g", + child->actor, min_height, natural_height); n_children_in_natural += 1; total_natural += natural_height; @@ -1868,30 +1864,30 @@ big_box_get_preferred_height (ClutterActor *self, if (priv->debug) { if (min_height_p) - g_debug ("Computed minimum height for width=%d as %d", - CLUTTER_UNITS_TO_DEVICE (for_width), CLUTTER_UNITS_TO_DEVICE (*min_height_p)); + g_debug ("Computed minimum height for width=%g as %g", + for_width, *min_height_p); if (natural_height_p) - g_debug ("Computed natural height for width=%d as %d", - CLUTTER_UNITS_TO_DEVICE (for_width), CLUTTER_UNITS_TO_DEVICE (*natural_height_p)); + g_debug ("Computed natural height for width=%g as %g", + for_width, *natural_height_p); } } static void -big_box_layout (ClutterActor *self, - ClutterUnit content_x, - ClutterUnit content_y, - ClutterUnit allocated_content_width, - ClutterUnit allocated_content_height, - ClutterUnit requested_content_width, - ClutterUnit requested_content_height, - gboolean absolute_origin_changed) +big_box_layout (ClutterActor *self, + float content_x, + float content_y, + float allocated_content_width, + float allocated_content_height, + float requested_content_width, + float requested_content_height, + ClutterAllocationFlags flags) { BigBoxPrivate *priv; BigBoxAdjustInfo *adjusts; ClutterActorBox child_box; - ClutterUnit allocated_size, requested_size; - ClutterUnit start; - ClutterUnit end; + float allocated_size, requested_size; + float start; + float end; GList *c; gint i; @@ -1924,7 +1920,7 @@ big_box_layout (ClutterActor *self, for (c = priv->children; c != NULL; c = c->next) { BigBoxChild *child = (BigBoxChild *) c->data; - ClutterUnit req; + float req; if (!BOX_CHILD_IN_LAYOUT (child)) { @@ -1953,7 +1949,7 @@ big_box_layout (ClutterActor *self, child_box.y2 - child_box.y1); clutter_actor_allocate (child->actor, &child_box, - absolute_origin_changed); + flags); } else { @@ -1976,7 +1972,7 @@ big_box_layout (ClutterActor *self, child_box.y2 - child_box.y1); clutter_actor_allocate (child->actor, &child_box, - absolute_origin_changed); + flags); } if (req <= 0) @@ -1990,7 +1986,7 @@ big_box_layout (ClutterActor *self, child_box.y2 = 0; clutter_actor_allocate (child->actor, &child_box, - absolute_origin_changed); + flags); } /* Children with req == 0 still get spacing unless they are IF_FITS. @@ -2015,7 +2011,7 @@ big_box_layout (ClutterActor *self, static void big_box_allocate (ClutterActor *self, const ClutterActorBox *box, - gboolean absolute_origin_changed) + ClutterAllocationFlags flags) { BigBoxPrivate *priv; int requested_content_width; @@ -2037,7 +2033,7 @@ big_box_allocate (ClutterActor *self, box->x2, box->y2); - CLUTTER_ACTOR_CLASS (big_box_parent_class)->allocate (self, box, absolute_origin_changed); + CLUTTER_ACTOR_CLASS (big_box_parent_class)->allocate (self, box, flags); big_box_get_content_width_request (self, &requested_content_width, @@ -2088,7 +2084,7 @@ big_box_allocate (ClutterActor *self, } clutter_actor_allocate (priv->background_texture, &bg_box, - absolute_origin_changed); + flags); } if (priv->background_rectangle) @@ -2102,7 +2098,7 @@ big_box_allocate (ClutterActor *self, clutter_actor_allocate (priv->background_rectangle, &rectangle_box, - absolute_origin_changed); + flags); } for (c = priv->children; c != NULL; c = c->next) @@ -2123,7 +2119,7 @@ big_box_allocate (ClutterActor *self, { float x, y, width, height; - clutter_actor_get_positionu (child->actor, &x, &y); + clutter_actor_get_position (child->actor, &x, &y); clutter_actor_get_preferred_width(child->actor, -1, NULL, &width); clutter_actor_get_preferred_height(child->actor, width, NULL, &height); @@ -2185,14 +2181,14 @@ big_box_allocate (ClutterActor *self, child_box.y2); clutter_actor_allocate(child->actor, &child_box, - absolute_origin_changed); + flags); } } big_box_layout (self, content_x, content_y, allocated_content_width, allocated_content_height, requested_content_width, requested_content_height, - absolute_origin_changed); + flags); } static void diff --git a/src/big/rectangle.c b/src/big/rectangle.c index fd5d1dadd..2b1fb7d37 100644 --- a/src/big/rectangle.c +++ b/src/big/rectangle.c @@ -43,7 +43,7 @@ typedef struct { struct BigRectangle { ClutterRectangle parent_instance; - ClutterUnit radius; + float radius; Corner *corner; CoglHandle corner_material; CoglHandle border_material; @@ -210,8 +210,7 @@ create_corner_texture(Corner *src) g_free(data); texture = cogl_texture_new_from_data(size, size, - 0, - FALSE, + COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_RGBA_8888, COGL_PIXEL_FORMAT_ANY, rowstride, @@ -287,7 +286,7 @@ big_rectangle_update_corners(BigRectangle *rectangle) "color", &color, NULL); - corner = corner_get(CLUTTER_UNITS_TO_DEVICE(rectangle->radius), + corner = corner_get(rectangle->radius, color, border_width, border_color); @@ -485,7 +484,7 @@ big_rectangle_set_property(GObject *object, switch (prop_id) { case PROP_CORNER_RADIUS: - rectangle->radius = CLUTTER_UNITS_FROM_DEVICE(g_value_get_uint(value)); + rectangle->radius = g_value_get_uint(value); rectangle->corners_dirty = TRUE; break; @@ -508,7 +507,7 @@ big_rectangle_get_property(GObject *object, switch (prop_id) { case PROP_CORNER_RADIUS: - g_value_set_uint(value, CLUTTER_UNITS_TO_DEVICE(rectangle->radius)); + g_value_set_uint(value, rectangle->radius); break; default: diff --git a/src/big/theme-image.c b/src/big/theme-image.c index 82ddbc8e2..19779c260 100644 --- a/src/big/theme-image.c +++ b/src/big/theme-image.c @@ -279,7 +279,7 @@ big_theme_image_paint(ClutterActor *actor) static void big_theme_image_allocate(ClutterActor *actor, const ClutterActorBox *box, - gboolean absolute_origin_changed) + ClutterAllocationFlags flags) { BigThemeImage *image; guint old_width; @@ -289,8 +289,8 @@ big_theme_image_allocate(ClutterActor *actor, image = BIG_THEME_IMAGE(actor); - width = ABS(CLUTTER_UNITS_TO_DEVICE(box->x2 - box->x1)); - height = ABS(CLUTTER_UNITS_TO_DEVICE(box->y2 - box->y1)); + width = ABS(box->x2 - box->x1); + height = ABS(box->y2 - box->y1); g_object_get(actor, "surface-width", &old_width, @@ -307,14 +307,14 @@ big_theme_image_allocate(ClutterActor *actor, if (CLUTTER_ACTOR_CLASS(big_theme_image_parent_class)) CLUTTER_ACTOR_CLASS(big_theme_image_parent_class)->allocate(actor, box, - absolute_origin_changed); + flags); } static void big_theme_image_get_preferred_height(ClutterActor *actor, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + float for_width, + float *min_height_p, + float *natural_height_p) { BigThemeImage *image; @@ -333,8 +333,7 @@ big_theme_image_get_preferred_height(ClutterActor *actor, if (!image->u.surface) break; - *natural_height_p = CLUTTER_UNITS_FROM_DEVICE( - cairo_image_surface_get_height(image->u.surface)); + *natural_height_p = cairo_image_surface_get_height(image->u.surface); break; case BIG_THEME_IMAGE_SVG: { @@ -344,8 +343,7 @@ big_theme_image_get_preferred_height(ClutterActor *actor, return; rsvg_handle_get_dimensions(image->u.svg_handle, &dimensions); - *natural_height_p = - CLUTTER_UNITS_FROM_DEVICE(dimensions.height); + *natural_height_p = dimensions.height; break; } default: @@ -355,9 +353,9 @@ big_theme_image_get_preferred_height(ClutterActor *actor, static void big_theme_image_get_preferred_width(ClutterActor *actor, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + float for_height, + float *min_width_p, + float *natural_width_p) { BigThemeImage *image; @@ -376,7 +374,7 @@ big_theme_image_get_preferred_width(ClutterActor *actor, if (!image->u.surface) break; - *natural_width_p = CLUTTER_UNITS_FROM_DEVICE(cairo_image_surface_get_width(image->u.surface)); + *natural_width_p = cairo_image_surface_get_width(image->u.surface); break; case BIG_THEME_IMAGE_SVG: { @@ -386,7 +384,7 @@ big_theme_image_get_preferred_width(ClutterActor *actor, return; rsvg_handle_get_dimensions(image->u.svg_handle, &dimensions); - *natural_width_p = CLUTTER_UNITS_FROM_DEVICE(dimensions.width); + *natural_width_p = dimensions.width; break; } default: From 8a7acaab8419c86c4c85373426240b327e3465f1 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 6 Jun 2009 12:42:50 -0400 Subject: [PATCH 3/6] BigBox: Implement foreach_with_internals() We need a foreach_with_internals() function that includes the background_texture/background_rectangle actors, so that states will properly be updated on map/unmap/etc. http://bugzilla.gnome.org/show_bug.cgi?id=585007 --- src/big/box.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/big/box.c b/src/big/box.c index a2c216621..96c9ae5d1 100644 --- a/src/big/box.c +++ b/src/big/box.c @@ -290,6 +290,23 @@ big_box_real_foreach (ClutterContainer *container, } } +static void +big_box_real_foreach_with_internals (ClutterContainer *container, + ClutterCallback callback, + gpointer user_data) +{ + BigBox *group = BIG_BOX (container); + BigBoxPrivate *priv = group->priv; + + big_box_real_foreach (container, callback, user_data); + + if (priv->background_texture) + (* callback) (priv->background_texture, user_data); + + if (priv->background_rectangle) + (* callback) (priv->background_rectangle, user_data); +} + static void big_box_real_raise (ClutterContainer *container, ClutterActor *child, @@ -439,6 +456,7 @@ clutter_container_iface_init (ClutterContainerIface *iface) iface->add = big_box_real_add; iface->remove = big_box_real_remove; iface->foreach = big_box_real_foreach; + iface->foreach_with_internals = big_box_real_foreach_with_internals; iface->raise = big_box_real_raise; iface->lower = big_box_real_lower; iface->sort_depth_order = big_box_real_sort_depth_order; From 9a62af6c7cab312d7c40b7ce0c91d09d68ae84cb Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 6 Jun 2009 12:55:30 -0400 Subject: [PATCH 4/6] Port TidyGrid to Clutter-1.0 API - ClutterUnit is now replaced with float - allocate() now takes flags rather than absolute_origin_changed boolean http://bugzilla.gnome.org/show_bug.cgi?id=585010 --- src/tidy/tidy-grid.c | 154 +++++++++++++++++++++---------------------- src/tidy/tidy-grid.h | 8 +-- 2 files changed, 80 insertions(+), 82 deletions(-) diff --git a/src/tidy/tidy-grid.c b/src/tidy/tidy-grid.c index 5725ecd7b..fb035edc1 100644 --- a/src/tidy/tidy-grid.c +++ b/src/tidy/tidy-grid.c @@ -76,19 +76,19 @@ static void tidy_grid_pick (ClutterActor *actor, static void tidy_grid_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p); + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p); static void tidy_grid_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p); + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p); -static void tidy_grid_allocate (ClutterActor *self, - const ClutterActorBox *box, - gboolean absolute_origin_changed); +static void tidy_grid_allocate (ClutterActor *self, + const ClutterActorBox *box, + ClutterAllocationFlags flags); G_DEFINE_TYPE_WITH_CODE (TidyGrid, tidy_grid, CLUTTER_TYPE_ACTOR, @@ -101,26 +101,25 @@ G_DEFINE_TYPE_WITH_CODE (TidyGrid, tidy_grid, struct _TidyGridPrivate { - ClutterUnit for_height, for_width; - ClutterUnit pref_width, pref_height; - ClutterUnit alloc_width, alloc_height; + gfloat for_height, for_width; + gfloat pref_width, pref_height; + gfloat alloc_width, alloc_height; - gboolean absolute_origin_changed; GHashTable *hash_table; GList *list; gboolean homogenous_rows; gboolean homogenous_columns; gboolean end_align; - ClutterUnit column_gap, row_gap; + gfloat column_gap, row_gap; gdouble valign, halign; gboolean column_major; gboolean first_of_batch; - ClutterUnit a_current_sum, a_wrap; - ClutterUnit max_extent_a; - ClutterUnit max_extent_b; + gfloat a_current_sum, a_wrap; + gfloat max_extent_a; + gfloat max_extent_b; }; enum @@ -139,8 +138,8 @@ enum struct _TidyGridActorData { gboolean xpos_set, ypos_set; - ClutterUnit xpos, ypos; - ClutterUnit pref_width, pref_height; + gfloat xpos, ypos; + gfloat pref_width, pref_height; }; static void @@ -167,22 +166,22 @@ tidy_grid_class_init (TidyGridClass *klass) g_object_class_install_property (gobject_class, PROP_ROW_GAP, - clutter_param_spec_unit ("row-gap", - "Row gap", - "gap between rows in the layout", - 0, CLUTTER_MAXUNIT, - 0, - G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); + g_param_spec_float ("row-gap", + "Row gap", + "gap between rows in the layout", + 0.0, G_MAXFLOAT, + 0.0, + G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); g_object_class_install_property (gobject_class, PROP_COLUMN_GAP, - clutter_param_spec_unit ("column-gap", - "Column gap", - "gap between columns in the layout", - 0, CLUTTER_MAXUNIT, - 0, - G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); + g_param_spec_float ("column-gap", + "Column gap", + "gap between columns in the layout", + 0.0, G_MAXFLOAT, + 0.0, + G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); g_object_class_install_property @@ -367,14 +366,14 @@ tidy_grid_get_column_major (TidyGrid *self) void tidy_grid_set_column_gap (TidyGrid *self, - ClutterUnit value) + gfloat value) { TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); priv->column_gap = value; clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); } -ClutterUnit +gfloat tidy_grid_get_column_gap (TidyGrid *self) { TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); @@ -385,14 +384,14 @@ tidy_grid_get_column_gap (TidyGrid *self) void tidy_grid_set_row_gap (TidyGrid *self, - ClutterUnit value) + gfloat value) { TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); priv->row_gap = value; clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); } -ClutterUnit +gfloat tidy_grid_get_row_gap (TidyGrid *self) { TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); @@ -463,10 +462,10 @@ tidy_grid_set_property (GObject *object, tidy_grid_set_column_major (grid, g_value_get_boolean (value)); break; case PROP_COLUMN_GAP: - tidy_grid_set_column_gap (grid, clutter_value_get_unit (value)); + tidy_grid_set_column_gap (grid, g_value_get_float (value)); break; case PROP_ROW_GAP: - tidy_grid_set_row_gap (grid, clutter_value_get_unit (value)); + tidy_grid_set_row_gap (grid, g_value_get_float (value)); break; case PROP_VALIGN: tidy_grid_set_valign (grid, g_value_get_double (value)); @@ -507,10 +506,10 @@ tidy_grid_get_property (GObject *object, g_value_set_boolean (value, tidy_grid_get_column_major (grid)); break; case PROP_COLUMN_GAP: - clutter_value_set_unit (value, tidy_grid_get_column_gap (grid)); + g_value_set_float (value, tidy_grid_get_column_gap (grid)); break; case PROP_ROW_GAP: - clutter_value_set_unit (value, tidy_grid_get_row_gap (grid)); + g_value_set_float (value, tidy_grid_get_row_gap (grid)); break; case PROP_VALIGN: g_value_set_double (value, tidy_grid_get_valign (grid)); @@ -661,15 +660,15 @@ tidy_grid_pick (ClutterActor *actor, static void tidy_grid_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { TidyGrid *layout = (TidyGrid *) self; TidyGridPrivate *priv = layout->priv; - ClutterUnit natural_width; + gfloat natural_width; - natural_width = CLUTTER_UNITS_FROM_INT (200); + natural_width = 200.0; if (min_width_p) *min_width_p = natural_width; if (natural_width_p) @@ -680,15 +679,15 @@ tidy_grid_get_preferred_width (ClutterActor *self, static void tidy_grid_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { TidyGrid *layout = (TidyGrid *) self; TidyGridPrivate *priv = layout->priv; - ClutterUnit natural_height; + gfloat natural_height; - natural_height = CLUTTER_UNITS_FROM_INT (200); + natural_height = 200.0; priv->for_width = for_width; priv->pref_height = natural_height; @@ -699,17 +698,17 @@ tidy_grid_get_preferred_height (ClutterActor *self, *natural_height_p = natural_height; } -static ClutterUnit +static gfloat compute_row_height (GList *siblings, - ClutterUnit best_yet, - ClutterUnit current_a, + gfloat best_yet, + gfloat current_a, TidyGridPrivate *priv) { GList *l; gboolean homogenous_a; gboolean homogenous_b; - ClutterUnit gap; + gfloat gap; if (priv->column_major) { @@ -727,7 +726,7 @@ compute_row_height (GList *siblings, for (l = siblings; l != NULL; l = l->next) { ClutterActor *child = l->data; - ClutterUnit natural_width, natural_height; + gfloat natural_width, natural_height; /* each child will get as much space as they require */ clutter_actor_get_preferred_size (CLUTTER_ACTOR (child), @@ -736,7 +735,7 @@ compute_row_height (GList *siblings, if (priv->column_major) { - ClutterUnit temp = natural_height; + gfloat temp = natural_height; natural_height = natural_width; natural_width = temp; } @@ -762,17 +761,17 @@ compute_row_height (GList *siblings, -static ClutterUnit +static gfloat compute_row_start (GList *siblings, - ClutterUnit start_x, + gfloat start_x, TidyGridPrivate *priv) { - ClutterUnit current_a = start_x; + gfloat current_a = start_x; GList *l; gboolean homogenous_a; gboolean homogenous_b; - ClutterUnit gap; + gfloat gap; if (priv->column_major) { @@ -790,7 +789,7 @@ compute_row_start (GList *siblings, for (l = siblings; l != NULL; l = l->next) { ClutterActor *child = l->data; - ClutterUnit natural_width, natural_height; + gfloat natural_width, natural_height; /* each child will get as much space as they require */ clutter_actor_get_preferred_size (CLUTTER_ACTOR (child), @@ -819,17 +818,17 @@ compute_row_start (GList *siblings, static void tidy_grid_allocate (ClutterActor *self, - const ClutterActorBox *box, - gboolean absolute_origin_changed) + const ClutterActorBox *box, + ClutterAllocationFlags flags) { TidyGrid *layout = (TidyGrid *) self; TidyGridPrivate *priv = layout->priv; - ClutterUnit current_a; - ClutterUnit current_b; - ClutterUnit next_b; - ClutterUnit agap; - ClutterUnit bgap; + gfloat current_a; + gfloat current_b; + gfloat next_b; + gfloat agap; + gfloat bgap; gboolean homogenous_a; gboolean homogenous_b; @@ -842,11 +841,10 @@ tidy_grid_allocate (ClutterActor *self, /* chain up to set actor->allocation */ CLUTTER_ACTOR_CLASS (tidy_grid_parent_class) - ->allocate (self, box, absolute_origin_changed); + ->allocate (self, box, flags); priv->alloc_width = box->x2 - box->x1; priv->alloc_height = box->y2 - box->y1; - priv->absolute_origin_changed = absolute_origin_changed; /* Make sure we have calculated the preferred size */ /* what does this do? */ @@ -885,8 +883,8 @@ tidy_grid_allocate (ClutterActor *self, for (iter = priv->list; iter; iter = iter->next) { ClutterActor *child = iter->data; - ClutterUnit natural_width; - ClutterUnit natural_height; + gfloat natural_width; + gfloat natural_height; /* each child will get as much space as they require */ clutter_actor_get_preferred_size (CLUTTER_ACTOR (child), @@ -901,7 +899,7 @@ tidy_grid_allocate (ClutterActor *self, if (priv->column_major) { - ClutterUnit temp = priv->max_extent_a; + gfloat temp = priv->max_extent_a; priv->max_extent_a = priv->max_extent_b; priv->max_extent_b = temp; } @@ -909,8 +907,8 @@ tidy_grid_allocate (ClutterActor *self, for (iter = priv->list; iter; iter=iter->next) { ClutterActor *child = iter->data; - ClutterUnit natural_a; - ClutterUnit natural_b; + gfloat natural_a; + gfloat natural_b; /* each child will get as much space as they require */ clutter_actor_get_preferred_size (CLUTTER_ACTOR (child), @@ -919,7 +917,7 @@ tidy_grid_allocate (ClutterActor *self, if (priv->column_major) /* swap axes around if column is major */ { - ClutterUnit temp = natural_a; + gfloat temp = natural_a; natural_a = natural_b; natural_b = temp; } @@ -945,7 +943,7 @@ tidy_grid_allocate (ClutterActor *self, next_b = current_b + natural_b; { - ClutterUnit row_height; + gfloat row_height; ClutterActorBox child_box; if (homogenous_b) @@ -976,7 +974,7 @@ tidy_grid_allocate (ClutterActor *self, if (priv->column_major) { - ClutterUnit temp = child_box.x1; + gfloat temp = child_box.x1; child_box.x1 = child_box.y1; child_box.y1 = temp; @@ -988,7 +986,7 @@ tidy_grid_allocate (ClutterActor *self, /* update the allocation */ clutter_actor_allocate (CLUTTER_ACTOR (child), &child_box, - absolute_origin_changed); + flags); if (homogenous_a) { diff --git a/src/tidy/tidy-grid.h b/src/tidy/tidy-grid.h index 6ed94657e..9444c3fff 100644 --- a/src/tidy/tidy-grid.h +++ b/src/tidy/tidy-grid.h @@ -82,11 +82,11 @@ void tidy_grid_set_column_major (TidyGrid *self, gboolean value); gboolean tidy_grid_get_column_major (TidyGrid *self); void tidy_grid_set_row_gap (TidyGrid *self, - ClutterUnit value); -ClutterUnit tidy_grid_get_row_gap (TidyGrid *self); + gfloat value); +gfloat tidy_grid_get_row_gap (TidyGrid *self); void tidy_grid_set_column_gap (TidyGrid *self, - ClutterUnit value); -ClutterUnit tidy_grid_get_column_gap (TidyGrid *self); + gfloat value); +gfloat tidy_grid_get_column_gap (TidyGrid *self); void tidy_grid_set_valign (TidyGrid *self, gdouble value); gdouble tidy_grid_get_valign (TidyGrid *self); From 315da57c97ae738fc345ff07d375203235bf0cc4 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 6 Jun 2009 13:03:24 -0400 Subject: [PATCH 5/6] Add the root pixmap source actor to the stage With clutter changes, we can now no longer clone an actor unless it is part of a stage. So, we hide the root pixmap source, and add it. This means that the logic to free the source actor when the last clone disappears no longer applies, since the stage will also reference it; so we just leave the actor around permanently. http://bugzilla.gnome.org/show_bug.cgi?id=585012 --- src/shell-global.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/shell-global.c b/src/shell-global.c index f7c0500d7..f3a4185b4 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -44,7 +44,7 @@ struct _ShellGlobal { const char *configdir; /* Displays the root window; see shell_global_create_root_pixmap_actor() */ - ClutterGLXTexturePixmap *root_pixmap; + ClutterActor *root_pixmap; }; enum { @@ -1002,23 +1002,27 @@ ClutterActor * shell_global_create_root_pixmap_actor (ShellGlobal *global) { GdkWindow *window; - gboolean created_new_pixmap = FALSE; - ClutterActor *clone; + ClutterActor *stage; /* The actor created is actually a ClutterClone of global->root_pixmap. */ if (global->root_pixmap == NULL) { - global->root_pixmap = CLUTTER_GLX_TEXTURE_PIXMAP (clutter_glx_texture_pixmap_new ()); + global->root_pixmap = clutter_glx_texture_pixmap_new (); /* The low and medium quality filters give nearest-neighbor resizing. */ clutter_texture_set_filter_quality (CLUTTER_TEXTURE (global->root_pixmap), CLUTTER_TEXTURE_QUALITY_HIGH); - /* The pixmap actor is only referenced by its clones. */ - g_object_ref_sink (global->root_pixmap); + /* We can only clone an actor within a stage, so we hide the source + * texture then add it to the stage */ + clutter_actor_hide (global->root_pixmap); + stage = mutter_plugin_get_stage (global->plugin); + clutter_container_add_actor (CLUTTER_CONTAINER (stage), + global->root_pixmap); - g_signal_connect (G_OBJECT (global->root_pixmap), "destroy", + /* This really should never happen; but just in case... */ + g_signal_connect (global->root_pixmap, "destroy", G_CALLBACK (root_pixmap_destroy), global); /* Metacity handles changes to some root window properties in its global @@ -1034,16 +1038,9 @@ shell_global_create_root_pixmap_actor (ShellGlobal *global) gdk_window_add_filter (window, root_window_filter, global); update_root_window_pixmap (global); - - created_new_pixmap = TRUE; } - clone = clutter_clone_new (CLUTTER_ACTOR (global->root_pixmap)); - - if (created_new_pixmap) - g_object_unref(global->root_pixmap); - - return clone; + return clutter_clone_new (global->root_pixmap); } void From 2c7d33bad2653b9ad9bce090b5b8227cd6393ad1 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 6 Jun 2009 13:07:41 -0400 Subject: [PATCH 6/6] Port gnome-shell to the Clutter-1.0 API - clutter_actor_get_transformed_position()/size() return floats - clutter_stage_get_actor_at_pos() takes a pick mode - ClutterTimeline no longer has a concept of frames - ClutterUnit is now replaced by float - cogl_texture_new_from_data() signature changed http://bugzilla.gnome.org/show_bug.cgi?id=585013 --- js/ui/chrome.js | 4 ++++ js/ui/dnd.js | 7 +++++-- js/ui/genericDisplay.js | 3 ++- js/ui/tweener.js | 26 +++++++++----------------- src/shell-gtk-embed.c | 20 ++++++++++---------- src/shell-recorder.c | 6 +++--- src/shell-status-menu.c | 6 +++--- src/shell-texture-cache.c | 3 +-- 8 files changed, 37 insertions(+), 38 deletions(-) diff --git a/js/ui/chrome.js b/js/ui/chrome.js index 7a50c29f4..8a962425f 100644 --- a/js/ui/chrome.js +++ b/js/ui/chrome.js @@ -289,6 +289,10 @@ Chrome.prototype = { let [x, y] = actorData.actor.get_transformed_position(); let [w, h] = actorData.actor.get_transformed_size(); + x = Math.round(x); + y = Math.round(y); + w = Math.round(w); + h = Math.round(h); let rect = new Meta.Rectangle({ x: x, y: y, width: w, height: h}); if (actorData.inputRegion && actorData.actor.get_paint_visibility()) diff --git a/js/ui/dnd.js b/js/ui/dnd.js index 940433940..300aeed7d 100644 --- a/js/ui/dnd.js +++ b/js/ui/dnd.js @@ -122,7 +122,9 @@ _Draggable.prototype = { // Because we want to find out what other actor is located at the current position of this._dragActor, // we have to temporarily hide this._dragActor. this._dragActor.hide(); - let target = actor.get_stage().get_actor_at_pos(stageX + this._dragOffsetX, stageY + this._dragOffsetY); + let target = actor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL, + stageX + this._dragOffsetX, + stageY + this._dragOffsetY); this._dragActor.show(); while (target) { if (target._delegate && target._delegate.handleDragOver) { @@ -156,7 +158,8 @@ _Draggable.prototype = { // Find a drop target actor.hide(); let [dropX, dropY] = event.get_coords(); - let target = actor.get_stage().get_actor_at_pos(dropX, dropY); + let target = actor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL, + dropX, dropY); actor.show(); while (target) { if (target._delegate && target._delegate.acceptDrop) { diff --git a/js/ui/genericDisplay.js b/js/ui/genericDisplay.js index d4d2c5af8..4ddaf0688 100644 --- a/js/ui/genericDisplay.js +++ b/js/ui/genericDisplay.js @@ -648,7 +648,8 @@ GenericDisplay.prototype = { // Check if the pointer is over one of the items and display the preview pop-up if it is. let [child, x, y, mask] = Gdk.Screen.get_default().get_root_window().get_pointer(); let global = Shell.Global.get(); - let actor = global.stage.get_actor_at_pos(x, y); + let actor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, + x, y); if (actor != null) { let item = this._findDisplayedByActor(actor.get_parent()); if (item != null) { diff --git a/js/ui/tweener.js b/js/ui/tweener.js index 87d929231..74cab9651 100644 --- a/js/ui/tweener.js +++ b/js/ui/tweener.js @@ -204,10 +204,9 @@ ClutterFrameTicker.prototype = { _init : function() { // We don't have a finite duration; tweener will tell us to stop // when we need to stop, so use 1000 seconds as "infinity" - this._timeline = new Clutter.Timeline({ fps: this.FRAME_RATE, - duration: 1000*1000 }); - this._currentTime = 0; - this._frame = 0; + this._timeline = new Clutter.Timeline({ duration: 1000*1000 }); + this._startTime = -1; + this._currentTime = -1; let me = this; this._timeline.connect('new-frame', @@ -220,20 +219,13 @@ ClutterFrameTicker.prototype = { // If there is a lot of setup to start the animation, then // first frame number we get from clutter might be a long ways // into the animation (or the animation might even be done). - // That looks bad, so we always start one frame into the + // That looks bad, so we always start at the first frame of the // animation then only do frame dropping from there. - let delta; - if (this._frame == 0) - delta = 1; - else - delta = frame - this._frame; - - if (delta == 0) // protect against divide-by-0 if we get a frame twice - delta = 1; + if (this._startTime < 0) + this._startTime = this._timeline.get_elapsed_time(); // currentTime is in milliseconds - this._currentTime += (1000 * delta) / this.FRAME_RATE; - this._frame = frame; + this._currentTime = this._timeline.get_elapsed_time() - this._startTime; this.emit('prepare-frame'); }, @@ -247,8 +239,8 @@ ClutterFrameTicker.prototype = { stop : function() { this._timeline.stop(); - this._frame = 0; - this._currentTime = 0; + this._startTime = -1; + this._currentTime = -1; } }; diff --git a/src/shell-gtk-embed.c b/src/shell-gtk-embed.c index 998651c09..0d5f2978e 100644 --- a/src/shell-gtk-embed.c +++ b/src/shell-gtk-embed.c @@ -147,9 +147,9 @@ shell_gtk_embed_get_property (GObject *object, static void shell_gtk_embed_get_preferred_width (ClutterActor *actor, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + float for_height, + float *min_width_p, + float *natural_width_p) { ShellGtkEmbed *embed = SHELL_GTK_EMBED (actor); @@ -166,9 +166,9 @@ shell_gtk_embed_get_preferred_width (ClutterActor *actor, static void shell_gtk_embed_get_preferred_height (ClutterActor *actor, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + float for_width, + float *min_height_p, + float *natural_height_p) { ShellGtkEmbed *embed = SHELL_GTK_EMBED (actor); @@ -186,13 +186,13 @@ shell_gtk_embed_get_preferred_height (ClutterActor *actor, static void shell_gtk_embed_allocate (ClutterActor *actor, const ClutterActorBox *box, - gboolean absolute_origin_changed) + ClutterAllocationFlags flags) { ShellGtkEmbed *embed = SHELL_GTK_EMBED (actor); - int wx = 0, wy = 0, x, y, ax, ay; + float wx = 0.0, wy = 0.0, x, y, ax, ay; CLUTTER_ACTOR_CLASS (shell_gtk_embed_parent_class)-> - allocate (actor, box, absolute_origin_changed); + allocate (actor, box, flags); /* Find the actor's new coordinates in terms of the stage (which is * priv->window's parent window. @@ -209,7 +209,7 @@ shell_gtk_embed_allocate (ClutterActor *actor, } _shell_embedded_window_allocate (embed->priv->window, - wx, wy, + (int)(0.5 + wx), (int)(0.5 + wy), box->x2 - box->x1, box->y2 - box->y1); } diff --git a/src/shell-recorder.c b/src/shell-recorder.c index b80b7db75..134c0e550 100644 --- a/src/shell-recorder.c +++ b/src/shell-recorder.c @@ -188,7 +188,7 @@ create_recording_icon (void) cairo_destroy (cr); - texture = cogl_texture_new_from_data (32, 32, 63, + texture = cogl_texture_new_from_data (32, 32, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_BGRA_8888, COGL_PIXEL_FORMAT_ANY, @@ -576,11 +576,11 @@ static void recorder_queue_redraw (ShellRecorder *recorder) { /* If we just queue a redraw on every mouse motion (for example), we - * starve ClutterTimeline, which operates at a very low priority. So + * starve Clutter, which operates at a very low priority. So * we need to queue a "low priority redraw" after timeline updates */ if (recorder->state == RECORDER_STATE_RECORDING && recorder->redraw_idle == 0) - recorder->redraw_idle = g_idle_add_full (CLUTTER_PRIORITY_TIMELINE + 1, + recorder->redraw_idle = g_idle_add_full (CLUTTER_PRIORITY_REDRAW + 1, recorder_idle_redraw, recorder, NULL); } diff --git a/src/shell-status-menu.c b/src/shell-status-menu.c index ab4fb5a4d..bfe9b41a2 100644 --- a/src/shell-status-menu.c +++ b/src/shell-status-menu.c @@ -598,12 +598,12 @@ static void position_menu (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data) { ShellStatusMenu *status = SHELL_STATUS_MENU (user_data); - int src_x, src_y; + float src_x, src_y; clutter_actor_get_transformed_position (CLUTTER_ACTOR (status), &src_x, &src_y); - *x = src_x; - *y = src_y; + *x = (gint)(0.5 + src_x); + *y = (gint)(0.5 + src_y); } void diff --git a/src/shell-texture-cache.c b/src/shell-texture-cache.c index db03c0a5c..c5930877f 100644 --- a/src/shell-texture-cache.c +++ b/src/shell-texture-cache.c @@ -434,8 +434,7 @@ pixbuf_to_cogl_handle (GdkPixbuf *pixbuf) { return cogl_texture_new_from_data (gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), - 63, /* taken from clutter-texture.c default */ - COGL_TEXTURE_AUTO_MIPMAP, + COGL_TEXTURE_NONE, gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888, COGL_PIXEL_FORMAT_ANY, gdk_pixbuf_get_rowstride (pixbuf),