bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#16430: 24.3.50; When fullscreen is triggered from the window manager


From: martin rudalics
Subject: bug#16430: 24.3.50; When fullscreen is triggered from the window manager, I can't resize window (via M-x org-export RET)
Date: Sun, 19 Jan 2014 18:31:11 +0100

> With two windows on a wm-fullscreened frame:
> ============================================
>
> frame pixel: 1366 x 768   cols/lines: 151 x 42   units: 9 x 18
> frame text pixel: 1348 x 768   cols/lines: 149 x 42
...
> #<window 31>   parent: nil
> pixel left: 0   top: 0   size: 1366 x 750   new: 750
...
> #<window 26 on *unsent wide reply to martin rudalics*>   parent: #<window 31>
> pixel left: 0   top: 0   size: 1366 x 372   new: 372
...
> #<window 32 on *unsent wide reply to martin rudalics*>   parent: #<window 31>
> pixel left: 0   top: 372   size: 1366 x 378   new: 378
...
> With two windows on a emacs-fullscreened frame:
> ===============================================
>
> frame pixel: 1362 x 746   cols/lines: 151 x 41   units: 9 x 18
> frame text pixel: 1344 x 746   cols/lines: 149 x 41
...
> #<window 33>   parent: nil
> pixel left: 0   top: 0   size: 1362 x 728   new: 1362
...
> #<window 26 on *unsent wide reply to martin rudalics*>   parent: #<window 33>
> pixel left: 0   top: 0   size: 1362 x 364   new: 1362
...
> #<window 34 on *unsent wide reply to martin rudalics*>   parent: #<window 33>
> pixel left: 0   top: 364   size: 1362 x 364   new: 1362
...

All these sum up well: 372 + 378 = 750 for the wm- and 364 + 364 = 728
for the emacs-fullscreened frame.

What I now need is a bit more hairy:

(1) You need frame-dump and window-dump evaluated.

(2) Put the definition of `fit-window-to-buffer' below into say
   *scratch* and evaluate it.

(3) Now do the usual dance to provoke the error in wm- and
    emacs-fullscreen.

Post the two *frame-dump*s here.

Thanks, martin


(defun fit-window-to-buffer (&optional window max-height min-height max-width 
min-width)
  "Adjust size of WINDOW to display its buffer's contents exactly.
WINDOW must be a live window and defaults to the selected one.

If WINDOW is part of a vertical combination, adjust WINDOW's
height.  The new height is calculated from the number of lines of
the accessible portion of its buffer.  The optional argument
MAX-HEIGHT specifies a maximum height and defaults to the height
of WINDOW's frame.  The optional argument MIN-HEIGHT specifies a
minimum height and defaults to `window-min-height'.  Both
MAX-HEIGHT and MIN-HEIGHT are specified in lines and include the
mode line and header line, if any.

If WINDOW is part of a horizontal combination and the value of
the option `fit-window-to-buffer-horizontally' is non-nil, adjust
WINDOW's height.  The new width of WINDOW is calculated from the
maximum length of its buffer's lines that follow the current
start position of WINDOW.  The optional argument MAX-WIDTH
specifies a maximum width and defaults to the width of WINDOW's
frame.  The optional argument MIN-WIDTH specifies a minimum width
and defaults to `window-min-width'.  Both MAX-WIDTH and MIN-WIDTH
are specified in columns and include fringes, margins and
scrollbars, if any.

Fit pixelwise if the option `window-resize-pixelwise' is non-nil.
If WINDOW is its frame's root window, then if the option
`fit-frame-to-buffer' is non-nil, call `fit-frame-to-buffer' to
adjust the frame's size.

Note that even if this function makes WINDOW large enough to show
_all_ parts of its buffer you might not see the first part when
WINDOW was scrolled.  If WINDOW is resized horizontally, you will
not see the top of its buffer unless WINDOW starts at its minimum
accessible position."
  (interactive)
  (setq window (window-normalize-window window t))
  (if (eq window (frame-root-window window))
      (when fit-frame-to-buffer
        ;; Fit WINDOW's frame to buffer.
        (fit-frame-to-buffer
         (window-frame window)
         max-height min-height max-width min-width))
    (with-selected-window window
      (let* ((pixelwise window-resize-pixelwise)
             (char-height (frame-char-height))
             (char-width (frame-char-width))
             (total-height (window-size window nil pixelwise))
             (body-height (window-body-height window pixelwise))
             (body-width (window-body-width window pixelwise))
             (min-height
              ;; Sanitize MIN-HEIGHT.
              (if (numberp min-height)
                  ;; Can't get smaller than `window-safe-min-height'.
                  (max (if pixelwise
                           (* char-height min-height)
                         min-height)
                       (if pixelwise
                           (window-safe-min-pixel-height window)
                         window-safe-min-height))
                ;; Preserve header and mode line if present.
                (max (if pixelwise
                         (* char-height window-min-height)
                       window-min-height)
                     (window-min-size nil nil t pixelwise))))
             (max-height
              ;; Sanitize MAX-HEIGHT.
              (if (numberp max-height)
                  (min
                   (+ total-height
                      (window-max-delta
                       window nil nil nil nil nil pixelwise))
                   (if pixelwise
                       (* char-height max-height)
                     max-height))
                (+ total-height (window-max-delta
                                 window nil nil nil nil nil pixelwise))))
             height)
        (cond
         ;; If WINDOW is vertically combined, try to resize it
         ;; vertically.
         ((and (not (eq fit-window-to-buffer-horizontally 'only))
               (not (window-size-fixed-p window))
               (window-combined-p))
          ;; Vertically we always want to fit the entire buffer.
          ;; WINDOW'S height can't get larger than its frame's pixel
          ;; height.  Its width remains fixed.
          (setq height (+ (cdr (window-text-pixel-size
                                nil nil t nil (frame-pixel-height) t))
                          (window-bottom-divider-width)))
          ;; Round height.
          (unless pixelwise
            (setq height (+ (/ height char-height)
                            (if (zerop (% height char-height)) 0 1))))
          (unless (= height total-height)
            (frame-dump (window-frame window))
            (with-current-buffer "*frame-dump*"
              (goto-char (point-max))
              (insert
               (format "\n\nwindow %s height %s"
                       window (- (max min-height (min max-height height)) 
total-height))))
            (window-resize-no-error
             window
             (- (max min-height (min max-height height)) total-height)
             nil window pixelwise)))
         ;; If WINDOW is horizontally combined, try to resize it
         ;; horizontally.
         ((and fit-window-to-buffer-horizontally
               (not (window-size-fixed-p window t))
               (window-combined-p nil t))
          (let* ((total-width (window-size window nil pixelwise))
                 (min-width
                  ;; Sanitize MIN-WIDTH.
                  (if (numberp min-width)
                      ;; Can't get smaller than `window-safe-min-width'.
                      (max (if pixelwise
                               (* char-width min-width)
                             min-width)
                           (if pixelwise
                               (window-safe-min-pixel-width)
                             window-safe-min-width))
                    ;; Preserve fringes, margins, scrollbars if present.
                    (max (if pixelwise
                             (* char-width window-min-width)
                           window-min-width)
                         (window-min-size nil nil t pixelwise))))
                 (max-width
                  ;; Sanitize MAX-WIDTH.
                  (if (numberp max-width)
                      (min (+ total-width
                              (window-max-delta
                               nil t nil nil nil nil pixelwise))
                           (if pixelwise
                               (* char-width max-width)
                             max-width))
                    (+ total-width (window-max-delta
                                    nil t nil nil nil nil pixelwise))))
                 ;; When fitting vertically, assume that WINDOW's start
                 ;; position remains unaltered.  WINDOW can't get wider
                 ;; than its frame's pixel width, its height remains
                 ;; unaltered.
                 (width (+ (car (window-text-pixel-size
                                 nil (window-start) (point-max)
                                 (frame-pixel-width)
                                 ;; Add one char-height to assure that
                                 ;; we're on the safe side.  This
                                 ;; overshoots when the first line below
                                 ;; the bottom is wider than the window.
                                 (* body-height
                                    (if pixelwise char-height 1))))
                           (window-right-divider-width))))
            (unless pixelwise
              (setq width (+ (/ width char-width)
                             (if (zerop (% width char-width)) 0 1))))
            (unless (= width body-width)
              (window-resize-no-error
               window
               (- (max min-width
                       (min max-width
                            (+ total-width (- width body-width))))
                  total-width)
               t window pixelwise)))))))))





reply via email to

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