aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2013-07-06 13:41:38 +0300
committerEli Zaretskii2013-07-06 13:41:38 +0300
commitfdda022055a1dabf52c2f0aa80ed8599e4db3e10 (patch)
tree245901dcda86c61d071e4c36f6f43f020b5585ea /src
parent88c45e34b6626e4deab5e9a139323bf1e4b1c9b3 (diff)
downloademacs-fdda022055a1dabf52c2f0aa80ed8599e4db3e10.tar.gz
emacs-fdda022055a1dabf52c2f0aa80ed8599e4db3e10.zip
Fix bug #14771 with scroll-step = 1 and non-nil line-spacing.
src/xdisp.c (default_line_pixel_height): New function. (pos_visible_p, move_it_vertically_backward, try_scrolling) (try_cursor_movement, redisplay_window, try_window) (try_window_id): Use it instead of FRAME_LINE_HEIGHT. (Bug#14771) src/window.c (window_scroll_pixel_based): use default_line_pixel_height. src/dispextern.h (default_line_pixel_height): Add prototype. src/frame.c (x_set_line_spacing): Accept a float value for line-spacing parameter, per the documentation.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog13
-rw-r--r--src/dispextern.h1
-rw-r--r--src/frame.c9
-rw-r--r--src/window.c12
-rw-r--r--src/xdisp.c127
5 files changed, 127 insertions, 35 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 83d66ee6de6..9bf1840baac 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,18 @@
12013-07-06 Eli Zaretskii <eliz@gnu.org> 12013-07-06 Eli Zaretskii <eliz@gnu.org>
2 2
3 * xdisp.c (default_line_pixel_height): New function.
4 (pos_visible_p, move_it_vertically_backward, try_scrolling)
5 (try_cursor_movement, redisplay_window, try_window)
6 (try_window_id): Use it instead of FRAME_LINE_HEIGHT. (Bug#14771)
7
8 * window.c (window_scroll_pixel_based): use
9 default_line_pixel_height.
10
11 * dispextern.h (default_line_pixel_height): Add prototype.
12
13 * frame.c (x_set_line_spacing): Accept a float value for
14 line-spacing parameter, per the documentation.
15
3 * data.c (Fmultibyte_string_p): Doc fix. 16 * data.c (Fmultibyte_string_p): Doc fix.
4 17
52013-07-05 Paul Eggert <eggert@cs.ucla.edu> 182013-07-05 Paul Eggert <eggert@cs.ucla.edu>
diff --git a/src/dispextern.h b/src/dispextern.h
index 74e59679667..1dd96c6638d 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3116,6 +3116,7 @@ struct glyph_row *row_containing_pos (struct window *, ptrdiff_t,
3116 struct glyph_row *, 3116 struct glyph_row *,
3117 struct glyph_row *, int); 3117 struct glyph_row *, int);
3118int line_bottom_y (struct it *); 3118int line_bottom_y (struct it *);
3119int default_line_pixel_height (struct window *);
3119int display_prop_intangible_p (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t); 3120int display_prop_intangible_p (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t);
3120void resize_echo_area_exactly (void); 3121void resize_echo_area_exactly (void);
3121int resize_mini_window (struct window *, int); 3122int resize_mini_window (struct window *, int);
diff --git a/src/frame.c b/src/frame.c
index ba9074ddebe..6ecc7147c18 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2964,6 +2964,15 @@ x_set_line_spacing (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
2964 f->extra_line_spacing = 0; 2964 f->extra_line_spacing = 0;
2965 else if (RANGED_INTEGERP (0, new_value, INT_MAX)) 2965 else if (RANGED_INTEGERP (0, new_value, INT_MAX))
2966 f->extra_line_spacing = XFASTINT (new_value); 2966 f->extra_line_spacing = XFASTINT (new_value);
2967 else if (FLOATP (new_value))
2968 {
2969 int new_spacing = XFLOAT_DATA (new_value) * FRAME_LINE_HEIGHT (f) + 0.5;
2970
2971 if (new_spacing >= 0)
2972 f->extra_line_spacing = new_spacing;
2973 else
2974 signal_error ("Invalid line-spacing", new_value);
2975 }
2967 else 2976 else
2968 signal_error ("Invalid line-spacing", new_value); 2977 signal_error ("Invalid line-spacing", new_value);
2969 if (FRAME_VISIBLE_P (f)) 2978 if (FRAME_VISIBLE_P (f))
diff --git a/src/window.c b/src/window.c
index 76432f8bb6b..22da72db2b7 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4368,6 +4368,8 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4368 int vscrolled = 0; 4368 int vscrolled = 0;
4369 int x, y, rtop, rbot, rowh, vpos; 4369 int x, y, rtop, rbot, rowh, vpos;
4370 void *itdata = NULL; 4370 void *itdata = NULL;
4371 int window_total_lines;
4372 int frame_line_height = default_line_pixel_height (w);
4371 4373
4372 SET_TEXT_POS_FROM_MARKER (start, w->start); 4374 SET_TEXT_POS_FROM_MARKER (start, w->start);
4373 /* Scrolling a minibuffer window via scroll bar when the echo area 4375 /* Scrolling a minibuffer window via scroll bar when the echo area
@@ -4411,7 +4413,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4411 if (rtop || rbot) /* partially visible */ 4413 if (rtop || rbot) /* partially visible */
4412 { 4414 {
4413 int px; 4415 int px;
4414 int dy = WINDOW_FRAME_LINE_HEIGHT (w); 4416 int dy = frame_line_height;
4415 if (whole) 4417 if (whole)
4416 dy = max ((window_box_height (w) 4418 dy = max ((window_box_height (w)
4417 - next_screen_context_lines * dy), 4419 - next_screen_context_lines * dy),
@@ -4497,7 +4499,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4497 if (whole) 4499 if (whole)
4498 { 4500 {
4499 ptrdiff_t start_pos = IT_CHARPOS (it); 4501 ptrdiff_t start_pos = IT_CHARPOS (it);
4500 int dy = WINDOW_FRAME_LINE_HEIGHT (w); 4502 int dy = frame_line_height;
4501 dy = max ((window_box_height (w) 4503 dy = max ((window_box_height (w)
4502 - next_screen_context_lines * dy), 4504 - next_screen_context_lines * dy),
4503 dy) * n; 4505 dy) * n;
@@ -4614,10 +4616,12 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4614 /* Move PT out of scroll margins. 4616 /* Move PT out of scroll margins.
4615 This code wants current_y to be zero at the window start position 4617 This code wants current_y to be zero at the window start position
4616 even if there is a header line. */ 4618 even if there is a header line. */
4619 window_total_lines
4620 = w->total_lines * WINDOW_FRAME_LINE_HEIGHT (w) / frame_line_height;
4617 this_scroll_margin = max (0, scroll_margin); 4621 this_scroll_margin = max (0, scroll_margin);
4618 this_scroll_margin 4622 this_scroll_margin
4619 = min (this_scroll_margin, w->total_lines / 4); 4623 = min (this_scroll_margin, window_total_lines / 4);
4620 this_scroll_margin *= FRAME_LINE_HEIGHT (it.f); 4624 this_scroll_margin *= frame_line_height;
4621 4625
4622 if (n > 0) 4626 if (n > 0)
4623 { 4627 {
diff --git a/src/xdisp.c b/src/xdisp.c
index ec1dbc454f6..5869ce5fdfa 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1232,6 +1232,52 @@ Value is the height in pixels of the line at point. */)
1232 return make_number (line_bottom_y (&it)); 1232 return make_number (line_bottom_y (&it));
1233} 1233}
1234 1234
1235/* Return the default pixel height of text lines in window W. The
1236 value is the canonical height of the W frame's default font, plus
1237 any extra space required by the line-spacing variable or frame
1238 parameter.
1239
1240 Implementation note: this ignores any line-spacing text properties
1241 put on the newline characters. This is because those properties
1242 only affect the _screen_ line ending in the newline (i.e., in a
1243 continued line, only the last screen line will be affected), which
1244 means only a small number of lines in a buffer can ever use this
1245 feature. Since this function is used to compute the default pixel
1246 equivalent of text lines in a window, we can safely ignore those
1247 few lines. For the same reasons, we ignore the line-height
1248 properties. */
1249int
1250default_line_pixel_height (struct window *w)
1251{
1252 struct frame *f = WINDOW_XFRAME (w);
1253 int height = FRAME_LINE_HEIGHT (f);
1254
1255 if (!FRAME_INITIAL_P (f) && BUFFERP (w->contents))
1256 {
1257 struct buffer *b = XBUFFER (w->contents);
1258 Lisp_Object val = BVAR (b, extra_line_spacing);
1259
1260 if (NILP (val))
1261 val = BVAR (&buffer_defaults, extra_line_spacing);
1262 if (!NILP (val))
1263 {
1264 if (RANGED_INTEGERP (0, val, INT_MAX))
1265 height += XFASTINT (val);
1266 else if (FLOATP (val))
1267 {
1268 int addon = XFLOAT_DATA (val) * height + 0.5;
1269
1270 if (addon >= 0)
1271 height += addon;
1272 }
1273 }
1274 else
1275 height += f->extra_line_spacing;
1276 }
1277
1278 return height;
1279}
1280
1235/* Subroutine of pos_visible_p below. Extracts a display string, if 1281/* Subroutine of pos_visible_p below. Extracts a display string, if
1236 any, from the display spec given as its argument. */ 1282 any, from the display spec given as its argument. */
1237static Lisp_Object 1283static Lisp_Object
@@ -1366,8 +1412,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
1366 struct it save_it = it; 1412 struct it save_it = it;
1367 /* Why 10? because we don't know how many canonical lines 1413 /* Why 10? because we don't know how many canonical lines
1368 will the height of the next line(s) be. So we guess. */ 1414 will the height of the next line(s) be. So we guess. */
1369 int ten_more_lines = 1415 int ten_more_lines = 10 * default_line_pixel_height (w);
1370 10 * FRAME_LINE_HEIGHT (XFRAME (WINDOW_FRAME (w)));
1371 1416
1372 move_it_to (&it, charpos, -1, bottom_y + ten_more_lines, -1, 1417 move_it_to (&it, charpos, -1, bottom_y + ten_more_lines, -1,
1373 MOVE_TO_POS | MOVE_TO_Y); 1418 MOVE_TO_POS | MOVE_TO_Y);
@@ -9056,7 +9101,7 @@ move_it_vertically_backward (struct it *it, int dy)
9056 start_pos = IT_CHARPOS (*it); 9101 start_pos = IT_CHARPOS (*it);
9057 9102
9058 /* Estimate how many newlines we must move back. */ 9103 /* Estimate how many newlines we must move back. */
9059 nlines = max (1, dy / FRAME_LINE_HEIGHT (it->f)); 9104 nlines = max (1, dy / default_line_pixel_height (it->w));
9060 if (it->line_wrap == TRUNCATE) 9105 if (it->line_wrap == TRUNCATE)
9061 pos_limit = BEGV; 9106 pos_limit = BEGV;
9062 else 9107 else
@@ -14536,6 +14581,9 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14536 Lisp_Object aggressive; 14581 Lisp_Object aggressive;
14537 /* We will never try scrolling more than this number of lines. */ 14582 /* We will never try scrolling more than this number of lines. */
14538 int scroll_limit = SCROLL_LIMIT; 14583 int scroll_limit = SCROLL_LIMIT;
14584 int frame_line_height = default_line_pixel_height (w);
14585 int window_total_lines
14586 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height;
14539 14587
14540#ifdef GLYPH_DEBUG 14588#ifdef GLYPH_DEBUG
14541 debug_method_add (w, "try_scrolling"); 14589 debug_method_add (w, "try_scrolling");
@@ -14546,8 +14594,8 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14546 /* Compute scroll margin height in pixels. We scroll when point is 14594 /* Compute scroll margin height in pixels. We scroll when point is
14547 within this distance from the top or bottom of the window. */ 14595 within this distance from the top or bottom of the window. */
14548 if (scroll_margin > 0) 14596 if (scroll_margin > 0)
14549 this_scroll_margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4) 14597 this_scroll_margin = min (scroll_margin, window_total_lines / 4)
14550 * FRAME_LINE_HEIGHT (f); 14598 * frame_line_height;
14551 else 14599 else
14552 this_scroll_margin = 0; 14600 this_scroll_margin = 0;
14553 14601
@@ -14558,19 +14606,19 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14558 if (arg_scroll_conservatively > scroll_limit) 14606 if (arg_scroll_conservatively > scroll_limit)
14559 { 14607 {
14560 arg_scroll_conservatively = scroll_limit + 1; 14608 arg_scroll_conservatively = scroll_limit + 1;
14561 scroll_max = scroll_limit * FRAME_LINE_HEIGHT (f); 14609 scroll_max = scroll_limit * frame_line_height;
14562 } 14610 }
14563 else if (scroll_step || arg_scroll_conservatively || temp_scroll_step) 14611 else if (scroll_step || arg_scroll_conservatively || temp_scroll_step)
14564 /* Compute how much we should try to scroll maximally to bring 14612 /* Compute how much we should try to scroll maximally to bring
14565 point into view. */ 14613 point into view. */
14566 scroll_max = (max (scroll_step, 14614 scroll_max = (max (scroll_step,
14567 max (arg_scroll_conservatively, temp_scroll_step)) 14615 max (arg_scroll_conservatively, temp_scroll_step))
14568 * FRAME_LINE_HEIGHT (f)); 14616 * frame_line_height);
14569 else if (NUMBERP (BVAR (current_buffer, scroll_down_aggressively)) 14617 else if (NUMBERP (BVAR (current_buffer, scroll_down_aggressively))
14570 || NUMBERP (BVAR (current_buffer, scroll_up_aggressively))) 14618 || NUMBERP (BVAR (current_buffer, scroll_up_aggressively)))
14571 /* We're trying to scroll because of aggressive scrolling but no 14619 /* We're trying to scroll because of aggressive scrolling but no
14572 scroll_step is set. Choose an arbitrary one. */ 14620 scroll_step is set. Choose an arbitrary one. */
14573 scroll_max = 10 * FRAME_LINE_HEIGHT (f); 14621 scroll_max = 10 * frame_line_height;
14574 else 14622 else
14575 scroll_max = 0; 14623 scroll_max = 0;
14576 14624
@@ -14585,7 +14633,7 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14585 either that ypos or PT, whichever comes first. */ 14633 either that ypos or PT, whichever comes first. */
14586 start_display (&it, w, startp); 14634 start_display (&it, w, startp);
14587 scroll_margin_y = it.last_visible_y - this_scroll_margin 14635 scroll_margin_y = it.last_visible_y - this_scroll_margin
14588 - FRAME_LINE_HEIGHT (f) * extra_scroll_margin_lines; 14636 - frame_line_height * extra_scroll_margin_lines;
14589 move_it_to (&it, PT, -1, scroll_margin_y - 1, -1, 14637 move_it_to (&it, PT, -1, scroll_margin_y - 1, -1,
14590 (MOVE_TO_POS | MOVE_TO_Y)); 14638 (MOVE_TO_POS | MOVE_TO_Y));
14591 14639
@@ -14597,7 +14645,7 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14597 the user limited scrolling by a small number of lines, but 14645 the user limited scrolling by a small number of lines, but
14598 always finds PT if scroll_conservatively is set to a large 14646 always finds PT if scroll_conservatively is set to a large
14599 number, such as most-positive-fixnum. */ 14647 number, such as most-positive-fixnum. */
14600 int slack = max (scroll_max, 10 * FRAME_LINE_HEIGHT (f)); 14648 int slack = max (scroll_max, 10 * frame_line_height);
14601 int y_to_move = it.last_visible_y + slack; 14649 int y_to_move = it.last_visible_y + slack;
14602 14650
14603 /* Compute the distance from the scroll margin to PT or to 14651 /* Compute the distance from the scroll margin to PT or to
@@ -14624,8 +14672,8 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14624 move it down by scroll_step. */ 14672 move it down by scroll_step. */
14625 if (arg_scroll_conservatively) 14673 if (arg_scroll_conservatively)
14626 amount_to_scroll 14674 amount_to_scroll
14627 = min (max (dy, FRAME_LINE_HEIGHT (f)), 14675 = min (max (dy, frame_line_height),
14628 FRAME_LINE_HEIGHT (f) * arg_scroll_conservatively); 14676 frame_line_height * arg_scroll_conservatively);
14629 else if (scroll_step || temp_scroll_step) 14677 else if (scroll_step || temp_scroll_step)
14630 amount_to_scroll = scroll_max; 14678 amount_to_scroll = scroll_max;
14631 else 14679 else
@@ -14722,7 +14770,7 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14722 start_display (&it, w, pos); 14770 start_display (&it, w, pos);
14723 y0 = it.current_y; 14771 y0 = it.current_y;
14724 y_to_move = max (it.last_visible_y, 14772 y_to_move = max (it.last_visible_y,
14725 max (scroll_max, 10 * FRAME_LINE_HEIGHT (f))); 14773 max (scroll_max, 10 * frame_line_height));
14726 move_it_to (&it, CHARPOS (scroll_margin_pos), 0, 14774 move_it_to (&it, CHARPOS (scroll_margin_pos), 0,
14727 y_to_move, -1, 14775 y_to_move, -1,
14728 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); 14776 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
@@ -14738,7 +14786,7 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14738 start_display (&it, w, startp); 14786 start_display (&it, w, startp);
14739 14787
14740 if (arg_scroll_conservatively) 14788 if (arg_scroll_conservatively)
14741 amount_to_scroll = max (dy, FRAME_LINE_HEIGHT (f) * 14789 amount_to_scroll = max (dy, frame_line_height *
14742 max (scroll_step, temp_scroll_step)); 14790 max (scroll_step, temp_scroll_step));
14743 else if (scroll_step || temp_scroll_step) 14791 else if (scroll_step || temp_scroll_step)
14744 amount_to_scroll = scroll_max; 14792 amount_to_scroll = scroll_max;
@@ -14958,6 +15006,9 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
14958 { 15006 {
14959 int this_scroll_margin, top_scroll_margin; 15007 int this_scroll_margin, top_scroll_margin;
14960 struct glyph_row *row = NULL; 15008 struct glyph_row *row = NULL;
15009 int frame_line_height = default_line_pixel_height (w);
15010 int window_total_lines
15011 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height;
14961 15012
14962#ifdef GLYPH_DEBUG 15013#ifdef GLYPH_DEBUG
14963 debug_method_add (w, "cursor movement"); 15014 debug_method_add (w, "cursor movement");
@@ -14967,8 +15018,8 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
14967 of the window. This is a pixel value. */ 15018 of the window. This is a pixel value. */
14968 if (scroll_margin > 0) 15019 if (scroll_margin > 0)
14969 { 15020 {
14970 this_scroll_margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4); 15021 this_scroll_margin = min (scroll_margin, window_total_lines / 4);
14971 this_scroll_margin *= FRAME_LINE_HEIGHT (f); 15022 this_scroll_margin *= frame_line_height;
14972 } 15023 }
14973 else 15024 else
14974 this_scroll_margin = 0; 15025 this_scroll_margin = 0;
@@ -15310,6 +15361,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15310 int centering_position = -1; 15361 int centering_position = -1;
15311 int last_line_misfit = 0; 15362 int last_line_misfit = 0;
15312 ptrdiff_t beg_unchanged, end_unchanged; 15363 ptrdiff_t beg_unchanged, end_unchanged;
15364 int frame_line_height;
15313 15365
15314 SET_TEXT_POS (lpoint, PT, PT_BYTE); 15366 SET_TEXT_POS (lpoint, PT, PT_BYTE);
15315 opoint = lpoint; 15367 opoint = lpoint;
@@ -15324,6 +15376,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15324 15376
15325 restart: 15377 restart:
15326 reconsider_clip_changes (w, buffer); 15378 reconsider_clip_changes (w, buffer);
15379 frame_line_height = default_line_pixel_height (w);
15327 15380
15328 /* Has the mode line to be updated? */ 15381 /* Has the mode line to be updated? */
15329 update_mode_line = (w->update_mode_line 15382 update_mode_line = (w->update_mode_line
@@ -15559,8 +15612,10 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15559 /* Some people insist on not letting point enter the scroll 15612 /* Some people insist on not letting point enter the scroll
15560 margin, even though this part handles windows that didn't 15613 margin, even though this part handles windows that didn't
15561 scroll at all. */ 15614 scroll at all. */
15562 int margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4); 15615 int window_total_lines
15563 int pixel_margin = margin * FRAME_LINE_HEIGHT (f); 15616 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height;
15617 int margin = min (scroll_margin, window_total_lines / 4);
15618 int pixel_margin = margin * frame_line_height;
15564 bool header_line = WINDOW_WANTS_HEADER_LINE_P (w); 15619 bool header_line = WINDOW_WANTS_HEADER_LINE_P (w);
15565 15620
15566 /* Note: We add an extra FRAME_LINE_HEIGHT, because the loop 15621 /* Note: We add an extra FRAME_LINE_HEIGHT, because the loop
@@ -15571,7 +15626,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15571 new_vpos 15626 new_vpos
15572 = pixel_margin + (header_line 15627 = pixel_margin + (header_line
15573 ? CURRENT_HEADER_LINE_HEIGHT (w) 15628 ? CURRENT_HEADER_LINE_HEIGHT (w)
15574 : 0) + FRAME_LINE_HEIGHT (f); 15629 : 0) + frame_line_height;
15575 else 15630 else
15576 { 15631 {
15577 int window_height = window_box_height (w); 15632 int window_height = window_box_height (w);
@@ -15820,9 +15875,11 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15820 it.current_y = it.last_visible_y; 15875 it.current_y = it.last_visible_y;
15821 if (centering_position < 0) 15876 if (centering_position < 0)
15822 { 15877 {
15878 int window_total_lines
15879 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height;
15823 int margin = 15880 int margin =
15824 scroll_margin > 0 15881 scroll_margin > 0
15825 ? min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4) 15882 ? min (scroll_margin, window_total_lines / 4)
15826 : 0; 15883 : 0;
15827 ptrdiff_t margin_pos = CHARPOS (startp); 15884 ptrdiff_t margin_pos = CHARPOS (startp);
15828 Lisp_Object aggressive; 15885 Lisp_Object aggressive;
@@ -15844,7 +15901,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15844 15901
15845 SAVE_IT (it1, it, it1data); 15902 SAVE_IT (it1, it, it1data);
15846 start_display (&it1, w, startp); 15903 start_display (&it1, w, startp);
15847 move_it_vertically (&it1, margin * FRAME_LINE_HEIGHT (f)); 15904 move_it_vertically (&it1, margin * frame_line_height);
15848 margin_pos = IT_CHARPOS (it1); 15905 margin_pos = IT_CHARPOS (it1);
15849 RESTORE_IT (&it, &it, it1data); 15906 RESTORE_IT (&it, &it, it1data);
15850 } 15907 }
@@ -15880,15 +15937,15 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15880 if (pt_offset) 15937 if (pt_offset)
15881 centering_position -= pt_offset; 15938 centering_position -= pt_offset;
15882 centering_position -= 15939 centering_position -=
15883 FRAME_LINE_HEIGHT (f) * (1 + margin + (last_line_misfit != 0)) 15940 frame_line_height * (1 + margin + (last_line_misfit != 0))
15884 + WINDOW_HEADER_LINE_HEIGHT (w); 15941 + WINDOW_HEADER_LINE_HEIGHT (w);
15885 /* Don't let point enter the scroll margin near top of 15942 /* Don't let point enter the scroll margin near top of
15886 the window. */ 15943 the window. */
15887 if (centering_position < margin * FRAME_LINE_HEIGHT (f)) 15944 if (centering_position < margin * frame_line_height)
15888 centering_position = margin * FRAME_LINE_HEIGHT (f); 15945 centering_position = margin * frame_line_height;
15889 } 15946 }
15890 else 15947 else
15891 centering_position = margin * FRAME_LINE_HEIGHT (f) + pt_offset; 15948 centering_position = margin * frame_line_height + pt_offset;
15892 } 15949 }
15893 else 15950 else
15894 /* Set the window start half the height of the window backward 15951 /* Set the window start half the height of the window backward
@@ -15993,11 +16050,13 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15993 make that row fully visible and out of the margin. */ 16050 make that row fully visible and out of the margin. */
15994 if (scroll_conservatively > SCROLL_LIMIT) 16051 if (scroll_conservatively > SCROLL_LIMIT)
15995 { 16052 {
16053 int window_total_lines
16054 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) * frame_line_height;
15996 int margin = 16055 int margin =
15997 scroll_margin > 0 16056 scroll_margin > 0
15998 ? min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4) 16057 ? min (scroll_margin, window_total_lines / 4)
15999 : 0; 16058 : 0;
16000 int move_down = w->cursor.vpos >= WINDOW_TOTAL_LINES (w) / 2; 16059 int move_down = w->cursor.vpos >= window_total_lines / 2;
16001 16060
16002 move_it_by_lines (&it, move_down ? margin + 1 : -(margin + 1)); 16061 move_it_by_lines (&it, move_down ? margin + 1 : -(margin + 1));
16003 clear_glyph_matrix (w->desired_matrix); 16062 clear_glyph_matrix (w->desired_matrix);
@@ -16184,6 +16243,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
16184 struct it it; 16243 struct it it;
16185 struct glyph_row *last_text_row = NULL; 16244 struct glyph_row *last_text_row = NULL;
16186 struct frame *f = XFRAME (w->frame); 16245 struct frame *f = XFRAME (w->frame);
16246 int frame_line_height = default_line_pixel_height (w);
16187 16247
16188 /* Make POS the new window start. */ 16248 /* Make POS the new window start. */
16189 set_marker_both (w->start, Qnil, CHARPOS (pos), BYTEPOS (pos)); 16249 set_marker_both (w->start, Qnil, CHARPOS (pos), BYTEPOS (pos));
@@ -16209,11 +16269,13 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
16209 && !MINI_WINDOW_P (w)) 16269 && !MINI_WINDOW_P (w))
16210 { 16270 {
16211 int this_scroll_margin; 16271 int this_scroll_margin;
16272 int window_total_lines
16273 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height;
16212 16274
16213 if (scroll_margin > 0) 16275 if (scroll_margin > 0)
16214 { 16276 {
16215 this_scroll_margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4); 16277 this_scroll_margin = min (scroll_margin, window_total_lines / 4);
16216 this_scroll_margin *= FRAME_LINE_HEIGHT (f); 16278 this_scroll_margin *= frame_line_height;
16217 } 16279 }
16218 else 16280 else
16219 this_scroll_margin = 0; 16281 this_scroll_margin = 0;
@@ -17514,10 +17576,13 @@ try_window_id (struct window *w)
17514 /* Don't let the cursor end in the scroll margins. */ 17576 /* Don't let the cursor end in the scroll margins. */
17515 { 17577 {
17516 int this_scroll_margin, cursor_height; 17578 int this_scroll_margin, cursor_height;
17579 int frame_line_height = default_line_pixel_height (w);
17580 int window_total_lines
17581 = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (it.f) / frame_line_height;
17517 17582
17518 this_scroll_margin = 17583 this_scroll_margin =
17519 max (0, min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4)); 17584 max (0, min (scroll_margin, window_total_lines / 4));
17520 this_scroll_margin *= FRAME_LINE_HEIGHT (it.f); 17585 this_scroll_margin *= frame_line_height;
17521 cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height; 17586 cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height;
17522 17587
17523 if ((w->cursor.y < this_scroll_margin 17588 if ((w->cursor.y < this_scroll_margin