From e699044575e17f708f428bf0865d13e26fab0f7d Mon Sep 17 00:00:00 2001
From: Felipe Borges <felipeborges@gnome.org>
Date: Tue, 22 Mar 2016 15:15:04 +0100
Subject: [PATCH] libview: Add annots to the right page
We were assuming that annots were always added to the current page,
which is not always true in continuous or dual modes.
https://bugzilla.redhat.com/show_bug.cgi?id=1292195
---
libview/ev-view.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 6098fc0..afea8ed 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -3167,17 +3167,25 @@ ev_view_create_annotation (EvView *view,
GdkColor color = { 0, 65535, 65535, 0 };
GdkRectangle view_rect;
cairo_region_t *region;
+ gint annot_page;
+ gint offset;
+
+ find_page_at_location (view, x, y, &annot_page, &offset, &offset);
+ if (annot_page == -1) {
+ ev_view_cancel_add_annotation (view);
+ return;
+ }
point.x = x;
point.y = y;
- ev_view_get_page_extents (view, view->current_page, &page_area, &border);
+ ev_view_get_page_extents (view, annot_page, &page_area, &border);
_ev_view_transform_view_point_to_doc_point (view, &point, &page_area, &border,
&doc_rect.x1, &doc_rect.y1);
doc_rect.x2 = doc_rect.x1 + 24;
doc_rect.y2 = doc_rect.y1 + 24;
ev_document_doc_mutex_lock ();
- page = ev_document_get_page (view->document, view->current_page);
+ page = ev_document_get_page (view->document, annot_page);
switch (annot_type) {
case EV_ANNOTATION_TYPE_TEXT:
annot = ev_annotation_text_new (page);
@@ -3212,8 +3220,8 @@ ev_view_create_annotation (EvView *view,
ev_document_doc_mutex_unlock ();
/* If the page didn't have annots, mark the cache as dirty */
- if (!ev_page_cache_get_annot_mapping (view->page_cache, view->current_page))
- ev_page_cache_mark_dirty (view->page_cache, view->current_page, EV_PAGE_DATA_INCLUDE_ANNOTS);
+ if (!ev_page_cache_get_annot_mapping (view->page_cache, annot_page))
+ ev_page_cache_mark_dirty (view->page_cache, annot_page, EV_PAGE_DATA_INCLUDE_ANNOTS);
if (EV_IS_ANNOTATION_MARKUP (annot)) {
GtkWindow *parent;
@@ -3226,11 +3234,11 @@ ev_view_create_annotation (EvView *view,
ev_view_annotation_show_popup_window (view, window);
}
- _ev_view_transform_doc_rect_to_view_rect (view, view->current_page, &doc_rect, &view_rect);
+ _ev_view_transform_doc_rect_to_view_rect (view, annot_page, &doc_rect, &view_rect);
view_rect.x -= view->scroll_x;
view_rect.y -= view->scroll_y;
region = cairo_region_create_rectangle (&view_rect);
- ev_view_reload_page (view, view->current_page, region);
+ ev_view_reload_page (view, annot_page, region);
cairo_region_destroy (region);
g_signal_emit (view, signals[SIGNAL_ANNOT_ADDED], 0, annot);
--
2.5.0