summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-12-01 19:35:11 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-12-01 19:35:11 -0500
commit67ad566188f7ca80dbf2769ee07fc1bcf14ac511 (patch)
tree833ccc1cfaea0db2517515a83fbdb0f7f40f5ee8
parentdb46a8dd0636750d49573ca34f89da849aaccdc1 (diff)
downloadgtk+-67ad566188f7ca80dbf2769ee07fc1bcf14ac511.tar.gz
textview: Improve scroll-to-mark behavior
The idea of within-margin is to scroll as little as possible to bring the mark within the margins defined by the factor. The code was achieving that when scrolling down, but not when scrolling up. This change makes things symmetrical. Fixes: #4325
-rw-r--r--gtk/gtktextview.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index c1b83eb9b3..75f9471c8f 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -2641,16 +2641,16 @@ _gtk_text_view_scroll_to_iter (GtkTextView *text_view,
if (cursor.y < screen_inner_top)
{
if (cursor.y == 0)
- border_yoffset = (with_border) ? priv->top_padding : 0;
+ border_yoffset = with_border ? priv->top_padding : 0;
screen_dest.y = cursor.y - MAX (within_margin_yoffset, border_yoffset);
}
else if (cursor_bottom > screen_inner_bottom)
{
if (cursor_bottom == buffer_bottom - priv->top_margin)
- border_yoffset = (with_border) ? priv->bottom_padding : 0;
+ border_yoffset = with_border ? priv->bottom_padding : 0;
- screen_dest.y = cursor_bottom - screen_dest.height +
+ screen_dest.y = cursor_bottom - screen_dest.height -
MAX (within_margin_yoffset, border_yoffset);
}
}
@@ -2679,16 +2679,16 @@ _gtk_text_view_scroll_to_iter (GtkTextView *text_view,
if (cursor.x < screen_inner_left)
{
if (cursor.x == priv->left_margin)
- border_xoffset = (with_border) ? priv->left_padding : 0;
+ border_xoffset = with_border ? priv->left_padding : 0;
screen_dest.x = cursor.x - MAX (within_margin_xoffset, border_xoffset);
}
else if (cursor_right >= screen_inner_right - 1)
{
if (cursor.x >= buffer_right - priv->right_padding)
- border_xoffset = (with_border) ? priv->right_padding : 0;
+ border_xoffset = with_border ? priv->right_padding : 0;
- screen_dest.x = cursor_right - screen_dest.width +
+ screen_dest.x = cursor_right - screen_dest.width -
MAX (within_margin_xoffset, border_xoffset) + 1;
}
}