From cb803a124bf6e589baa649fa9bfe25a5fc970e18 Mon Sep 17 00:00:00 2001 From: "Alejandro G. Castro" Date: Fri, 4 Jul 2008 10:36:47 +0000 Subject: [PATCH] * src/hildon-pannable-area.c, (hildon_pannable_area_get_topmost): replaced gdk_window_get_children with gdk_window_peek_children, this way we do not have to free the list because it is not a copy. (hildon_pannable_axis_scroll), (hildon_pannable_area_scroll), (hildon_pannable_area_timeout), (hildon_pannable_area_motion_notify_cb): Code refactoring, removed two parameters that were only used inside the hildon_pannable_area_scroll function. * examples/hildon-pannable-area-example.c, (get_sawtooth_label): Fixed small memory leak. --- ChangeLog | 17 +++++++++++++++++ examples/hildon-pannable-area-example.c | 3 +++ src/hildon-pannable-area.c | 31 +++++++++++++------------------ 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb4bbf4..130659e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2008-07-04 Alejandro G. Castro + + * src/hildon-pannable-area.c, + (hildon_pannable_area_get_topmost): replaced + gdk_window_get_children with gdk_window_peek_children, this way we + do not have to free the list because it is not a copy. + + (hildon_pannable_axis_scroll), + (hildon_pannable_area_scroll), + (hildon_pannable_area_timeout), + (hildon_pannable_area_motion_notify_cb): Code refactoring, removed + two parameters that were only used inside the + hildon_pannable_area_scroll function. + + * examples/hildon-pannable-area-example.c, + (get_sawtooth_label): Fixed small memory leak. + 2008-07-03 Alejandro G. Castro More checks for the case where the overshoot is bigger than the diff --git a/examples/hildon-pannable-area-example.c b/examples/hildon-pannable-area-example.c index 9b2187b..8bad34e 100644 --- a/examples/hildon-pannable-area-example.c +++ b/examples/hildon-pannable-area-example.c @@ -49,6 +49,9 @@ get_sawtooth_label (gchar **label, guint num) sawtooth = sawtooth_aux; } else { + if (sawtooth) + g_free (sawtooth); + sawtooth = g_strdup (" "); } diff --git a/src/hildon-pannable-area.c b/src/hildon-pannable-area.c index 6b30116..9b3c6ed 100644 --- a/src/hildon-pannable-area.c +++ b/src/hildon-pannable-area.c @@ -162,7 +162,7 @@ static GdkWindow *hildon_pannable_area_get_topmost (GdkWindow * window, while (window) { gint child_x = 0, child_y = 0; - GList *c, *children = gdk_window_get_children (window); + GList *c, *children = gdk_window_peek_children (window); GdkWindow *old_window = window; for (c = children; c; c = c->next) { @@ -181,8 +181,6 @@ static GdkWindow *hildon_pannable_area_get_topmost (GdkWindow * window, } } - g_list_free (children); - /*g_debug ("\\|/"); */ if (window == old_window) break; @@ -525,16 +523,11 @@ hildon_pannable_axis_scroll (HildonPannableArea *area, *vel = 0; } } - - if (s) { - *s = TRUE; - } } gtk_adjustment_set_value (adjust, dist); } else { if (!priv->clicked) { - if (s) *s = TRUE; /* When the overshoot has started we continue for BOUNCE_STEPS more steps into the overshoot * before we reverse direction. The deceleration factor is calculated based on @@ -598,9 +591,9 @@ hildon_pannable_axis_scroll (HildonPannableArea *area, static void hildon_pannable_area_scroll (HildonPannableArea *area, - gdouble x, gdouble y, - gboolean *sx, gboolean *sy) + gdouble x, gdouble y) { + gboolean sx, sy; HildonPannableAreaPrivate *priv; gboolean hscroll, vscroll; @@ -614,27 +607,30 @@ hildon_pannable_area_scroll (HildonPannableArea *area, hscroll = (priv->hadjust->upper - priv->hadjust->lower > priv->hadjust->page_size) ? TRUE : FALSE; + sx = TRUE; + sy = TRUE; + if (vscroll) { hildon_pannable_axis_scroll (area, priv->vadjust, &priv->vel_y, y, &priv->overshooting_y, &priv->overshot_dist_y, - &priv->scroll_to_y, sy); + &priv->scroll_to_y, &sy); } if (hscroll) { hildon_pannable_axis_scroll (area, priv->hadjust, &priv->vel_x, x, &priv->overshooting_x, &priv->overshot_dist_x, - &priv->scroll_to_x, sx); + &priv->scroll_to_x, &sx); } /* If the scroll on a particular axis wasn't succesful, reset the * initial scroll position to the new mouse co-ordinate. This means * when you get to the top of the page, dragging down works immediately. */ - if ((sx)&&(!(*sx))) { + if (!sx) { priv->x = priv->ex; } - if ((sy)&&(!(*sy))) { + if (!sy) { priv->y = priv->ey; } @@ -643,7 +639,6 @@ hildon_pannable_area_scroll (HildonPannableArea *area, static gboolean hildon_pannable_area_timeout (HildonPannableArea * area) { - gboolean sx, sy; HildonPannableAreaPrivate *priv; GDK_THREADS_ENTER (); @@ -686,7 +681,7 @@ hildon_pannable_area_timeout (HildonPannableArea * area) return FALSE; } - hildon_pannable_area_scroll (area, priv->vel_x, priv->vel_y, &sx, &sy); + hildon_pannable_area_scroll (area, priv->vel_x, priv->vel_y); GDK_THREADS_LEAVE (); @@ -744,7 +739,7 @@ hildon_pannable_area_motion_notify_cb (GtkWidget * widget, /* Scroll by the amount of pixels the cursor has moved * since the last motion event. */ - hildon_pannable_area_scroll (area, x, y, NULL, NULL); + hildon_pannable_area_scroll (area, x, y); priv->x = event->x; priv->y = event->y; break; @@ -788,7 +783,7 @@ hildon_pannable_area_motion_notify_cb (GtkWidget * widget, priv->vel_y = priv->vel_y > 0 ? MIN (priv->vel_y, priv->vmax) : MAX (priv->vel_y, -1 * priv->vmax); - hildon_pannable_area_scroll (area, x, y, NULL, NULL); + hildon_pannable_area_scroll (area, x, y); priv->x = event->x; priv->y = event->y; -- 1.7.9.5