[evince] get_match_offset(): ignore areas with center outside of match



commit c3c1fcd761e0a6d8dc35763d1dd120b54a4edb9a
Author: Vasily Galkin <galkin-vv ya ru>
Date:   Sat Aug 14 00:24:06 2021 +0300

    get_match_offset(): ignore areas with center outside of match
    
    Find sidebar implementation of evince uses "reconstruction"
    of found letters by comparing geometrical position of match and letters
    in get_match_offset method.
    
    Before this change the only criteria for search was
    "beginning of the match is inside letter (area)".
    However, for pdfs containing letters that are much bigger than found
    (huge labels over content, like watermarks) those huge letters passed
    criteria and were incorrectly displayed in find sidebar.
    
    With current architecture this problem can't be solved for 100% cases,
    but can be hugely improved.
    
    This commit adds extra check that center of a letter is inside the match,
    this fixes a huge percent of huge letters incorrectly passing criteria.
    
    See MR !372 for more info and testing file.

 shell/ev-find-sidebar.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/shell/ev-find-sidebar.c b/shell/ev-find-sidebar.c
index 04a635862..a8a0ef43a 100644
--- a/shell/ev-find-sidebar.c
+++ b/shell/ev-find-sidebar.c
@@ -422,9 +422,13 @@ get_match_offset (EvRectangle *areas,
 
         do {
                 EvRectangle *area = areas + i;
+                gdouble area_y = (area->y1 + area->y2) / 2;
+                gdouble area_x = (area->x1 + area->x2) / 2;
 
                 if (x >= area->x1 && x < area->x2 &&
-                    y >= area->y1 && y <= area->y2) {
+                    y >= area->y1 && y <= area->y2 &&
+                    area_x >= match->x1 && area_x <= match->x2 &&
+                    area_y >= match->y1 && area_y <= match->y2) {
                         return i;
                 }
 


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