diff options
| author | Martin Rudalics | 2019-03-11 09:57:23 +0100 |
|---|---|---|
| committer | Martin Rudalics | 2019-03-11 09:57:23 +0100 |
| commit | 95373b69b34f9756d2f05b19798b763d22aa5f0a (patch) | |
| tree | ffd55c71f1cccf34fc90aeb56dfeb4e78afb1915 /src | |
| parent | 27466c62fdc977e8d3b23c5ae4f529a64ac7374f (diff) | |
| download | emacs-95373b69b34f9756d2f05b19798b763d22aa5f0a.tar.gz emacs-95373b69b34f9756d2f05b19798b763d22aa5f0a.zip | |
Rewrite minibuffer window resizing code
* src/frame.c (resize_mini_frames): New variable.
* src/window.c (resize_mini_window_apply): New function.
(grow_mini_window, shrink_mini_window): Remove PIXELWISE
argument. Call resize_mini_window_apply to apply changes.
(Fresize_mini_window_internal): Call resize_mini_window_apply
to apply changes.
(Qwindow__resize_mini_frame): New symbol.
* src/window.h (grow_mini_window, shrink_mini_window): Adjust
external declarations.
* src/xdisp.c (resize_mini_window): For minibuffer-only frames
call 'window--resize-mini-frame' if resize_mini_frames is
non-nil. Offload parts of logic to grow_mini_window and
shrink_mini_window which are now called without the PIXELWISE
argument.
(Vresize_mini_windows): Mention 'resize-mini-frames' in
doc-string.
* lisp/cus-start.el (resize-mini-frames): Add customization
support.
* lisp/window.el (window--resize-mini-window): Simplify code.
(window--resize-mini-frame): New function.
* doc/lispref/minibuf.texi (Minibuffer Windows): Describe new
option 'resize-mini-frames'.
* etc/NEWS: Mention new option 'resize-mini-frames'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/frame.c | 13 | ||||
| -rw-r--r-- | src/window.c | 180 | ||||
| -rw-r--r-- | src/window.h | 4 | ||||
| -rw-r--r-- | src/xdisp.c | 92 |
4 files changed, 131 insertions, 158 deletions
diff --git a/src/frame.c b/src/frame.c index c336369dbb5..46bdf222315 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -6079,6 +6079,19 @@ setting this variable does not change that frame's previous association. | |||
| 6079 | 6079 | ||
| 6080 | This variable is local to the current terminal and cannot be buffer-local. */); | 6080 | This variable is local to the current terminal and cannot be buffer-local. */); |
| 6081 | 6081 | ||
| 6082 | DEFVAR_LISP ("resize-mini-frames", resize_mini_frames, | ||
| 6083 | doc: /* Non-nil means resize minibuffer-only frames automatically. | ||
| 6084 | If this is nil, do not resize minibuffer-only frames automatically. | ||
| 6085 | |||
| 6086 | If this is a function, call that function with the minibuffer-only | ||
| 6087 | frame that shall be resized as sole argument. The buffer of the root | ||
| 6088 | window of that frame is the buffer whose text will be eventually shown | ||
| 6089 | in the minibuffer window. | ||
| 6090 | |||
| 6091 | Any other non-nil value means to resize minibuffer-only frames by | ||
| 6092 | calling `fit-frame-to-buffer'. */); | ||
| 6093 | resize_mini_frames = Qnil; | ||
| 6094 | |||
| 6082 | DEFVAR_LISP ("focus-follows-mouse", focus_follows_mouse, | 6095 | DEFVAR_LISP ("focus-follows-mouse", focus_follows_mouse, |
| 6083 | doc: /* Non-nil if window system changes focus when you move the mouse. | 6096 | doc: /* Non-nil if window system changes focus when you move the mouse. |
| 6084 | You should set this variable to tell Emacs how your window manager | 6097 | You should set this variable to tell Emacs how your window manager |
diff --git a/src/window.c b/src/window.c index c498ae81cdb..ae039b76add 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -5168,118 +5168,111 @@ Signal an error when WINDOW is the only window on its frame. */) | |||
| 5168 | Resizing Mini-Windows | 5168 | Resizing Mini-Windows |
| 5169 | ***********************************************************************/ | 5169 | ***********************************************************************/ |
| 5170 | 5170 | ||
| 5171 | /* Grow mini-window W by DELTA lines, DELTA >= 0, or as much as we | 5171 | /** |
| 5172 | can. */ | 5172 | * resize_mini_window_apply: |
| 5173 | * | ||
| 5174 | * Assign new window sizes after resizing a mini window W by DELTA | ||
| 5175 | * pixels. No error checking performed. | ||
| 5176 | */ | ||
| 5177 | static void | ||
| 5178 | resize_mini_window_apply (struct window *w, int delta) | ||
| 5179 | { | ||
| 5180 | struct frame *f = XFRAME (w->frame); | ||
| 5181 | Lisp_Object root = FRAME_ROOT_WINDOW (f); | ||
| 5182 | struct window *r = XWINDOW (root); | ||
| 5183 | |||
| 5184 | block_input (); | ||
| 5185 | w->pixel_height = w->pixel_height + delta; | ||
| 5186 | w->total_lines = w->pixel_height / FRAME_LINE_HEIGHT (f); | ||
| 5187 | |||
| 5188 | window_resize_apply (r, false); | ||
| 5189 | |||
| 5190 | w->pixel_top = r->pixel_top + r->pixel_height; | ||
| 5191 | w->top_line = r->top_line + r->total_lines; | ||
| 5192 | |||
| 5193 | /* Enforce full redisplay of the frame. */ | ||
| 5194 | /* FIXME: Shouldn't some of the caller do it? */ | ||
| 5195 | fset_redisplay (f); | ||
| 5196 | adjust_frame_glyphs (f); | ||
| 5197 | unblock_input (); | ||
| 5198 | } | ||
| 5199 | |||
| 5200 | /** | ||
| 5201 | * grow_mini_window: | ||
| 5202 | * | ||
| 5203 | * Grow mini-window W by DELTA pixels. If DELTA is negative, this may | ||
| 5204 | * shrink the minibuffer window to the minimum height to display one | ||
| 5205 | * line of text. | ||
| 5206 | */ | ||
| 5173 | void | 5207 | void |
| 5174 | grow_mini_window (struct window *w, int delta, bool pixelwise) | 5208 | grow_mini_window (struct window *w, int delta) |
| 5175 | { | 5209 | { |
| 5176 | struct frame *f = XFRAME (w->frame); | 5210 | struct frame *f = XFRAME (w->frame); |
| 5177 | struct window *r; | 5211 | int old_height = WINDOW_PIXEL_HEIGHT (w); |
| 5178 | Lisp_Object root, height; | 5212 | int min_height = FRAME_LINE_HEIGHT (f); |
| 5179 | int line_height, pixel_height; | ||
| 5180 | 5213 | ||
| 5181 | eassert (MINI_WINDOW_P (w)); | 5214 | eassert (MINI_WINDOW_P (w)); |
| 5182 | eassert (delta >= 0); | ||
| 5183 | 5215 | ||
| 5184 | if (delta > 0) | 5216 | if (old_height + delta < min_height) |
| 5185 | { | 5217 | /* Never shrink mini-window to less than its minimum |
| 5186 | root = FRAME_ROOT_WINDOW (f); | 5218 | height. */ |
| 5187 | r = XWINDOW (root); | 5219 | delta = old_height > min_height ? min_height - old_height : 0; |
| 5188 | height = call3 (Qwindow__resize_root_window_vertically, | ||
| 5189 | root, make_fixnum (- delta), pixelwise ? Qt : Qnil); | ||
| 5190 | if (FIXNUMP (height) && window_resize_check (r, false)) | ||
| 5191 | { | ||
| 5192 | block_input (); | ||
| 5193 | window_resize_apply (r, false); | ||
| 5194 | 5220 | ||
| 5195 | if (pixelwise) | 5221 | if (delta != 0) |
| 5196 | { | 5222 | { |
| 5197 | pixel_height = min (-XFIXNUM (height), INT_MAX - w->pixel_height); | 5223 | Lisp_Object root = FRAME_ROOT_WINDOW (f); |
| 5198 | line_height = pixel_height / FRAME_LINE_HEIGHT (f); | 5224 | struct window *r = XWINDOW (root); |
| 5199 | } | 5225 | Lisp_Object grow; |
| 5200 | else | ||
| 5201 | { | ||
| 5202 | line_height = min (-XFIXNUM (height), | ||
| 5203 | ((INT_MAX - w->pixel_height) | ||
| 5204 | / FRAME_LINE_HEIGHT (f))); | ||
| 5205 | pixel_height = line_height * FRAME_LINE_HEIGHT (f); | ||
| 5206 | } | ||
| 5207 | 5226 | ||
| 5208 | /* Grow the mini-window. */ | 5227 | FRAME_WINDOWS_FROZEN (f) = true; |
| 5209 | w->pixel_top = r->pixel_top + r->pixel_height; | 5228 | grow = call3 (Qwindow__resize_root_window_vertically, |
| 5210 | w->top_line = r->top_line + r->total_lines; | 5229 | root, make_fixnum (- delta), Qt); |
| 5211 | /* Make sure the mini-window has always at least one line. */ | ||
| 5212 | w->pixel_height = max (w->pixel_height + pixel_height, | ||
| 5213 | FRAME_LINE_HEIGHT (f)); | ||
| 5214 | w->total_lines = max (w->total_lines + line_height, 1); | ||
| 5215 | |||
| 5216 | /* Enforce full redisplay of the frame. */ | ||
| 5217 | /* FIXME: Shouldn't window--resize-root-window-vertically do it? */ | ||
| 5218 | fset_redisplay (f); | ||
| 5219 | adjust_frame_glyphs (f); | ||
| 5220 | unblock_input (); | ||
| 5221 | } | ||
| 5222 | else | ||
| 5223 | error ("Failed to grow minibuffer window"); | ||
| 5224 | 5230 | ||
| 5231 | if (FIXNUMP (grow) && window_resize_check (r, false)) | ||
| 5232 | resize_mini_window_apply (w, -XFIXNUM (grow)); | ||
| 5225 | } | 5233 | } |
| 5226 | } | 5234 | } |
| 5227 | 5235 | ||
| 5228 | /* Shrink mini-window W to one line. */ | 5236 | /** |
| 5237 | * shrink_mini_window: | ||
| 5238 | * | ||
| 5239 | * Shrink mini-window W to the minimum height needed to display one | ||
| 5240 | * line of text. | ||
| 5241 | */ | ||
| 5229 | void | 5242 | void |
| 5230 | shrink_mini_window (struct window *w, bool pixelwise) | 5243 | shrink_mini_window (struct window *w) |
| 5231 | { | 5244 | { |
| 5232 | struct frame *f = XFRAME (w->frame); | 5245 | struct frame *f = XFRAME (w->frame); |
| 5233 | struct window *r; | 5246 | int delta = WINDOW_PIXEL_HEIGHT (w) - FRAME_LINE_HEIGHT (f); |
| 5234 | Lisp_Object root, delta; | ||
| 5235 | EMACS_INT height, unit; | ||
| 5236 | 5247 | ||
| 5237 | eassert (MINI_WINDOW_P (w)); | 5248 | eassert (MINI_WINDOW_P (w)); |
| 5238 | 5249 | ||
| 5239 | height = pixelwise ? w->pixel_height : w->total_lines; | 5250 | if (delta > 0) |
| 5240 | unit = pixelwise ? FRAME_LINE_HEIGHT (f) : 1; | ||
| 5241 | if (height > unit) | ||
| 5242 | { | 5251 | { |
| 5243 | root = FRAME_ROOT_WINDOW (f); | 5252 | Lisp_Object root = FRAME_ROOT_WINDOW (f); |
| 5244 | r = XWINDOW (root); | 5253 | struct window *r = XWINDOW (root); |
| 5245 | delta = call3 (Qwindow__resize_root_window_vertically, | 5254 | Lisp_Object grow; |
| 5246 | root, make_fixnum (height - unit), | 5255 | |
| 5247 | pixelwise ? Qt : Qnil); | 5256 | FRAME_WINDOWS_FROZEN (f) = false; |
| 5248 | if (FIXNUMP (delta) && window_resize_check (r, false)) | 5257 | grow = call3 (Qwindow__resize_root_window_vertically, |
| 5249 | { | 5258 | root, make_fixnum (delta), Qt); |
| 5250 | block_input (); | 5259 | |
| 5251 | window_resize_apply (r, false); | 5260 | if (FIXNUMP (grow) && window_resize_check (r, false)) |
| 5252 | 5261 | resize_mini_window_apply (w, -XFIXNUM (grow)); | |
| 5253 | /* Shrink the mini-window. */ | ||
| 5254 | w->top_line = r->top_line + r->total_lines; | ||
| 5255 | w->total_lines = 1; | ||
| 5256 | w->pixel_top = r->pixel_top + r->pixel_height; | ||
| 5257 | w->pixel_height = FRAME_LINE_HEIGHT (f); | ||
| 5258 | /* Enforce full redisplay of the frame. */ | ||
| 5259 | /* FIXME: Shouldn't window--resize-root-window-vertically do it? */ | ||
| 5260 | fset_redisplay (f); | ||
| 5261 | adjust_frame_glyphs (f); | ||
| 5262 | unblock_input (); | ||
| 5263 | } | ||
| 5264 | /* If the above failed for whatever strange reason we must make a | ||
| 5265 | one window frame here. The same routine will be needed when | ||
| 5266 | shrinking the frame (and probably when making the initial | ||
| 5267 | *scratch* window). For the moment leave things as they are. */ | ||
| 5268 | else | ||
| 5269 | error ("Failed to shrink minibuffer window"); | ||
| 5270 | } | 5262 | } |
| 5271 | } | 5263 | } |
| 5272 | 5264 | ||
| 5273 | DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini_window_internal, 1, 1, 0, | 5265 | DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, |
| 5274 | doc: /* Resize minibuffer window WINDOW. */) | 5266 | Sresize_mini_window_internal, 1, 1, 0, |
| 5267 | doc: /* Resize mini window WINDOW. */) | ||
| 5275 | (Lisp_Object window) | 5268 | (Lisp_Object window) |
| 5276 | { | 5269 | { |
| 5277 | struct window *w = XWINDOW (window); | 5270 | struct window *w = XWINDOW (window); |
| 5278 | struct window *r; | 5271 | struct window *r; |
| 5279 | struct frame *f; | 5272 | struct frame *f; |
| 5280 | int height; | 5273 | int old_height, delta; |
| 5281 | 5274 | ||
| 5282 | CHECK_WINDOW (window); | 5275 | CHECK_LIVE_WINDOW (window); |
| 5283 | f = XFRAME (w->frame); | 5276 | f = XFRAME (w->frame); |
| 5284 | 5277 | ||
| 5285 | if (!EQ (FRAME_MINIBUF_WINDOW (XFRAME (w->frame)), window)) | 5278 | if (!EQ (FRAME_MINIBUF_WINDOW (XFRAME (w->frame)), window)) |
| @@ -5288,26 +5281,18 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini | |||
| 5288 | error ("Cannot resize a minibuffer-only frame"); | 5281 | error ("Cannot resize a minibuffer-only frame"); |
| 5289 | 5282 | ||
| 5290 | r = XWINDOW (FRAME_ROOT_WINDOW (f)); | 5283 | r = XWINDOW (FRAME_ROOT_WINDOW (f)); |
| 5291 | height = r->pixel_height + w->pixel_height; | 5284 | old_height = r->pixel_height + w->pixel_height; |
| 5285 | delta = XFIXNUM (w->new_pixel) - w->pixel_height; | ||
| 5292 | if (window_resize_check (r, false) | 5286 | if (window_resize_check (r, false) |
| 5293 | && XFIXNUM (w->new_pixel) > 0 | 5287 | && XFIXNUM (w->new_pixel) > 0 |
| 5294 | && height == XFIXNUM (r->new_pixel) + XFIXNUM (w->new_pixel)) | 5288 | && old_height == XFIXNUM (r->new_pixel) + XFIXNUM (w->new_pixel)) |
| 5295 | { | 5289 | { |
| 5296 | block_input (); | 5290 | resize_mini_window_apply (w, delta); |
| 5297 | window_resize_apply (r, false); | ||
| 5298 | |||
| 5299 | w->pixel_height = XFIXNAT (w->new_pixel); | ||
| 5300 | w->total_lines = w->pixel_height / FRAME_LINE_HEIGHT (f); | ||
| 5301 | w->pixel_top = r->pixel_top + r->pixel_height; | ||
| 5302 | w->top_line = r->top_line + r->total_lines; | ||
| 5303 | 5291 | ||
| 5304 | fset_redisplay (f); | ||
| 5305 | adjust_frame_glyphs (f); | ||
| 5306 | unblock_input (); | ||
| 5307 | return Qt; | 5292 | return Qt; |
| 5308 | } | 5293 | } |
| 5309 | else | 5294 | else |
| 5310 | error ("Failed to resize minibuffer window"); | 5295 | error ("Cannot resize mini window"); |
| 5311 | } | 5296 | } |
| 5312 | 5297 | ||
| 5313 | /* Mark window cursors off for all windows in the window tree rooted | 5298 | /* Mark window cursors off for all windows in the window tree rooted |
| @@ -8047,6 +8032,7 @@ syms_of_window (void) | |||
| 8047 | DEFSYM (Qwindow__resize_root_window, "window--resize-root-window"); | 8032 | DEFSYM (Qwindow__resize_root_window, "window--resize-root-window"); |
| 8048 | DEFSYM (Qwindow__resize_root_window_vertically, | 8033 | DEFSYM (Qwindow__resize_root_window_vertically, |
| 8049 | "window--resize-root-window-vertically"); | 8034 | "window--resize-root-window-vertically"); |
| 8035 | DEFSYM (Qwindow__resize_mini_frame, "window--resize-mini-frame"); | ||
| 8050 | DEFSYM (Qwindow__sanitize_window_sizes, "window--sanitize-window-sizes"); | 8036 | DEFSYM (Qwindow__sanitize_window_sizes, "window--sanitize-window-sizes"); |
| 8051 | DEFSYM (Qwindow__pixel_to_total, "window--pixel-to-total"); | 8037 | DEFSYM (Qwindow__pixel_to_total, "window--pixel-to-total"); |
| 8052 | DEFSYM (Qsafe, "safe"); | 8038 | DEFSYM (Qsafe, "safe"); |
diff --git a/src/window.h b/src/window.h index d816bb1683d..b450173eb2f 100644 --- a/src/window.h +++ b/src/window.h | |||
| @@ -1063,8 +1063,8 @@ extern Lisp_Object window_from_coordinates (struct frame *, int, int, | |||
| 1063 | extern void resize_frame_windows (struct frame *, int, bool, bool); | 1063 | extern void resize_frame_windows (struct frame *, int, bool, bool); |
| 1064 | extern void restore_window_configuration (Lisp_Object); | 1064 | extern void restore_window_configuration (Lisp_Object); |
| 1065 | extern void delete_all_child_windows (Lisp_Object); | 1065 | extern void delete_all_child_windows (Lisp_Object); |
| 1066 | extern void grow_mini_window (struct window *, int, bool); | 1066 | extern void grow_mini_window (struct window *, int); |
| 1067 | extern void shrink_mini_window (struct window *, bool); | 1067 | extern void shrink_mini_window (struct window *); |
| 1068 | extern int window_relative_x_coord (struct window *, enum window_part, int); | 1068 | extern int window_relative_x_coord (struct window *, enum window_part, int); |
| 1069 | 1069 | ||
| 1070 | void run_window_change_functions (void); | 1070 | void run_window_change_functions (void); |
diff --git a/src/xdisp.c b/src/xdisp.c index 0af5e39dfb6..6d30afda6d8 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -11259,15 +11259,10 @@ bool | |||
| 11259 | resize_mini_window (struct window *w, bool exact_p) | 11259 | resize_mini_window (struct window *w, bool exact_p) |
| 11260 | { | 11260 | { |
| 11261 | struct frame *f = XFRAME (w->frame); | 11261 | struct frame *f = XFRAME (w->frame); |
| 11262 | bool window_height_changed_p = false; | 11262 | int old_height = WINDOW_PIXEL_HEIGHT (w); |
| 11263 | 11263 | ||
| 11264 | eassert (MINI_WINDOW_P (w)); | 11264 | eassert (MINI_WINDOW_P (w)); |
| 11265 | 11265 | ||
| 11266 | /* By default, start display at the beginning. */ | ||
| 11267 | set_marker_both (w->start, w->contents, | ||
| 11268 | BUF_BEGV (XBUFFER (w->contents)), | ||
| 11269 | BUF_BEGV_BYTE (XBUFFER (w->contents))); | ||
| 11270 | |||
| 11271 | /* Don't resize windows while redisplaying a window; it would | 11266 | /* Don't resize windows while redisplaying a window; it would |
| 11272 | confuse redisplay functions when the size of the window they are | 11267 | confuse redisplay functions when the size of the window they are |
| 11273 | displaying changes from under them. Such a resizing can happen, | 11268 | displaying changes from under them. Such a resizing can happen, |
| @@ -11278,19 +11273,30 @@ resize_mini_window (struct window *w, bool exact_p) | |||
| 11278 | return false; | 11273 | return false; |
| 11279 | 11274 | ||
| 11280 | /* Nil means don't try to resize. */ | 11275 | /* Nil means don't try to resize. */ |
| 11281 | if (NILP (Vresize_mini_windows) | 11276 | if ((NILP (Vresize_mini_windows) |
| 11277 | && (NILP (resize_mini_frames) || !FRAME_MINIBUF_ONLY_P (f))) | ||
| 11282 | || (FRAME_X_P (f) && FRAME_X_OUTPUT (f) == NULL)) | 11278 | || (FRAME_X_P (f) && FRAME_X_OUTPUT (f) == NULL)) |
| 11283 | return false; | 11279 | return false; |
| 11284 | 11280 | ||
| 11285 | if (!FRAME_MINIBUF_ONLY_P (f)) | 11281 | /* By default, start display at the beginning. */ |
| 11282 | set_marker_both (w->start, w->contents, | ||
| 11283 | BUF_BEGV (XBUFFER (w->contents)), | ||
| 11284 | BUF_BEGV_BYTE (XBUFFER (w->contents))); | ||
| 11285 | |||
| 11286 | if (FRAME_MINIBUF_ONLY_P (f)) | ||
| 11287 | { | ||
| 11288 | if (!NILP (resize_mini_frames)) | ||
| 11289 | safe_call1 (Qwindow__resize_mini_frame, WINDOW_FRAME (w)); | ||
| 11290 | } | ||
| 11291 | else | ||
| 11286 | { | 11292 | { |
| 11287 | struct it it; | 11293 | struct it it; |
| 11288 | int total_height = (WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_ROOT_WINDOW (f))) | 11294 | int old_height = WINDOW_PIXEL_HEIGHT (w); |
| 11289 | + WINDOW_PIXEL_HEIGHT (w)); | ||
| 11290 | int unit = FRAME_LINE_HEIGHT (f); | 11295 | int unit = FRAME_LINE_HEIGHT (f); |
| 11291 | int height, max_height; | 11296 | int height, max_height; |
| 11292 | struct text_pos start; | 11297 | struct text_pos start; |
| 11293 | struct buffer *old_current_buffer = NULL; | 11298 | struct buffer *old_current_buffer = NULL; |
| 11299 | int windows_height = FRAME_WINDOWS_HEIGHT (f); | ||
| 11294 | 11300 | ||
| 11295 | if (current_buffer != XBUFFER (w->contents)) | 11301 | if (current_buffer != XBUFFER (w->contents)) |
| 11296 | { | 11302 | { |
| @@ -11302,14 +11308,14 @@ resize_mini_window (struct window *w, bool exact_p) | |||
| 11302 | 11308 | ||
| 11303 | /* Compute the max. number of lines specified by the user. */ | 11309 | /* Compute the max. number of lines specified by the user. */ |
| 11304 | if (FLOATP (Vmax_mini_window_height)) | 11310 | if (FLOATP (Vmax_mini_window_height)) |
| 11305 | max_height = XFLOAT_DATA (Vmax_mini_window_height) * total_height; | 11311 | max_height = XFLOAT_DATA (Vmax_mini_window_height) * windows_height; |
| 11306 | else if (FIXNUMP (Vmax_mini_window_height)) | 11312 | else if (FIXNUMP (Vmax_mini_window_height)) |
| 11307 | max_height = XFIXNUM (Vmax_mini_window_height) * unit; | 11313 | max_height = XFIXNUM (Vmax_mini_window_height) * unit; |
| 11308 | else | 11314 | else |
| 11309 | max_height = total_height / 4; | 11315 | max_height = windows_height / 4; |
| 11310 | 11316 | ||
| 11311 | /* Correct that max. height if it's bogus. */ | 11317 | /* Correct that max. height if it's bogus. */ |
| 11312 | max_height = clip_to_bounds (unit, max_height, total_height); | 11318 | max_height = clip_to_bounds (unit, max_height, windows_height); |
| 11313 | 11319 | ||
| 11314 | /* Find out the height of the text in the window. */ | 11320 | /* Find out the height of the text in the window. */ |
| 11315 | if (it.line_wrap == TRUNCATE) | 11321 | if (it.line_wrap == TRUNCATE) |
| @@ -11335,63 +11341,27 @@ resize_mini_window (struct window *w, bool exact_p) | |||
| 11335 | } | 11341 | } |
| 11336 | else | 11342 | else |
| 11337 | SET_TEXT_POS (start, BEGV, BEGV_BYTE); | 11343 | SET_TEXT_POS (start, BEGV, BEGV_BYTE); |
| 11344 | |||
| 11338 | SET_MARKER_FROM_TEXT_POS (w->start, start); | 11345 | SET_MARKER_FROM_TEXT_POS (w->start, start); |
| 11339 | 11346 | ||
| 11340 | if (EQ (Vresize_mini_windows, Qgrow_only)) | 11347 | if (EQ (Vresize_mini_windows, Qgrow_only)) |
| 11341 | { | 11348 | { |
| 11342 | /* Let it grow only, until we display an empty message, in which | 11349 | /* Let it grow only, until we display an empty message, in which |
| 11343 | case the window shrinks again. */ | 11350 | case the window shrinks again. */ |
| 11344 | if (height > WINDOW_PIXEL_HEIGHT (w)) | 11351 | if (height > old_height) |
| 11345 | { | 11352 | grow_mini_window (w, height - old_height); |
| 11346 | int old_height = WINDOW_PIXEL_HEIGHT (w); | 11353 | else if (height < old_height && (exact_p || BEGV == ZV)) |
| 11347 | 11354 | shrink_mini_window (w); | |
| 11348 | FRAME_WINDOWS_FROZEN (f) = true; | ||
| 11349 | grow_mini_window (w, height - WINDOW_PIXEL_HEIGHT (w), true); | ||
| 11350 | window_height_changed_p = WINDOW_PIXEL_HEIGHT (w) != old_height; | ||
| 11351 | } | ||
| 11352 | else if (height < WINDOW_PIXEL_HEIGHT (w) | ||
| 11353 | && (exact_p || BEGV == ZV)) | ||
| 11354 | { | ||
| 11355 | int old_height = WINDOW_PIXEL_HEIGHT (w); | ||
| 11356 | |||
| 11357 | FRAME_WINDOWS_FROZEN (f) = false; | ||
| 11358 | shrink_mini_window (w, true); | ||
| 11359 | window_height_changed_p = WINDOW_PIXEL_HEIGHT (w) != old_height; | ||
| 11360 | } | ||
| 11361 | } | ||
| 11362 | else | ||
| 11363 | { | ||
| 11364 | /* Always resize to exact size needed. */ | ||
| 11365 | if (height > WINDOW_PIXEL_HEIGHT (w)) | ||
| 11366 | { | ||
| 11367 | int old_height = WINDOW_PIXEL_HEIGHT (w); | ||
| 11368 | |||
| 11369 | FRAME_WINDOWS_FROZEN (f) = true; | ||
| 11370 | grow_mini_window (w, height - WINDOW_PIXEL_HEIGHT (w), true); | ||
| 11371 | window_height_changed_p = WINDOW_PIXEL_HEIGHT (w) != old_height; | ||
| 11372 | } | ||
| 11373 | else if (height < WINDOW_PIXEL_HEIGHT (w)) | ||
| 11374 | { | ||
| 11375 | int old_height = WINDOW_PIXEL_HEIGHT (w); | ||
| 11376 | |||
| 11377 | FRAME_WINDOWS_FROZEN (f) = false; | ||
| 11378 | shrink_mini_window (w, true); | ||
| 11379 | |||
| 11380 | if (height) | ||
| 11381 | { | ||
| 11382 | FRAME_WINDOWS_FROZEN (f) = true; | ||
| 11383 | grow_mini_window (w, height - WINDOW_PIXEL_HEIGHT (w), true); | ||
| 11384 | } | ||
| 11385 | |||
| 11386 | window_height_changed_p = WINDOW_PIXEL_HEIGHT (w) != old_height; | ||
| 11387 | } | ||
| 11388 | } | 11355 | } |
| 11356 | else if (height != old_height) | ||
| 11357 | /* Always resize to exact size needed. */ | ||
| 11358 | grow_mini_window (w, height - old_height); | ||
| 11389 | 11359 | ||
| 11390 | if (old_current_buffer) | 11360 | if (old_current_buffer) |
| 11391 | set_buffer_internal (old_current_buffer); | 11361 | set_buffer_internal (old_current_buffer); |
| 11392 | } | 11362 | } |
| 11393 | 11363 | ||
| 11394 | return window_height_changed_p; | 11364 | return WINDOW_PIXEL_HEIGHT (w) != old_height; |
| 11395 | } | 11365 | } |
| 11396 | 11366 | ||
| 11397 | 11367 | ||
| @@ -33091,7 +33061,11 @@ A value of nil means don't automatically resize mini-windows. | |||
| 33091 | A value of t means resize them to fit the text displayed in them. | 33061 | A value of t means resize them to fit the text displayed in them. |
| 33092 | A value of `grow-only', the default, means let mini-windows grow only; | 33062 | A value of `grow-only', the default, means let mini-windows grow only; |
| 33093 | they return to their normal size when the minibuffer is closed, or the | 33063 | they return to their normal size when the minibuffer is closed, or the |
| 33094 | echo area becomes empty. */); | 33064 | echo area becomes empty. |
| 33065 | |||
| 33066 | This variable does not affect resizing of the minibuffer window of | ||
| 33067 | minibuffer-only frames. These are handled by 'resize-mini-frames' | ||
| 33068 | only. */); | ||
| 33095 | /* Contrary to the doc string, we initialize this to nil, so that | 33069 | /* Contrary to the doc string, we initialize this to nil, so that |
| 33096 | loading loadup.el won't try to resize windows before loading | 33070 | loading loadup.el won't try to resize windows before loading |
| 33097 | window.el, where some functions we need to call for this live. | 33071 | window.el, where some functions we need to call for this live. |