display: Fix mouse events not working in preview
We need to save event areas with the correct transformation. The following things need to be take into account: * Current cairo matrix (translations) * Widget allocation because it is painting on the parents widgets window * Cairo device offset, which GTK+ sets (but not for a full window redraw) https://bugzilla.gnome.org/show_bug.cgi?id=681475
This commit is contained in:
parent
72cce6b89f
commit
c1857b0f9c
1 changed files with 27 additions and 7 deletions
|
@ -1182,16 +1182,31 @@ foo_scroll_area_set_min_size (FooScrollArea *scroll_area,
|
||||||
gtk_widget_queue_resize (GTK_WIDGET (scroll_area));
|
gtk_widget_queue_resize (GTK_WIDGET (scroll_area));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
cairo_t *cr;
|
||||||
|
GtkAllocation allocation;
|
||||||
|
} user_to_device_data;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
user_to_device (double *x, double *y,
|
user_to_device (double *x, double *y,
|
||||||
gpointer data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
#if 0
|
gdouble ox, oy;
|
||||||
cairo_t *cr = data;
|
user_to_device_data* data = user_data;
|
||||||
|
|
||||||
/* FIXME: not set transform in first place? */
|
/* Required in case the user does transformations (eg. translates) */
|
||||||
cairo_user_to_device (cr, x, y);
|
cairo_user_to_device (data->cr, x, y);
|
||||||
#endif
|
|
||||||
|
/* 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 *
|
static InputPath *
|
||||||
|
@ -1201,13 +1216,18 @@ make_path (FooScrollArea *area,
|
||||||
FooScrollAreaEventFunc func,
|
FooScrollAreaEventFunc func,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
user_to_device_data conversion_data;
|
||||||
|
|
||||||
InputPath *path = g_new0 (InputPath, 1);
|
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->is_stroke = is_stroke;
|
||||||
path->fill_rule = cairo_get_fill_rule (cr);
|
path->fill_rule = cairo_get_fill_rule (cr);
|
||||||
path->line_width = cairo_get_line_width (cr);
|
path->line_width = cairo_get_line_width (cr);
|
||||||
path->path = cairo_copy_path (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->func = func;
|
||||||
path->data = data;
|
path->data = data;
|
||||||
path->next = area->priv->current_input->paths;
|
path->next = area->priv->current_input->paths;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue