[evince/gpoo/fix-hover-for-highlight-annotations: 3/3] libview: checking if point is inside annotation



commit a8411864d67735a119f2d5a66e0c2227dc7d95f8
Author: Giselle Reis <gisellemnr src gnome org>
Date:   Tue Aug 19 19:23:31 2014 +0200

    libview: checking if point is inside annotation
    
    Added a step to check if a point is inside an
    annotation. In case it is foud to be inside the
    bounding box, view asks the document if it is
    actually inside the annotations, since the
    quadrilaterals might not comprise the whole are of
    the bounding box. Only then it become selectable.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769133
    
    Fixes #696

 libview/ev-view.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 802ca493..ec86a1fd 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -3312,6 +3312,8 @@ get_annotation_mapping_at_location (EvView *view,
 {
        gint x_new = 0, y_new = 0;
        EvMappingList *annotations_mapping;
+       GArray        *annotation_mapping_array;
+       guint          i;
 
        if (!EV_IS_DOCUMENT_ANNOTATIONS (view->document))
                return NULL;
@@ -3321,8 +3323,23 @@ get_annotation_mapping_at_location (EvView *view,
 
        annotations_mapping = ev_page_cache_get_annot_mapping (view->page_cache, *page);
 
-       if (annotations_mapping)
-               return ev_mapping_list_get (annotations_mapping, x_new, y_new);
+       if (annotations_mapping) {
+               annotation_mapping_array = ev_mapping_list_get_all (annotations_mapping, x_new, y_new);
+
+               if (annotation_mapping_array) {
+                       for (i = 0; i < annotation_mapping_array->len; i++) {
+                               EvMapping    *mapping;
+                               EvAnnotation *annot;
+
+                               mapping = &g_array_index (annotation_mapping_array, EvMapping, i);
+                               annot = EV_ANNOTATION (mapping->data);
+
+                               if (ev_document_annotations_is_xy_in_annotation (EV_DOCUMENT_ANNOTATIONS 
(view->document), annot, x_new, y_new))
+                                       return mapping;
+                       }
+                       g_array_unref (annotation_mapping_array);
+               }
+       }
 
        return NULL;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]