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.
+2013-12-20 Martin Rudalics <rudalics@gmx.at>
+
+ Fix assignment for new window total sizes.
+ * window.el (window--pixel-to-size): Remove function.
+ (window--pixel-to-total-1, window--pixel-to-total): Fix
+ calculation of new total sizes.
+
2013-12-20 Vitalie Spinu <spinuvit@gmail.com>
* comint.el (comint-output-filter): Fix rear-nonsticky property
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)))
(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)
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.
+2013-12-20 Martin Rudalics <rudalics@gmx.at>
+
+ 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.
+
2013-12-20 Chong Yidong <cyd@gnu.org>
* textprop.c (Fadd_face_text_property): Doc fix. Rename `appendp'
{
new_text_width = (new_width == 0) ? FRAME_TEXT_WIDTH (f) : new_width;
new_text_height = (new_height == 0) ? FRAME_TEXT_HEIGHT (f) : new_height;
+ /* Consider rounding here: Currently, the root window can be
+ larger than the frame in terms of columns/lines. */
new_cols = new_text_width / FRAME_COLUMN_WIDTH (f);
new_lines = new_text_height / FRAME_LINE_HEIGHT (f);
}
fringe columns. Do this after rounding - see discussion of
bug#9723. */
new_root_width = (new_text_width
- /* PXM: Use the configured scrollbar width !?? */
+ FRAME_SCROLL_BAR_AREA_WIDTH (f)
+ FRAME_TOTAL_FRINGE_WIDTH (f));
/* If we're not changing the frame size, quit now. */
doc: /* Return scroll bar width of FRAME in pixels. */)
(Lisp_Object frame)
{
- return make_number (decode_any_frame (frame)->scroll_bar_actual_width);
+ return make_number (FRAME_SCROLL_BAR_AREA_WIDTH (decode_any_frame (frame)));
}
DEFUN ("frame-fringe-width", Ffringe_width, Sfringe_width, 0, 1, 0,
window_prompting |= PSize;
}
- f->scroll_bar_actual_width
- = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
/* This used to be done _before_ calling x_figure_window_size, but
since the height is reset here, this was really a no-op. I
int config_scroll_bar_width;
int config_scroll_bar_cols;
- /* The size of the extra width currently allotted for vertical
- scroll bars in this frame, in pixels. */
- int scroll_bar_actual_width;
-
/* The baud rate that was used to calculate costs for this frame. */
int cost_calculation_baud_rate;
check_frame_size (f, &width, &height, pixelwise);
- f->scroll_bar_actual_width = NS_SCROLL_BAR_WIDTH (f);
compute_fringe_widths (f, 0);
if (pixelwise)
{
return CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE,
/* Position and size of scroll bar. */
- XINT (bar->left), XINT (bar->top),
- XINT (bar->width), XINT (bar->height),
+ bar->left, bar->top, bar->width, bar->height,
FRAME_W32_WINDOW (f), NULL, hinst, NULL);
}
= x_window_to_scroll_bar (WindowFromPoint (pt));
if (bar)
- {
- f1 = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
- }
+ f1 = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
}
if (f1 == 0 && insist > 0)
/* We use the whole scroll-bar height in the calculations below, to
avoid strange effects like scrolling backwards when just clicking
on the handle (without moving it). */
- double range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height))
+ double range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height)
+ VERTICAL_SCROLL_BAR_MIN_HANDLE;
int sb_page, sb_pos;
- BOOL draggingp = !NILP (bar->dragging) ? TRUE : FALSE;
+ BOOL draggingp = bar->dragging ? TRUE : FALSE;
SCROLLINFO si;
/* We used to change the nPage setting while dragging the handle,
HWND hwnd;
SCROLLINFO si;
struct scroll_bar *bar
- = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, fringe_extended_p, PVEC_OTHER);
+ = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, top, PVEC_OTHER);
Lisp_Object barobj;
block_input ();
XSETWINDOW (bar->window, w);
- XSETINT (bar->top, top);
- XSETINT (bar->left, left);
- XSETINT (bar->width, width);
- XSETINT (bar->height, height);
- XSETINT (bar->start, 0);
- XSETINT (bar->end, 0);
- bar->dragging = Qnil;
+ bar->top = top;
+ bar->left = left;
+ bar->width = width;
+ bar->height = height;
+ bar->start = 0;
+ bar->end = 0;
+ bar->dragging = 0;
bar->fringe_extended_p = 0;
/* Requires geometry to be set before call to create the real window */
hwnd = SCROLL_BAR_W32_WINDOW (bar);
/* If already correctly positioned, do nothing. */
- if (XINT (bar->left) == sb_left
- && XINT (bar->top) == top
- && XINT (bar->width) == sb_width
- && XINT (bar->height) == height
+ if (bar->left == sb_left
+ && bar->top == top
+ && bar->width == sb_width
+ && bar->height == height
&& bar->fringe_extended_p == fringe_extended_p)
{
/* Redraw after clear_frame. */
/* InvalidateRect (w, NULL, FALSE); */
/* Remember new settings. */
- XSETINT (bar->left, sb_left);
- XSETINT (bar->top, top);
- XSETINT (bar->width, sb_width);
- XSETINT (bar->height, height);
+ bar->left = sb_left;
+ bar->top = top;
+ bar->width = sb_width;
+ bar->height = height;
unblock_input ();
}
emacs_event->timestamp = msg->msg.time;
{
- int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
+ int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height);
int y;
- int dragging = !NILP (bar->dragging);
+ int dragging = bar->dragging;
SCROLLINFO si;
si.cbSize = sizeof (si);
GetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si);
y = si.nPos;
- bar->dragging = Qnil;
+ bar->dragging = 0;
FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam;
switch (LOWORD (msg->msg.wParam))
break;
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
- if (VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)) <= 0xffff)
+ if (VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height) <= 0xffff)
y = HIWORD (msg->msg.wParam);
- bar->dragging = Qt;
+ bar->dragging = 1; /* ??????? */
emacs_event->part = scroll_bar_handle;
/* "Silently" update current position. */
if (dragging)
{
SCROLLINFO si;
- int start = XINT (bar->start);
- int end = XINT (bar->end);
+ int start = bar->start;
+ int end = bar->end;
si.cbSize = sizeof (si);
si.fMask = SIF_PAGE | SIF_POS;
Window w = SCROLL_BAR_W32_WINDOW (bar);
struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
int pos;
- int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
+ int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height);
SCROLLINFO si;
block_input ();
case SB_THUMBPOSITION:
case SB_THUMBTRACK:
*part = scroll_bar_handle;
- if (VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)) <= 0xffff)
+ if (VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height) <= 0xffff)
pos = HIWORD (dpyinfo->last_mouse_scroll_bar_pos);
break;
case SB_LINEDOWN:
block_input ();
check_frame_size (f, &width, &height, pixelwise);
- f->scroll_bar_actual_width
- = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
compute_fringe_widths (f, 0);
/* The position and size of the scroll bar in pixels, relative to the
frame. */
- Lisp_Object top, left, width, height;
+ int top, left, width, height;
/* The starting and ending positions of the handle, relative to the
handle area (i.e. zero is the top position, not
drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
where they would be normally; the bottom and top are in a
different co-ordinate system. */
- Lisp_Object start, end;
+ int start, end;
/* If the scroll bar handle is currently being dragged by the user,
this is the number of pixels from the top of the handle to the
place where the user grabbed it. If the handle isn't currently
being dragged, this is Qnil. */
- Lisp_Object dragging;
+ int dragging;
/* 1 if the background of the fringe that is adjacent to a scroll
bar is extended to the gap between the fringe and the bar. */
might end up with a frame width that is not a multiple of the
frame's character width which is bad for vertically split
windows. */
- f->scroll_bar_actual_width
- = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
compute_fringe_widths (f, 0);
r->left_col = 0;
r->top_line = FRAME_TOP_MARGIN (f);
window_resize_apply_total (r, !NILP (horizontal));
+ /* Handle the mini window. */
+ if (FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f))
+ {
+ struct window *m = XWINDOW (f->minibuffer_window);
+
+ if (NILP (horizontal))
+ {
+ m->top_line = r->top_line + r->total_lines;
+ m->total_lines = XFASTINT (m->new_total);
+ }
+ else
+ m->total_cols = XFASTINT (m->new_total);
+ }
+
unblock_input ();
return Qt;
int pixelwidth, pixelheight;
check_frame_size (f, &width, &height, pixelwise);
- f->scroll_bar_actual_width
- = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
- ? 0
- : FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f));
compute_fringe_widths (f, 0);
#endif
text_width = FRAME_PIXEL_TO_TEXT_WIDTH (f, FRAME_PIXEL_WIDTH (f));
text_height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, pixelh);
- /* Update f->scroll_bar_actual_width because it is used in
- FRAME_PIXEL_WIDTH_TO_TEXT_COLS. */
- f->scroll_bar_actual_width
- = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
+
change_frame_size (f, text_width, text_height, 0, 1, 0, 1);
}