textview: Fix cursor positioning oddities when scrolling through Pg Up/Down

Use the adjustment target value when repositioning the cursor, and remove the
checks that ensured the cursor was made onscreen immediately, as there will
be definitely a delay on animated adjustment changes.
This commit is contained in:
Carlos Garnacho 2014-07-08 15:27:06 +02:00 committed by Matthias Clasen
parent 6aa8511495
commit ea19e595a1

View File

@ -6183,16 +6183,14 @@ gtk_text_view_scroll_pages (GtkTextView *text_view,
{
gtk_text_view_get_virtual_cursor_pos (text_view, NULL, &cursor_x_pos, &cursor_y_pos);
oldval = gtk_adjustment_get_value (adjustment);
newval = gtk_adjustment_get_value (adjustment);
oldval = newval = gtk_adjustment_get_target_value (adjustment);
newval += count * gtk_adjustment_get_page_increment (adjustment);
gtk_adjustment_animate_to_value (adjustment, newval);
cursor_y_pos += gtk_adjustment_get_value (adjustment) - oldval;
cursor_y_pos += newval - oldval;
gtk_text_layout_get_iter_at_pixel (priv->layout, &new_insert, cursor_x_pos, cursor_y_pos);
clamp_iter_onscreen (text_view, &new_insert);
move_cursor (text_view, &new_insert, extend_selection);
gtk_text_view_set_virtual_cursor_pos (text_view, cursor_x_pos, cursor_y_pos);
@ -6202,7 +6200,6 @@ gtk_text_view_scroll_pages (GtkTextView *text_view,
* only guarantees 1 pixel onscreen.
*/
DV(g_print (G_STRLOC": scrolling onscreen\n"));
gtk_text_view_scroll_mark_onscreen (text_view, insert_mark);
return !gtk_text_iter_equal (&old_insert, &new_insert);
}
@ -6267,16 +6264,13 @@ gtk_text_view_scroll_hpages (GtkTextView *text_view,
{
gtk_text_view_get_virtual_cursor_pos (text_view, NULL, &cursor_x_pos, &cursor_y_pos);
oldval = gtk_adjustment_get_value (adjustment);
newval = gtk_adjustment_get_value (adjustment);
oldval = newval = gtk_adjustment_get_target_value (adjustment);
newval += count * gtk_adjustment_get_page_increment (adjustment);
gtk_adjustment_animate_to_value (adjustment, newval);
cursor_x_pos += gtk_adjustment_get_value (adjustment) - oldval;
cursor_x_pos += newval - oldval;
gtk_text_layout_get_iter_at_pixel (priv->layout, &new_insert, cursor_x_pos, cursor_y_pos);
clamp_iter_onscreen (text_view, &new_insert);
move_cursor (text_view, &new_insert, extend_selection);
gtk_text_view_set_virtual_cursor_pos (text_view, cursor_x_pos, cursor_y_pos);
@ -6292,7 +6286,6 @@ gtk_text_view_scroll_hpages (GtkTextView *text_view,
* only guarantees 1 pixel onscreen.
*/
DV(g_print (G_STRLOC": scrolling onscreen\n"));
gtk_text_view_scroll_mark_onscreen (text_view, insert_mark);
return !gtk_text_iter_equal (&old_insert, &new_insert);
}