diff options
| author | Eli Zaretskii | 2014-11-15 19:04:17 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2014-11-15 19:04:17 +0200 |
| commit | 1fb97e79d269d8196811ebb6abdd93d70c95bc5c (patch) | |
| tree | 78607add4b5dc0efc79ba4d3c0a76b2c939c802f /src/window.c | |
| parent | d4fceca9cd0d6f42bd45f4c6e572d1335c9d40dc (diff) | |
| download | emacs-1fb97e79d269d8196811ebb6abdd93d70c95bc5c.tar.gz emacs-1fb97e79d269d8196811ebb6abdd93d70c95bc5c.zip | |
Fix bug #19060 with inaccurate pixel-based scrolling.
src/window.c (window_scroll_pixel_based): Avoid truncation/rounding
errors in computing the number of pixels to scroll. Suggested by
Kelly Dean <kelly@prtime.org>.
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/window.c b/src/window.c index b00242311a6..6938ffb8cb8 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -4955,9 +4955,14 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror) | |||
| 4955 | { | 4955 | { |
| 4956 | int px; | 4956 | int px; |
| 4957 | int dy = frame_line_height; | 4957 | int dy = frame_line_height; |
| 4958 | /* In the below we divide the window box height by the | ||
| 4959 | frame's line height to make the result predictable when | ||
| 4960 | the window box is not an integral multiple of the line | ||
| 4961 | height. This is important to ensure we get back to the | ||
| 4962 | same position when scrolling up, then down. */ | ||
| 4958 | if (whole) | 4963 | if (whole) |
| 4959 | dy = max ((window_box_height (w) | 4964 | dy = max ((window_box_height (w) / dy |
| 4960 | - next_screen_context_lines * dy), | 4965 | - next_screen_context_lines) * dy, |
| 4961 | dy); | 4966 | dy); |
| 4962 | dy *= n; | 4967 | dy *= n; |
| 4963 | 4968 | ||
| @@ -5039,8 +5044,12 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror) | |||
| 5039 | { | 5044 | { |
| 5040 | ptrdiff_t start_pos = IT_CHARPOS (it); | 5045 | ptrdiff_t start_pos = IT_CHARPOS (it); |
| 5041 | int dy = frame_line_height; | 5046 | int dy = frame_line_height; |
| 5042 | dy = max ((window_box_height (w) | 5047 | /* In the below we divide the window box height by the frame's |
| 5043 | - next_screen_context_lines * dy), | 5048 | line height to make the result predictable when the window |
| 5049 | box is not an integral multiple of the line height. This is | ||
| 5050 | important to ensure we get back to the same position when | ||
| 5051 | scrolling up, then down. */ | ||
| 5052 | dy = max ((window_box_height (w) / dy - next_screen_context_lines) * dy, | ||
| 5044 | dy) * n; | 5053 | dy) * n; |
| 5045 | 5054 | ||
| 5046 | /* Note that move_it_vertically always moves the iterator to the | 5055 | /* Note that move_it_vertically always moves the iterator to the |