emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r116189: Fix Fwindow_text_pixel_size and fit-frame-t


From: Martin Rudalics
Subject: [Emacs-diffs] trunk r116189: Fix Fwindow_text_pixel_size and fit-frame-to-buffer.
Date: Tue, 28 Jan 2014 09:46:02 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116189
revision-id: address@hidden
parent: address@hidden
committer: martin rudalics <address@hidden>
branch nick: trunk
timestamp: Tue 2014-01-28 10:45:37 +0100
message:
  Fix Fwindow_text_pixel_size and fit-frame-to-buffer.
  
  * xdisp.c (last_max_ascent): Re-remove after erroneously
  reintroducing it on 2013-11-30 and abolishing Dmitry's removal
  from 2013-03-29.
  (move_it_to): Re-remove reference to last_max_ascent.
  (Fwindow_text_pixel_size): Add iterator's max_ascent and
  max_descent here instead of calling line_bottom_y.  Fix
  doc-string.
  
  * window.el (fit-frame-to-buffer): Fix calculations for margins and
  height constraints.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/window.el                 window.el-20091113204419-o5vbwnq5f7feedwu-94
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/xdisp.c                    xdisp.c-20091113204419-o5vbwnq5f7feedwu-240
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-01-28 07:02:34 +0000
+++ b/lisp/ChangeLog    2014-01-28 09:45:37 +0000
@@ -1,3 +1,8 @@
+2014-01-28  Martin Rudalics  <address@hidden>
+
+       * window.el (fit-frame-to-buffer): Fix calculations for margins and
+       height constraints.
+
 2014-01-28  Luke Lee  <address@hidden>
 
        * progmodes/hideif.el: Extend to full CPP expression syntax.

=== modified file 'lisp/window.el'
--- a/lisp/window.el    2014-01-22 10:29:23 +0000
+++ b/lisp/window.el    2014-01-28 09:45:37 +0000
@@ -6864,20 +6864,30 @@
             ;; Handle margins.
             (margins (or (frame-parameter frame 'fit-frame-to-buffer-margins)
                          fit-frame-to-buffer-margins))
-            (left-margin (or (window--sanitize-margin
-                              (nth 0 margins) 0 display-width)
-                             (nth 0 workarea)))
-            (top-margin (or (window--sanitize-margin
-                             (nth 1 margins) 0 display-height)
-                            (nth 1 workarea)))
+            (left-margin (if (nth 0 margins)
+                             (or (window--sanitize-margin
+                                  (nth 0 margins) 0 display-width)
+                                 0)
+                           (nth 0 workarea)))
+            (top-margin (if (nth 1 margins)
+                            (or (window--sanitize-margin
+                                 (nth 1 margins) 0 display-height)
+                                0)
+                          (nth 1 workarea)))
             (workarea-width (nth 2 workarea))
-            (right-margin (or (window--sanitize-margin
-                               (nth 2 margins) left-margin display-width)
-                              (+ left-margin workarea-width)))
+            (right-margin (if (nth 2 margins)
+                              (- display-width
+                                 (or (window--sanitize-margin
+                                      (nth 2 margins) left-margin 
display-width)
+                                     0))
+                            (nth 2 workarea)))
             (workarea-height (nth 3 workarea))
-            (bottom-margin (or (window--sanitize-margin
-                                (nth 3 margins) top-margin display-height)
-                               (+ top-margin workarea-height)))
+            (bottom-margin (if (nth 3 margins)
+                               (- display-height
+                                  (or (window--sanitize-margin
+                                       (nth 3 margins) top-margin 
display-height)
+                                      0))
+                             (nth 3 workarea)))
             ;; The pixel width of FRAME (which does not include the
             ;; window manager's decorations).
             (frame-width (frame-pixel-width))
@@ -6927,11 +6937,7 @@
                            (not (zerop lines)))
                       (1- lines)
                     0))))
-            ;; The maximum height we can use for fitting.
-            (fit-height
-             (- workarea-height extra-height toolbar-extra-height))
-            ;; The pixel position of FRAME's top border.  We usually
-            ;; try to leave this alone.
+            ;; The pixel position of FRAME's top border.
             (top
              (let ((top (frame-parameter nil 'top)))
                (if (consp top)
@@ -6943,7 +6949,8 @@
             (max-height
              (cond
               ((numberp (nth 0 sizes)) (* (nth 0 sizes) char-height))
-              ((numberp max-height) (* max-height char-height))))
+              ((numberp max-height) (* max-height char-height))
+              (t display-height)))
             (min-height
              (cond
               ((numberp (nth 1 sizes)) (* (nth 1 sizes) char-height))
@@ -6954,7 +6961,8 @@
               ((numberp (nth 2 sizes))
                (- (* (nth 2 sizes) char-width) window-extra-width))
               ((numberp max-width)
-               (- (* max-width char-width) window-extra-width))))
+               (- (* max-width char-width) window-extra-width))
+              (t display-height)))
             (min-width
              (cond
               ((numberp (nth 3 sizes))
@@ -6967,59 +6975,48 @@
             (value (window-text-pixel-size
                     nil t t workarea-width workarea-height t))
             (width (+ (car value) (window-right-divider-width)))
-            (height (+ (cdr value) (window-bottom-divider-width)))
-            remainder)
-       (unless frame-resize-pixelwise
-         ;; Round sizes to character sizes.
-         (setq remainder (% width char-width))
-         (unless (zerop remainder)
-           (setq width (+ width (- char-width remainder))))
-         (setq remainder (% height char-height))
-         (setq height (+ height (- char-height remainder))))
-       ;; Now make sure that we don't get larger than our rounded
-       ;; maximum lines and columns.
-       (when (> width fit-width)
-         (setq width (- fit-width (% fit-width char-width))))
-       (when (> height fit-height)
-         (setq height (- fit-height (% fit-height char-height))))
+            (height (+ (cdr value) (window-bottom-divider-width))))
        ;; Don't change height or width when the window's size is fixed
        ;; in either direction.
        (cond
+        ((eq window-size-fixed 'width)
+         (setq width nil))
         ((eq window-size-fixed 'height)
-         (setq height nil))
-        ((eq window-size-fixed 'width)
          (setq height nil)))
+       ;; Fit width to constraints.
        (when width
+         (unless frame-resize-pixelwise
+           ;; Round to character sizes.
+           (setq width (* (/ (+ width char-width -1) char-width)
+                          char-width)))
          ;; Fit to maximum and minimum widths.
-         (when max-width
-           (setq width (min width max-width)))
-         (when min-width
-           (setq width (max width min-width)))
+         (setq width (max (min width max-width) min-width))
          ;; Add extra width.
          (setq width (+ width extra-width))
-         ;; Preserve right margin.
-         (let ((right (+ left width extra-width)))
+         ;; Preserve margins.
+         (let ((right (+ left width)))
            (cond
             ((> right right-margin)
              ;; Move frame to left (we don't know its real width).
-             (setq left (min (- right-margin display-width) -1)))
+             (setq left (max left-margin (- left (- right right-margin)))))
             ((< left left-margin)
              ;; Move frame to right.
              (setq left left-margin)))))
+       ;; Fit height to constraints.
        (when height
+         (unless frame-resize-pixelwise
+           (setq height (* (/ (+ height char-height -1) char-height)
+                           char-height)))
          ;; Fit to maximum and minimum heights.
-         (when max-height
-           (setq height (min height max-height)))
-         (when min-height
-           (setq height (max height min-height)))
+         (setq height (max (min height max-height) min-height))
          ;; Add extra height.
          (setq height (+ height extra-height))
-         ;; Preserve bottom and top margins.
-         (let ((bottom (+ top height extra-height)))
+         ;; Preserve margins.
+         (let ((bottom (+ top height)))
            (cond
             ((> bottom bottom-margin)
              ;; Move frame up (we don't know its real height).
-             (setq top (min (- bottom-margin display-height) -1)))
+             (setq top (max top-margin (- top (- bottom bottom-margin)))))
             ((< top top-margin)
              ;; Move frame down.
              (setq top top-margin)))))

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-01-28 07:43:24 +0000
+++ b/src/ChangeLog     2014-01-28 09:45:37 +0000
@@ -1,3 +1,13 @@
+2014-01-28  Martin Rudalics  <address@hidden>
+
+       * xdisp.c (last_max_ascent): Re-remove after erroneously
+       reintroducing it on 2013-11-30 and abolishing Dmitry's removal
+       from 2013-03-29.
+       (move_it_to): Re-remove reference to last_max_ascent.
+       (Fwindow_text_pixel_size): Add iterator's max_ascent and
+       max_descent here instead of calling line_bottom_y.  Fix
+       doc-string.
+
 2014-01-28  Dmitry Antipov  <address@hidden>
 
        * terminal.c (initial_free_frame_resources): New function.

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2014-01-25 03:48:29 +0000
+++ b/src/xdisp.c       2014-01-28 09:45:37 +0000
@@ -571,7 +571,7 @@
 
 /* Ascent and height of the last line processed by move_it_to.  */
 
-static int last_max_ascent, last_height;
+static int last_height;
 
 /* Non-zero if there's a help-echo in the echo area.  */
 
@@ -9099,7 +9099,6 @@
       it->current_y += it->max_ascent + it->max_descent;
       ++it->vpos;
       last_height = it->max_ascent + it->max_descent;
-      last_max_ascent = it->max_ascent;
       it->max_ascent = it->max_descent = 0;
     }
 
@@ -9126,7 +9125,6 @@
       it->current_y += it->max_ascent + it->max_descent;
       ++it->vpos;
       last_height = it->max_ascent + it->max_descent;
-      last_max_ascent = it->max_ascent;
     }
 
   if (backup_data)
@@ -9511,7 +9509,7 @@
 include the height of the mode- or header-line of WINDOW in the return
 value.  If it is either the symbol `mode-line' or `header-line', include
 only the height of that line, if present, in the return value.  If t,
-include the height of any of these lines in the return value.  */)
+include the height of both, if present, in the return value.  */)
   (Lisp_Object window, Lisp_Object from, Lisp_Object to, Lisp_Object x_limit, 
Lisp_Object y_limit,
    Lisp_Object mode_and_header_line)
 {
@@ -9579,7 +9577,6 @@
   SET_TEXT_POS (startp, start, CHAR_TO_BYTE (start));
   start_display (&it, w, startp);
 
-  /**   move_it_vertically_backward (&it, 0); **/
   if (NILP (x_limit))
     x = move_it_to (&it, end, -1, max_y, -1, MOVE_TO_POS | MOVE_TO_Y);
   else
@@ -9593,14 +9590,7 @@
                      MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
     }
 
-  if (start == end)
-    y = it.current_y;
-  else
-    {
-      /* Count last line.  */
-      last_height = 0;
-      y = line_bottom_y (&it); /* - y; */
-    }
+  y = it.current_y + it.max_ascent + it.max_descent;
 
   if (!EQ (mode_and_header_line, Qheader_line)
       && !EQ (mode_and_header_line, Qt))


reply via email to

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