diff --git a/demos/gtk-demo/gestures.c b/demos/gtk-demo/gestures.c index 8d53ae3434..4079ed950f 100644 --- a/demos/gtk-demo/gestures.c +++ b/demos/gtk-demo/gestures.c @@ -94,9 +94,12 @@ drawing_area_draw (GtkDrawingArea *area, cairo_pattern_t *pat; cairo_matrix_t matrix; gdouble angle, scale; + gdouble x_center, y_center; + + gtk_gesture_get_bounding_box_center (GTK_GESTURE (zoom), &x_center, &y_center); cairo_get_matrix (cr, &matrix); - cairo_matrix_translate (&matrix, width / 2, height / 2); + cairo_matrix_translate (&matrix, x_center, y_center); cairo_save (cr); diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c index 165936d7c7..5e95de0cf9 100644 --- a/gtk/gtkgesture.c +++ b/gtk/gtkgesture.c @@ -1335,12 +1335,19 @@ gtk_gesture_get_bounding_box_center (GtkGesture *gesture, gdouble *x, gdouble *y) { + const GdkEvent *last_event; GdkRectangle rect; + GdkEventSequence *sequence; g_return_val_if_fail (GTK_IS_GESTURE (gesture), FALSE); g_return_val_if_fail (x != NULL && y != NULL, FALSE); - if (!gtk_gesture_get_bounding_box (gesture, &rect)) + sequence = gtk_gesture_get_last_updated_sequence (gesture); + last_event = gtk_gesture_get_last_event (gesture, sequence); + + if (EVENT_IS_TOUCHPAD_GESTURE (last_event)) + return gtk_gesture_get_point (gesture, sequence, x, y); + else if (!gtk_gesture_get_bounding_box (gesture, &rect)) return FALSE; *x = rect.x + rect.width / 2;