emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] [emacs] 01/01: Fix bug #19060 with inaccurate pixel-based


From: Eli Zaretskii
Subject: [Emacs-diffs] [emacs] 01/01: Fix bug #19060 with inaccurate pixel-based scrolling.
Date: Sat, 15 Nov 2014 17:06:20 +0000

eliz pushed a commit to branch emacs-24
in repository emacs.

commit 1fb97e79d269d8196811ebb6abdd93d70c95bc5c
Author: Eli Zaretskii <address@hidden>
Date:   Sat Nov 15 19:04:17 2014 +0200

    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 <address@hidden>.
---
 src/ChangeLog |    6 ++++++
 src/window.c  |   17 +++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index b431dd2..2ea5d29 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2014-11-15  Eli Zaretskii  <address@hidden>
+
+       * window.c (window_scroll_pixel_based): Avoid truncation/rounding
+       errors in computing the number of pixels to scroll.  Suggested by
+       Kelly Dean <address@hidden>.  (Bug#19060)
+
 2014-11-15  Jan Djärv  <address@hidden>
 
        * nsmenu.m (update_frame_tool_bar): If tool bar changes height,
diff --git a/src/window.c b/src/window.c
index b002423..6938ffb 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)
        {
          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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]