From: martin rudalics <rudalics@gmx.at>
To: Bastien <bzg@altern.org>
Cc: 16430@debbugs.gnu.org
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 [thread overview]
Message-ID: <52DC0BDF.5020602@gmx.at> (raw)
In-Reply-To: <878uucgcgc.fsf@bzg.ath.cx>
> 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)))))))))
next prev parent reply other threads:[~2014-01-19 17:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-13 11:39 bug#16430: 24.3.50; When fullscreen is triggered from the window manager, I can't resize window (via M-x org-export RET) Bastien Guerry
2014-01-13 17:52 ` martin rudalics
2014-01-13 19:13 ` Bastien
2014-01-13 19:35 ` martin rudalics
2014-01-13 20:55 ` Bastien
2014-01-14 7:47 ` martin rudalics
2014-01-14 9:50 ` Bastien
2014-01-14 10:45 ` martin rudalics
2014-01-14 16:30 ` Bastien
2014-01-14 18:09 ` martin rudalics
2014-01-14 20:18 ` Bastien
2014-01-15 8:08 ` martin rudalics
2014-01-17 14:19 ` Bastien
2014-01-17 19:07 ` martin rudalics
2014-01-18 12:19 ` martin rudalics
2014-01-19 16:31 ` Bastien
2014-01-19 17:31 ` martin rudalics [this message]
2014-01-20 14:18 ` Bastien
2014-01-20 18:18 ` martin rudalics
2014-01-20 18:25 ` Bastien
2014-01-22 10:35 ` martin rudalics
2014-01-22 11:06 ` Bastien
2014-01-14 20:22 ` Bastien
2014-01-15 8:09 ` martin rudalics
2014-01-17 14:44 ` Bastien
2014-01-14 16:34 ` Bastien
2014-01-14 18:09 ` martin rudalics
2014-01-14 20:32 ` Bastien
2014-01-15 8:09 ` martin rudalics
2014-01-17 14:48 ` Bastien
2014-01-13 20:56 ` Bastien
2014-01-14 7:48 ` martin rudalics
2014-01-14 9:45 ` Bastien
2014-01-22 11:07 ` Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52DC0BDF.5020602@gmx.at \
--to=rudalics@gmx.at \
--cc=16430@debbugs.gnu.org \
--cc=bzg@altern.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.