summaryrefslogtreecommitdiff
path: root/lisp/window.el
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2013-12-20 11:48:36 +0100
committerMartin Rudalics <rudalics@gmx.at>2013-12-20 11:48:36 +0100
commitc44de18d7db9c038473c71d0708990c3b081402f (patch)
tree14837bdee5bcc328b1b0d61b2f0a5d8e369a33a8 /lisp/window.el
parentd506bc1d20baf7ed991b01cede719791778a53c7 (diff)
downloademacs-c44de18d7db9c038473c71d0708990c3b081402f.tar.gz
Some more fixes for pixelwise resizing.
Remove scroll_bar_actual_width from frames. * frame.h (struct frame): Remove scroll_bar_actual_width slot. * frame.c (Fscroll_bar_width): Return scroll bar area width. (x_figure_window_size): * nsterm.m (x_set_window_size): * widget.c (set_frame_size): * w32term.c (x_set_window_size): * xterm.c (x_set_window_size, x_set_window_size_1): Don't set scroll_bar_actual_width. Convert scroll_bar members to integers on Windows. * w32term.h (struct scroll_bar): Convert top, left, width, height, start, end and dragging to integers. * w32fns.c (w32_createscrollbar): Remove XINT conversions for scroll_bar members. * w32term.c (w32_set_scroll_bar_thumb) (w32_scroll_bar_handle_click): Remove XINT conversions for scroll_bar members. Treat bar->dragging as integer. (x_scroll_bar_create): Call ALLOCATE_PSEUDOVECTOR with "top" as first element. Remove XINT conversions for scroll_bar members. (w32_set_vertical_scroll_bar, x_scroll_bar_report_motion): Remove XINT conversions for scroll_bar members. Fix assignment for new window total sizes. * window.c (Fwindow_resize_apply_total): Assign values for minibuffer window. * window.el (window--pixel-to-size): Remove function. (window--pixel-to-total-1, window--pixel-to-total): Fix calculation of new total sizes.
Diffstat (limited to 'lisp/window.el')
-rw-r--r--lisp/window.el73
1 files changed, 42 insertions, 31 deletions
diff --git a/lisp/window.el b/lisp/window.el
index ffc12930728..3b841747205 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2079,30 +2079,16 @@ WINDOW's frame if the option `window-resize-pixelwise' is nil."
size)
(* size char-size))))
-(defun window--pixel-to-size (window size &optional horizontal round-up)
- "For WINDOW convert SIZE pixels to lines.
-WINDOW must be a valid window and defaults to the selected one.
-Optional argument HORIZONTAL non-nil means convert SIZE pixels to
-columns. Optional argument ROUND-UP means to round up the return
-value."
- (let ((char-size (frame-char-size
- (window-normalize-window window) horizontal)))
- (if round-up
- (/ (+ size char-size -1) char-size)
- (/ size char-size))))
-
(defun window--pixel-to-total-1 (window horizontal char-size)
"Subroutine of `window--pixel-to-total'."
(let ((child (window-child window)))
(if (window-combination-p window horizontal)
;; In an iso-combination distribute sizes proportionally.
(let ((remainder (window-new-total window))
- size best-child best-size)
+ size best-child rem best-rem)
;; Initialize total sizes to each child's floor.
(while child
- (setq size (window--pixel-to-size
- child (window-size child horizontal t)
- horizontal))
+ (setq size (max (/ (window-size child horizontal t) char-size) 1))
(set-window-new-total child size)
(setq remainder (- remainder size))
(setq child (window-next-sibling child)))
@@ -2110,15 +2096,15 @@ value."
(while (> remainder 0)
(setq child (window-last-child window))
(setq best-child nil)
- (setq best-size 0)
- ;; We want those auxiliary fields in the window structure to
- ;; avoid this.
+ (setq best-rem 0)
(while child
- (setq size (- (/ (window-size child horizontal t) char-size)
- (window-new-total child)))
- (when (> size best-size)
- (setq best-child child)
- (setq best-size size))
+ (when (and (<= (window-new-total child)
+ (/ (window-size child horizontal t) char-size))
+ (> (setq rem (% (window-size child horizontal t)
+ char-size))
+ best-rem))
+ (setq best-child child)
+ (setq best-rem rem))
(setq child (window-prev-sibling child)))
;; We MUST have a best-child here.
(set-window-new-total best-child 1 t)
@@ -2142,14 +2128,39 @@ FRAME must be a live frame and defaults to the selected frame.
Optional argument HORIZONTAL non-nil means assign new total
window widths from pixel widths."
(setq frame (window-normalize-frame frame))
- (let ((root (frame-root-window))
- (char-size (frame-char-size frame horizontal)))
- (set-window-new-total
- root (window--pixel-to-size
- root (window-size root horizontal t) horizontal))
+ (let* ((char-size (frame-char-size frame horizontal))
+ (root (frame-root-window))
+ (root-size (window-size root horizontal t))
+ ;; We have to care about the minibuffer window only if it
+ ;; appears together with the root window on this frame.
+ (mini (let ((mini (minibuffer-window frame)))
+ (and (eq (window-frame mini) frame)
+ (not (eq mini root)) mini)))
+ (mini-size (and mini (window-size mini horizontal t))))
+ ;; We round the line/column sizes of windows here to the nearest
+ ;; integer. In some cases this can make windows appear _larger_
+ ;; than the containing frame (line/column-wise) because the latter's
+ ;; sizes are not (yet) rounded. We might eventually fix that.
+ (if (and mini (not horizontal))
+ (let (lines)
+ (set-window-new-total root (max (/ root-size char-size) 1))
+ (set-window-new-total mini (max (/ mini-size char-size) 1))
+ (setq lines (- (round (+ root-size mini-size) char-size)
+ (+ (window-new-total root) (window-new-total mini))))
+ (while (> lines 0)
+ (if (>= (% root-size (window-new-total root))
+ (% mini-size (window-new-total mini)))
+ (set-window-new-total root 1 t)
+ (set-window-new-total mini 1 t))
+ (setq lines (1- lines))))
+ (set-window-new-total root (round root-size char-size))
+ (when mini
+ ;; This is taken in the horizontal case only.
+ (set-window-new-total mini (round mini-size char-size))))
(unless (window-buffer root)
- (window--pixel-to-total-1 root horizontal char-size)))
- (window-resize-apply-total frame horizontal))
+ (window--pixel-to-total-1 root horizontal char-size))
+ ;; Apply the new sizes.
+ (window-resize-apply-total frame horizontal)))
(defun window--resize-reset (&optional frame horizontal)
"Reset resize values for all windows on FRAME.