From 4f4be3b6e7bb69e2d1b15256e4bf801791c9b957 Mon Sep 17 00:00:00 2001 From: Jason Crain Date: Mon, 17 Jun 2013 23:09:43 -0500 Subject: libview: Use EvPixbufCache to find selection region Using view->selection_info.selections is inaccurate if the zoom changes, causing drag and drop of selected text to fail. This changes location_in_selected_text function to use the more accurate ev_pixbuf_cache_get_selection_region to find the selection region. https://bugzilla.gnome.org/show_bug.cgi?id=702406 origin commit: https://git.gnome.org/browse/evince/commit/?h=gnome-3-10&id=abedcbd --- libview/ev-view.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'libview') diff --git a/libview/ev-view.c b/libview/ev-view.c index e4a351f8..f91efe84 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -1449,25 +1449,21 @@ location_in_selected_text (EvView *view, gdouble x, gdouble y) { + cairo_region_t *region; gint page = -1; gint x_offset = 0, y_offset = 0; - EvViewSelection *selection; - GList *l = NULL; - for (l = view->selection_info.selections; l != NULL; l = l->next) { - selection = (EvViewSelection *)l->data; - - find_page_at_location (view, x, y, &page, &x_offset, &y_offset); - - if (page != selection->page) - continue; - - if (selection->covered_region && - cairo_region_contains_point (selection->covered_region, x_offset, y_offset)) - return TRUE; - } + find_page_at_location (view, x, y, &page, &x_offset, &y_offset); - return FALSE; + if (page == -1) + return FALSE; + + region = ev_pixbuf_cache_get_selection_region (view->pixbuf_cache, page, view->scale); + + if (region) + return cairo_region_contains_point (region, x_offset, y_offset); + else + return FALSE; } static gboolean -- cgit v1.2.1