From: Martin Rudalics Date: Fri, 20 Dec 2013 10:48:36 +0000 (+0100) Subject: Some more fixes for pixelwise resizing. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~306 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c44de18d7db9c038473c71d0708990c3b081402f;p=emacs.git 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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2e0db47df47..00e0864a5fd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2013-12-20 Martin Rudalics + + 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 * comint.el (comint-output-filter): Fix rear-nonsticky property 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. diff --git a/src/ChangeLog b/src/ChangeLog index 23857e33a6d..dbb77ae1646 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,32 @@ +2013-12-20 Martin Rudalics + + 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 * textprop.c (Fadd_face_text_property): Doc fix. Rename `appendp' diff --git a/src/dispnew.c b/src/dispnew.c index 967fffe469b..cbf1963feca 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -5488,6 +5488,8 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height, { 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); } @@ -5507,7 +5509,6 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height, 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. */ diff --git a/src/frame.c b/src/frame.c index 7699f24fbb1..25e0f2727ca 100644 --- a/src/frame.c +++ b/src/frame.c @@ -2515,7 +2515,7 @@ DEFUN ("frame-scroll-bar-width", Fscroll_bar_width, Sscroll_bar_width, 0, 1, 0, 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, @@ -4237,8 +4237,6 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p) 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 diff --git a/src/frame.h b/src/frame.h index f9b368fb5ec..d7bbbd0686b 100644 --- a/src/frame.h +++ b/src/frame.h @@ -436,10 +436,6 @@ struct frame 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; diff --git a/src/nsterm.m b/src/nsterm.m index 8047bca1f60..10780b054d9 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1289,7 +1289,6 @@ x_set_window_size (struct frame *f, check_frame_size (f, &width, &height, pixelwise); - f->scroll_bar_actual_width = NS_SCROLL_BAR_WIDTH (f); compute_fringe_widths (f, 0); if (pixelwise) diff --git a/src/w32fns.c b/src/w32fns.c index 73197c6a8f2..59526936afe 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -1912,8 +1912,7 @@ w32_createscrollbar (struct frame *f, struct scroll_bar * bar) { 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); } diff --git a/src/w32term.c b/src/w32term.c index a66aca1e846..a39ab37768c 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -3451,9 +3451,7 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, = 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) @@ -3560,10 +3558,10 @@ w32_set_scroll_bar_thumb (struct scroll_bar *bar, /* 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, @@ -3708,19 +3706,19 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height) 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 */ @@ -3838,10 +3836,10 @@ w32_set_vertical_scroll_bar (struct window *w, 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. */ @@ -3883,10 +3881,10 @@ w32_set_vertical_scroll_bar (struct window *w, /* 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 (); } @@ -4026,9 +4024,9 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg, 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); @@ -4037,7 +4035,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg, 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)) @@ -4064,9 +4062,9 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg, 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. */ @@ -4090,8 +4088,8 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg, 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; @@ -4126,7 +4124,7 @@ x_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window, 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 (); @@ -4146,7 +4144,7 @@ x_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window, 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: @@ -5710,8 +5708,6 @@ x_set_window_size (struct frame *f, int change_gravity, int width, int height, b 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); diff --git a/src/w32term.h b/src/w32term.h index 89008b7348c..b8a1823d7b0 100644 --- a/src/w32term.h +++ b/src/w32term.h @@ -429,7 +429,7 @@ struct scroll_bar { /* 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 @@ -442,13 +442,13 @@ struct scroll_bar { 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. */ diff --git a/src/widget.c b/src/widget.c index 89b43fdae76..73c5149e2cd 100644 --- a/src/widget.c +++ b/src/widget.c @@ -404,8 +404,6 @@ set_frame_size (EmacsFrame ew) 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); diff --git a/src/window.c b/src/window.c index 9bf6ad4b8f3..e0c44ad344b 100644 --- a/src/window.c +++ b/src/window.c @@ -4001,6 +4001,20 @@ values. */) 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; diff --git a/src/xterm.c b/src/xterm.c index 20157acca2e..f634feb21f9 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -8537,10 +8537,6 @@ x_set_window_size_1 (struct frame *f, int change_gravity, int width, int height, 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); @@ -8623,10 +8619,7 @@ x_set_window_size (struct frame *f, int change_gravity, int width, int height, b #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); }