[evince/BUG_improve_dbl_tpl_selection_annots: 11/11] ev-view: fix annots from dbl/tpl click + drag



commit 947163b0fd9687f405a8956ec4afe45e03423341
Author: Nelson Benítez León <nbenitezl gmail com>
Date:   Wed Oct 30 17:21:24 2019 -0400

    ev-view: fix annots from dbl/tpl click + drag
    
    Text selections of type EV_SELECTION_STYLE_WORD
    and EV_SELECTION_STYLE_LINE can also be created
    from a double/triple click + keep button pressed
    + text dragging + release button.
    
    In this case, the assumption of commit bcde9daf
    that 'start' and 'end' points are the same for
    these type of selections is no longer valid, so
    remove it and update code accordingly.
    
    Fixes issue #1274

 libview/ev-view.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index e085df0c..e08f1508 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -3517,7 +3517,7 @@ ev_view_get_doc_points_from_selection_region (EvView  *view,
                                              EvPoint *begin,
                                              EvPoint *end)
 {
-       cairo_rectangle_int_t extents;
+       cairo_rectangle_int_t first, last;
        GdkPoint start, stop;
        cairo_region_t *region = NULL;
 
@@ -3529,12 +3529,15 @@ ev_view_get_doc_points_from_selection_region (EvView  *view,
        if (!region)
                return FALSE;
 
-       cairo_region_get_extents (region, &extents);
+       cairo_region_get_rectangle (region, 0, &first);
+       cairo_region_get_rectangle (region, cairo_region_num_rectangles(region) - 1, &last);
 
-       if (!get_doc_point_from_offset (view, page, extents.x, extents.y + (extents.height / 2), &(start.x), 
&(start.y)))
+       if (!get_doc_point_from_offset (view, page, first.x, first.y + (first.height / 2),
+                                       &(start.x), &(start.y)))
                return FALSE;
 
-       if (!get_doc_point_from_offset (view, page, extents.x + extents.width, extents.y + (extents.height / 
2), &(stop.x), &(stop.y)))
+       if (!get_doc_point_from_offset (view, page, last.x + last.width, last.y + (last.height / 2),
+                                       &(stop.x), &(stop.y)))
                return FALSE;
 
        begin->x = start.x;
@@ -3554,8 +3557,7 @@ ev_view_create_annotation_from_selection (EvView          *view,
 
        /* Check if selection is of double/triple click type (STYLE_WORD and STYLE_LINE) and in that
         * case get the start/end points from the selection region of pixbuf cache. Issue #1119 */
-       if (selection->rect.x1 == selection->rect.x2 && selection->rect.y1 == selection->rect.y2 &&
-            (selection->style == EV_SELECTION_STYLE_WORD || selection->style == EV_SELECTION_STYLE_LINE)) {
+       if (selection->style == EV_SELECTION_STYLE_WORD || selection->style == EV_SELECTION_STYLE_LINE) {
 
                if (!ev_view_get_doc_points_from_selection_region (view, selection->page,
                                                                   &doc_point_start, &doc_point_end))


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