]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug #19060 with inaccurate pixel-based scrolling.
authorEli Zaretskii <eliz@gnu.org>
Sat, 15 Nov 2014 17:04:17 +0000 (19:04 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 15 Nov 2014 17:04:17 +0000 (19:04 +0200)
 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>.

src/ChangeLog
src/window.c

index b431dd255a986e3e539f8d63a0aa51cd082faa6e..2ea5d29d3b28944b19f048bb866854c03b92ff8f 100644 (file)
@@ -1,3 +1,9 @@
+2014-11-15  Eli Zaretskii  <eliz@gnu.org>
+
+       * 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>.  (Bug#19060)
+
 2014-11-15  Jan Djärv  <jan.h.d@swipnet.se>
 
        * nsmenu.m (update_frame_tool_bar): If tool bar changes height,
index b00242311a6deb05a22ba616876c7e9e789150f5..6938ffb8cb850461f0e171454fe0ed6aaaf0aaa6 100644 (file)
@@ -4955,9 +4955,14 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
        {
          int px;
          int dy = frame_line_height;
+         /* In the below we divide the window box height by the
+            frame's line height to make the result predictable when
+            the window box is not an integral multiple of the line
+            height.  This is important to ensure we get back to the
+            same position when scrolling up, then down.  */
          if (whole)
-           dy = max ((window_box_height (w)
-                      - next_screen_context_lines * dy),
+           dy = max ((window_box_height (w) / dy
+                      - next_screen_context_lines) * dy,
                      dy);
          dy *= n;
 
@@ -5039,8 +5044,12 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
     {
       ptrdiff_t start_pos = IT_CHARPOS (it);
       int dy = frame_line_height;
-      dy = max ((window_box_height (w)
-                - next_screen_context_lines * dy),
+      /* In the below we divide the window box height by the frame's
+        line height to make the result predictable when the window
+        box is not an integral multiple of the line height.  This is
+        important to ensure we get back to the same position when
+        scrolling up, then down.  */
+      dy = max ((window_box_height (w) / dy - next_screen_context_lines) * dy,
                dy) * n;
 
       /* Note that move_it_vertically always moves the iterator to the