[evince] libview: Keep the offset inside a line when moving the caret between lines.
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] libview: Keep the offset inside a line when moving the caret between lines.
- Date: Wed, 26 Jun 2013 16:18:18 +0000 (UTC)
commit 255b9778880f4aa9520fee7a0a8f6d997559033b
Author: Antia Puentes <apuentes igalia com>
Date: Wed Jun 26 17:40:10 2013 +0200
libview: Keep the offset inside a line when moving the caret between lines.
https://bugzilla.gnome.org/show_bug.cgi?id=702075
libview/ev-view-private.h | 1 +
libview/ev-view.c | 19 ++++++++++++++++++-
2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index 161e8fd..ae1dc01 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -215,6 +215,7 @@ struct _EvView {
gboolean caret_enabled;
gint cursor_offset;
gint cursor_page;
+ gdouble cursor_line_offset;
gboolean cursor_visible;
guint cursor_blink_timeout_id;
guint cursor_blink_time;
diff --git a/libview/ev-view.c b/libview/ev-view.c
index aaf1833..88a419e 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -4175,6 +4175,11 @@ ev_view_button_press_event (GtkWidget *widget,
start_selection_for_event (view, event);
if (position_caret_cursor_at_location (view, event->x, event->y)) {
+ GdkRectangle area;
+
+ if (get_caret_cursor_area (view, view->cursor_page,
view->cursor_offset, &area))
+ view->cursor_line_offset = area.x;
+
view->cursor_blink_time = 0;
ev_view_pend_cursor_blink (view);
@@ -4626,7 +4631,12 @@ ev_view_button_release_event (GtkWidget *widget,
clear_link_selected (view);
ev_view_update_primary_selection (view);
- position_caret_cursor_at_location (view, event->x, event->y);
+ if (position_caret_cursor_at_location (view, event->x, event->y)) {
+ GdkRectangle area;
+
+ if (get_caret_cursor_area (view, view->cursor_page, view->cursor_offset, &area))
+ view->cursor_line_offset = area.x;
+ }
if (view->selection_info.in_drag) {
clear_selection (view);
@@ -5070,6 +5080,13 @@ ev_view_move_cursor (EvView *view,
if (!get_caret_cursor_area (view, view->cursor_page, view->cursor_offset, &rect))
return TRUE;
+ if (step == GTK_MOVEMENT_DISPLAY_LINES) {
+ position_caret_cursor_at_location (view, view->cursor_line_offset,
+ rect.y + (rect.height / 2));
+ } else {
+ view->cursor_line_offset = rect.x;
+ }
+
rect.x += view->scroll_x;
rect.y += view->scroll_y;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]