summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2017-03-05 18:28:56 +0100
committerraveit65 <[email protected]>2017-03-07 13:34:19 +0100
commit027cc1bf0c4cd482aaf4a582246d59e5ec7d3ae8 (patch)
tree9b5910bc6035274165db826d5e271568e504ecf0
parent2995f790a05d4077e2686f81ca0b941a0c06ef83 (diff)
downloadatril-027cc1bf0c4cd482aaf4a582246d59e5ec7d3ae8.tar.bz2
atril-027cc1bf0c4cd482aaf4a582246d59e5ec7d3ae8.tar.xz
ev-view-accessible: Use _ev_view_transform_view_point_to_doc_point()
In ev_view_accessible_get_offset_at_point(). taken from: https://git.gnome.org/browse/evince/commit/?h=gnome-3-8&id=28bd405
-rw-r--r--libview/ev-view-accessible.c50
1 files changed, 21 insertions, 29 deletions
diff --git a/libview/ev-view-accessible.c b/libview/ev-view-accessible.c
index 59652ad0..d3672f4a 100644
--- a/libview/ev-view-accessible.c
+++ b/libview/ev-view-accessible.c
@@ -469,14 +469,15 @@ ev_view_accessible_get_offset_at_point (AtkText *text,
AtkCoordType coords)
{
GtkWidget *widget, *toplevel;
+ EvView *view;
EvRectangle *areas = NULL;
EvRectangle *rect = NULL;
guint n_areas = 0;
- guint i = 0;
- EvPageCache *page_cache;
- gint x_window, y_window, x_widget, y_widget;
- gint offset=-1, rx, ry;
- gdouble scale;
+ guint i;
+ gint x_widget, y_widget;
+ gint offset=-1;
+ GdkPoint view_point;
+ gdouble doc_x, doc_y;
GtkBorder border;
GdkRectangle page_area;
@@ -485,45 +486,36 @@ ev_view_accessible_get_offset_at_point (AtkText *text,
/* State is defunct */
return -1;
- page_cache = EV_VIEW (widget)->page_cache;
- if (!page_cache)
+ view = EV_VIEW (widget);
+ if (!view->page_cache)
return -1;
- ev_view_get_page_extents (EV_VIEW (widget), EV_VIEW (widget)->current_page,
- &page_area, &border);
-
- scale = EV_VIEW (widget)->scale;
- ev_page_cache_get_text_layout (page_cache, EV_VIEW (widget)->current_page, &areas, &n_areas);
+ ev_page_cache_get_text_layout (view->page_cache, view->current_page, &areas, &n_areas);
if (!areas)
return -1;
- rx = x;
- ry = y;
-
- rx -= page_area.x;
- ry -= page_area.y;
-
- rx += EV_VIEW (widget)->scroll_x;
- ry += EV_VIEW (widget)->scroll_y;
-
+ view_point.x = x;
+ view_point.y = y;
toplevel = gtk_widget_get_toplevel (widget);
gtk_widget_translate_coordinates (widget, toplevel, 0, 0, &x_widget, &y_widget);
- rx -= x_widget;
- ry -= y_widget;
+ view_point.x -= x_widget;
+ view_point.y -= y_widget;
if (coords == ATK_XY_SCREEN) {
+ gint x_window, y_window;
+
gdk_window_get_origin (gtk_widget_get_window (toplevel), &x_window, &y_window);
- rx -= x_window;
- ry -= y_window;
+ view_point.x -= x_window;
+ view_point.y -= y_window;
}
- rx /= scale;
- ry /= scale;
+ ev_view_get_page_extents (view, view->current_page, &page_area, &border);
+ _ev_view_transform_view_point_to_doc_point (view, &view_point, &page_area, &doc_x, &doc_y);
for (i = 0; i < n_areas; i++) {
rect = areas + i;
- if (rx >= rect->x1 && rx <= rect->x2 &&
- ry >= rect->y1 && ry <= rect->y2)
+ if (doc_x >= rect->x1 && doc_x <= rect->x2 &&
+ doc_y >= rect->y1 && doc_y <= rect->y2)
offset = i;
}