From 1a4fc8250f89e316c0a8cdb71fa47dd591255176 Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Tue, 21 Aug 2018 10:05:10 +0100 Subject: Choose the lastmost annotation rather than firstmost as mouse event target. pdf_pass_event iterates through the annotations to find one with a bounding box that encompasses the event point. We were choosing the first found, whereas later annotations are considered above earlier ones so we should be choosing the last found. --- source/pdf/pdf-form.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c index 879c7819..2a7d80b1 100644 --- a/source/pdf/pdf-form.c +++ b/source/pdf/pdf-form.c @@ -532,7 +532,8 @@ int pdf_has_unsaved_changes(fz_context *ctx, pdf_document *doc) int pdf_pass_event(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_ui_event *ui_event) { - pdf_annot *annot; + pdf_annot *a; + pdf_annot *annot = NULL; pdf_hotspot *hp = &doc->hotspot; fz_point *pt = &(ui_event->event.pointer.pt); int changed = 0; @@ -541,12 +542,12 @@ int pdf_pass_event(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_ui_ev if (page == NULL) return 0; - for (annot = page->annots; annot; annot = annot->next) + for (a = page->annots; a; a = a->next) { - bbox = pdf_bound_annot(ctx, annot); + bbox = pdf_bound_annot(ctx, a); if (pt->x >= bbox.x0 && pt->x <= bbox.x1) if (pt->y >= bbox.y0 && pt->y <= bbox.y1) - break; + annot = a; } /* Skip hidden annotations. */ -- cgit v1.2.3