diff --git a/panels/display/scrollarea.c b/panels/display/scrollarea.c index 6946c6419..d705f0273 100644 --- a/panels/display/scrollarea.c +++ b/panels/display/scrollarea.c @@ -1182,16 +1182,31 @@ foo_scroll_area_set_min_size (FooScrollArea *scroll_area, gtk_widget_queue_resize (GTK_WIDGET (scroll_area)); } +typedef struct { + cairo_t *cr; + GtkAllocation allocation; +} user_to_device_data; + static void user_to_device (double *x, double *y, - gpointer data) + gpointer user_data) { -#if 0 - cairo_t *cr = data; + gdouble ox, oy; + user_to_device_data* data = user_data; - /* FIXME: not set transform in first place? */ - cairo_user_to_device (cr, x, y); -#endif + /* Required in case the user does transformations (eg. translates) */ + cairo_user_to_device (data->cr, x, y); + + /* The device offset is different for a full redraw. + * So we cannot make assumptions about it. */ + cairo_surface_get_device_offset(cairo_get_target(data->cr), &ox, &oy); + + *x -= ox; + *y -= oy; + + /* The input_window does not of the allocation offset. */ + *x -= data->allocation.x; + *y -= data->allocation.y; } static InputPath * @@ -1201,13 +1216,18 @@ make_path (FooScrollArea *area, FooScrollAreaEventFunc func, gpointer data) { + user_to_device_data conversion_data; + InputPath *path = g_new0 (InputPath, 1); + conversion_data.cr = cr; + gtk_widget_get_allocation(GTK_WIDGET (area), &conversion_data.allocation); + path->is_stroke = is_stroke; path->fill_rule = cairo_get_fill_rule (cr); path->line_width = cairo_get_line_width (cr); path->path = cairo_copy_path (cr); - path_foreach_point (path->path, user_to_device, cr); + path_foreach_point (path->path, user_to_device, &conversion_data); path->func = func; path->data = data; path->next = area->priv->current_input->paths;