diff options
| author | Gerd Moellmann | 1999-09-23 11:58:37 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 1999-09-23 11:58:37 +0000 |
| commit | f984d4fcdfe6495793c3b2090f2ace4646e77f6c (patch) | |
| tree | 6fa7b9e938c27a82ff798c706627faa2d9c9b1ba /src/window.c | |
| parent | 53811b42390709a3043940668924002e96285892 (diff) | |
| download | emacs-f984d4fcdfe6495793c3b2090f2ace4646e77f6c.tar.gz emacs-f984d4fcdfe6495793c3b2090f2ace4646e77f6c.zip | |
(window_min_size): Add parameter ignore_fixed_p.
(change_window_height): Call window_min_size with new parameter.
(shrink_window_lowest_first, save_restore_orig_size,
grow_mini_window, shrink_mini_window): New.
(make_window, replace_window): Initialize orig_top and
orig_height.
(enlarge_window): Renamed from change_window_height. Make it
static.
(Fdisplay_buffer, Fenlage_window, Fshrink_window): Call
enlarge_window instead of change_window_height.
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 240 |
1 files changed, 218 insertions, 22 deletions
diff --git a/src/window.c b/src/window.c index cc612315c64..451b7ce2a23 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -54,12 +54,13 @@ static void window_scroll P_ ((Lisp_Object, int, int, int)); | |||
| 54 | static void window_scroll_pixel_based P_ ((Lisp_Object, int, int, int)); | 54 | static void window_scroll_pixel_based P_ ((Lisp_Object, int, int, int)); |
| 55 | static void window_scroll_line_based P_ ((Lisp_Object, int, int, int)); | 55 | static void window_scroll_line_based P_ ((Lisp_Object, int, int, int)); |
| 56 | static int window_min_size_1 P_ ((struct window *, int)); | 56 | static int window_min_size_1 P_ ((struct window *, int)); |
| 57 | static int window_min_size P_ ((struct window *, int, int *)); | 57 | static int window_min_size P_ ((struct window *, int, int, int *)); |
| 58 | static int window_fixed_size_p P_ ((struct window *, int, int)); | ||
| 59 | static void size_window P_ ((Lisp_Object, int, int, int)); | 58 | static void size_window P_ ((Lisp_Object, int, int, int)); |
| 60 | static void foreach_window_1 P_ ((struct window *, void (*fn) (), int, int, | 59 | static void foreach_window_1 P_ ((struct window *, void (*fn) (), int, int, |
| 61 | int, int)); | 60 | int, int)); |
| 62 | static void freeze_window_start P_ ((struct window *, int)); | 61 | static void freeze_window_start P_ ((struct window *, int)); |
| 62 | static int window_fixed_size_p P_ ((struct window *, int, int)); | ||
| 63 | static void enlarge_window P_ ((int, int)); | ||
| 63 | 64 | ||
| 64 | 65 | ||
| 65 | /* This is the window in which the terminal's cursor should | 66 | /* This is the window in which the terminal's cursor should |
| @@ -210,6 +211,7 @@ make_window () | |||
| 210 | XSETFASTINT (p->height, 0); | 211 | XSETFASTINT (p->height, 0); |
| 211 | XSETFASTINT (p->width, 0); | 212 | XSETFASTINT (p->width, 0); |
| 212 | XSETFASTINT (p->hscroll, 0); | 213 | XSETFASTINT (p->hscroll, 0); |
| 214 | p->orig_top = p->orig_height = Qnil; | ||
| 213 | p->start = Fmake_marker (); | 215 | p->start = Fmake_marker (); |
| 214 | p->pointm = Fmake_marker (); | 216 | p->pointm = Fmake_marker (); |
| 215 | XSETFASTINT (p->use_time, 0); | 217 | XSETFASTINT (p->use_time, 0); |
| @@ -923,6 +925,7 @@ replace_window (old, replacement) | |||
| 923 | XSETFASTINT (p->window_end_pos, 0); | 925 | XSETFASTINT (p->window_end_pos, 0); |
| 924 | p->window_end_valid = Qnil; | 926 | p->window_end_valid = Qnil; |
| 925 | p->frozen_window_start_p = 0; | 927 | p->frozen_window_start_p = 0; |
| 928 | p->orig_top = p->orig_height = Qnil; | ||
| 926 | 929 | ||
| 927 | p->next = tem = o->next; | 930 | p->next = tem = o->next; |
| 928 | if (!NILP (tem)) | 931 | if (!NILP (tem)) |
| @@ -2104,17 +2107,22 @@ window_min_size_1 (w, width_p) | |||
| 2104 | 2107 | ||
| 2105 | /* Return the minimum size of window W, taking fixed-size windows into | 2108 | /* Return the minimum size of window W, taking fixed-size windows into |
| 2106 | account. WIDTH_P non-zero means return the minimum width, | 2109 | account. WIDTH_P non-zero means return the minimum width, |
| 2107 | otherwise return the minimum height. Set *FIXED to 1 if W is | 2110 | otherwise return the minimum height. IGNORE_FIXED_P non-zero means |
| 2108 | fixed-size unless FIXED is null. */ | 2111 | ignore if W is fixed-size. Set *FIXED to 1 if W is fixed-size |
| 2112 | unless FIXED is null. */ | ||
| 2109 | 2113 | ||
| 2110 | static int | 2114 | static int |
| 2111 | window_min_size (w, width_p, fixed) | 2115 | window_min_size (w, width_p, ignore_fixed_p, fixed) |
| 2112 | struct window *w; | 2116 | struct window *w; |
| 2113 | int width_p, *fixed; | 2117 | int width_p, ignore_fixed_p, *fixed; |
| 2114 | { | 2118 | { |
| 2115 | int size, fixed_p; | 2119 | int size, fixed_p; |
| 2116 | 2120 | ||
| 2117 | fixed_p = window_fixed_size_p (w, width_p, 1); | 2121 | if (ignore_fixed_p) |
| 2122 | fixed_p = 0; | ||
| 2123 | else | ||
| 2124 | fixed_p = window_fixed_size_p (w, width_p, 1); | ||
| 2125 | |||
| 2118 | if (fixed) | 2126 | if (fixed) |
| 2119 | *fixed = fixed_p; | 2127 | *fixed = fixed_p; |
| 2120 | 2128 | ||
| @@ -2122,7 +2130,7 @@ window_min_size (w, width_p, fixed) | |||
| 2122 | size = width_p ? XFASTINT (w->width) : XFASTINT (w->height); | 2130 | size = width_p ? XFASTINT (w->width) : XFASTINT (w->height); |
| 2123 | else | 2131 | else |
| 2124 | size = window_min_size_1 (w, width_p); | 2132 | size = window_min_size_1 (w, width_p); |
| 2125 | 2133 | ||
| 2126 | return size; | 2134 | return size; |
| 2127 | } | 2135 | } |
| 2128 | 2136 | ||
| @@ -2785,9 +2793,9 @@ If FRAME is nil, search only the selected frame\n\ | |||
| 2785 | old_selected_window = selected_window; | 2793 | old_selected_window = selected_window; |
| 2786 | 2794 | ||
| 2787 | selected_window = upper; | 2795 | selected_window = upper; |
| 2788 | change_window_height ((total / 2 | 2796 | enlarge_window ((total / 2 |
| 2789 | - XFASTINT (XWINDOW (upper)->height)), | 2797 | - XFASTINT (XWINDOW (upper)->height)), |
| 2790 | 0); | 2798 | 0); |
| 2791 | selected_window = old_selected_window; | 2799 | selected_window = old_selected_window; |
| 2792 | } | 2800 | } |
| 2793 | } | 2801 | } |
| @@ -3022,7 +3030,7 @@ From program, optional second arg non-nil means grow sideways ARG columns.") | |||
| 3022 | register Lisp_Object arg, side; | 3030 | register Lisp_Object arg, side; |
| 3023 | { | 3031 | { |
| 3024 | CHECK_NUMBER (arg, 0); | 3032 | CHECK_NUMBER (arg, 0); |
| 3025 | change_window_height (XINT (arg), !NILP (side)); | 3033 | enlarge_window (XINT (arg), !NILP (side)); |
| 3026 | 3034 | ||
| 3027 | if (! NILP (Vwindow_configuration_change_hook)) | 3035 | if (! NILP (Vwindow_configuration_change_hook)) |
| 3028 | call1 (Vrun_hooks, Qwindow_configuration_change_hook); | 3036 | call1 (Vrun_hooks, Qwindow_configuration_change_hook); |
| @@ -3037,7 +3045,7 @@ From program, optional second arg non-nil means shrink sideways arg columns.") | |||
| 3037 | register Lisp_Object arg, side; | 3045 | register Lisp_Object arg, side; |
| 3038 | { | 3046 | { |
| 3039 | CHECK_NUMBER (arg, 0); | 3047 | CHECK_NUMBER (arg, 0); |
| 3040 | change_window_height (-XINT (arg), !NILP (side)); | 3048 | enlarge_window (-XINT (arg), !NILP (side)); |
| 3041 | 3049 | ||
| 3042 | if (! NILP (Vwindow_configuration_change_hook)) | 3050 | if (! NILP (Vwindow_configuration_change_hook)) |
| 3043 | call1 (Vrun_hooks, Qwindow_configuration_change_hook); | 3051 | call1 (Vrun_hooks, Qwindow_configuration_change_hook); |
| @@ -3074,8 +3082,8 @@ window_width (window) | |||
| 3074 | fullfil the size request. If they become too small in the process, | 3082 | fullfil the size request. If they become too small in the process, |
| 3075 | they will be deleted. */ | 3083 | they will be deleted. */ |
| 3076 | 3084 | ||
| 3077 | void | 3085 | static void |
| 3078 | change_window_height (delta, widthflag) | 3086 | enlarge_window (delta, widthflag) |
| 3079 | int delta, widthflag; | 3087 | int delta, widthflag; |
| 3080 | { | 3088 | { |
| 3081 | Lisp_Object parent, window, next, prev; | 3089 | Lisp_Object parent, window, next, prev; |
| @@ -3124,10 +3132,10 @@ change_window_height (delta, widthflag) | |||
| 3124 | maxdelta = (!NILP (parent) ? (*sizefun) (parent) - *sizep | 3132 | maxdelta = (!NILP (parent) ? (*sizefun) (parent) - *sizep |
| 3125 | : !NILP (p->next) ? ((*sizefun) (p->next) | 3133 | : !NILP (p->next) ? ((*sizefun) (p->next) |
| 3126 | - window_min_size (XWINDOW (p->next), | 3134 | - window_min_size (XWINDOW (p->next), |
| 3127 | widthflag, 0)) | 3135 | widthflag, 0, 0)) |
| 3128 | : !NILP (p->prev) ? ((*sizefun) (p->prev) | 3136 | : !NILP (p->prev) ? ((*sizefun) (p->prev) |
| 3129 | - window_min_size (XWINDOW (p->prev), | 3137 | - window_min_size (XWINDOW (p->prev), |
| 3130 | widthflag, 0)) | 3138 | widthflag, 0, 0)) |
| 3131 | /* This is a frame with only one window, a minibuffer-only | 3139 | /* This is a frame with only one window, a minibuffer-only |
| 3132 | or a minibufferless frame. */ | 3140 | or a minibufferless frame. */ |
| 3133 | : (delta = 0)); | 3141 | : (delta = 0)); |
| @@ -3139,7 +3147,7 @@ change_window_height (delta, widthflag) | |||
| 3139 | delta = maxdelta; | 3147 | delta = maxdelta; |
| 3140 | } | 3148 | } |
| 3141 | 3149 | ||
| 3142 | if (*sizep + delta < window_min_size (XWINDOW (window), widthflag, 0)) | 3150 | if (*sizep + delta < window_min_size (XWINDOW (window), widthflag, 0, 0)) |
| 3143 | { | 3151 | { |
| 3144 | delete_window (window); | 3152 | delete_window (window); |
| 3145 | return; | 3153 | return; |
| @@ -3152,10 +3160,10 @@ change_window_height (delta, widthflag) | |||
| 3152 | maximum = 0; | 3160 | maximum = 0; |
| 3153 | for (next = p->next; ! NILP (next); next = XWINDOW (next)->next) | 3161 | for (next = p->next; ! NILP (next); next = XWINDOW (next)->next) |
| 3154 | maximum += (*sizefun) (next) - window_min_size (XWINDOW (next), | 3162 | maximum += (*sizefun) (next) - window_min_size (XWINDOW (next), |
| 3155 | widthflag, 0); | 3163 | widthflag, 0, 0); |
| 3156 | for (prev = p->prev; ! NILP (prev); prev = XWINDOW (prev)->prev) | 3164 | for (prev = p->prev; ! NILP (prev); prev = XWINDOW (prev)->prev) |
| 3157 | maximum += (*sizefun) (prev) - window_min_size (XWINDOW (prev), | 3165 | maximum += (*sizefun) (prev) - window_min_size (XWINDOW (prev), |
| 3158 | widthflag, 0); | 3166 | widthflag, 0, 0); |
| 3159 | 3167 | ||
| 3160 | /* If we can get it all from them, do so. */ | 3168 | /* If we can get it all from them, do so. */ |
| 3161 | if (delta <= maximum) | 3169 | if (delta <= maximum) |
| @@ -3176,7 +3184,7 @@ change_window_height (delta, widthflag) | |||
| 3176 | { | 3184 | { |
| 3177 | int this_one = ((*sizefun) (next) | 3185 | int this_one = ((*sizefun) (next) |
| 3178 | - window_min_size (XWINDOW (next), | 3186 | - window_min_size (XWINDOW (next), |
| 3179 | widthflag, &fixed_p)); | 3187 | widthflag, 0, &fixed_p)); |
| 3180 | if (!fixed_p) | 3188 | if (!fixed_p) |
| 3181 | { | 3189 | { |
| 3182 | if (this_one > delta) | 3190 | if (this_one > delta) |
| @@ -3198,7 +3206,7 @@ change_window_height (delta, widthflag) | |||
| 3198 | { | 3206 | { |
| 3199 | int this_one = ((*sizefun) (prev) | 3207 | int this_one = ((*sizefun) (prev) |
| 3200 | - window_min_size (XWINDOW (prev), | 3208 | - window_min_size (XWINDOW (prev), |
| 3201 | widthflag, &fixed_p)); | 3209 | widthflag, 0, &fixed_p)); |
| 3202 | if (!fixed_p) | 3210 | if (!fixed_p) |
| 3203 | { | 3211 | { |
| 3204 | if (this_one > delta) | 3212 | if (this_one > delta) |
| @@ -3309,6 +3317,194 @@ change_window_height (delta, widthflag) | |||
| 3309 | #undef CURSIZE | 3317 | #undef CURSIZE |
| 3310 | 3318 | ||
| 3311 | 3319 | ||
| 3320 | |||
| 3321 | /*********************************************************************** | ||
| 3322 | Resizing Mini-Windows | ||
| 3323 | ***********************************************************************/ | ||
| 3324 | |||
| 3325 | static void shrink_window_lowest_first P_ ((struct window *, int)); | ||
| 3326 | static void save_restore_orig_size P_ ((struct window *, int)); | ||
| 3327 | |||
| 3328 | |||
| 3329 | /* Shrink windows rooted in window W to HEIGHT. Take the space needed | ||
| 3330 | from lowest windows first. */ | ||
| 3331 | |||
| 3332 | static void | ||
| 3333 | shrink_window_lowest_first (w, height) | ||
| 3334 | struct window *w; | ||
| 3335 | int height; | ||
| 3336 | { | ||
| 3337 | struct window *c; | ||
| 3338 | Lisp_Object child; | ||
| 3339 | int old_height; | ||
| 3340 | |||
| 3341 | xassert (!MINI_WINDOW_P (w)); | ||
| 3342 | |||
| 3343 | /* Set redisplay hints. */ | ||
| 3344 | XSETFASTINT (w->last_modified, 0); | ||
| 3345 | XSETFASTINT (w->last_overlay_modified, 0); | ||
| 3346 | windows_or_buffers_changed++; | ||
| 3347 | FRAME_WINDOW_SIZES_CHANGED (XFRAME (WINDOW_FRAME (w))) = 1; | ||
| 3348 | |||
| 3349 | old_height = XFASTINT (w->height); | ||
| 3350 | XSETFASTINT (w->height, height); | ||
| 3351 | |||
| 3352 | if (!NILP (w->hchild)) | ||
| 3353 | { | ||
| 3354 | for (child = w->hchild; !NILP (child); child = c->next) | ||
| 3355 | { | ||
| 3356 | c = XWINDOW (child); | ||
| 3357 | c->top = w->top; | ||
| 3358 | shrink_window_lowest_first (c, height); | ||
| 3359 | } | ||
| 3360 | } | ||
| 3361 | else if (!NILP (w->vchild)) | ||
| 3362 | { | ||
| 3363 | Lisp_Object last_child; | ||
| 3364 | int delta = old_height - height; | ||
| 3365 | int last_top; | ||
| 3366 | |||
| 3367 | /* Find the last child. We are taking space from lowest windows | ||
| 3368 | first, so we iterate over children from the last child | ||
| 3369 | backwards. */ | ||
| 3370 | for (child = w->vchild; !NILP (child); child = XWINDOW (child)->next) | ||
| 3371 | last_child = child; | ||
| 3372 | |||
| 3373 | /* Assign new heights. We leave only MIN_SAFE_WINDOW_HEIGHT. */ | ||
| 3374 | for (child = last_child; delta && !NILP (child); child = c->prev) | ||
| 3375 | { | ||
| 3376 | int this_one; | ||
| 3377 | |||
| 3378 | c = XWINDOW (child); | ||
| 3379 | this_one = XFASTINT (c->height) - MIN_SAFE_WINDOW_HEIGHT; | ||
| 3380 | |||
| 3381 | if (this_one > delta) | ||
| 3382 | this_one = delta; | ||
| 3383 | |||
| 3384 | shrink_window_lowest_first (c, XFASTINT (c->height) - this_one); | ||
| 3385 | delta -= this_one; | ||
| 3386 | } | ||
| 3387 | |||
| 3388 | /* Compute new positions. */ | ||
| 3389 | last_top = w->top; | ||
| 3390 | for (child = w->vchild; !NILP (child); child = c->next) | ||
| 3391 | { | ||
| 3392 | c = XWINDOW (child); | ||
| 3393 | c->top = make_number (last_top); | ||
| 3394 | shrink_window_lowest_first (c, XFASTINT (c->height)); | ||
| 3395 | last_top += XFASTINT (c->height); | ||
| 3396 | } | ||
| 3397 | } | ||
| 3398 | } | ||
| 3399 | |||
| 3400 | |||
| 3401 | /* Save or restore positions and sizes in the window tree rooted at W. | ||
| 3402 | SAVE_P non-zero means save top position and height in orig_top and | ||
| 3403 | orig_height members of the window structure. Otherwise, restore top | ||
| 3404 | and height from orig_top and orig_height. */ | ||
| 3405 | |||
| 3406 | static void | ||
| 3407 | save_restore_orig_size (w, save_p) | ||
| 3408 | struct window *w; | ||
| 3409 | int save_p; | ||
| 3410 | { | ||
| 3411 | while (w) | ||
| 3412 | { | ||
| 3413 | if (!NILP (w->hchild)) | ||
| 3414 | save_restore_orig_size (XWINDOW (w->hchild), save_p); | ||
| 3415 | else if (!NILP (w->vchild)) | ||
| 3416 | save_restore_orig_size (XWINDOW (w->vchild), save_p); | ||
| 3417 | |||
| 3418 | if (save_p) | ||
| 3419 | { | ||
| 3420 | w->orig_top = w->top; | ||
| 3421 | w->orig_height = w->height; | ||
| 3422 | } | ||
| 3423 | else | ||
| 3424 | { | ||
| 3425 | xassert (INTEGERP (w->orig_top) && INTEGERP (w->orig_height)); | ||
| 3426 | w->top = w->orig_top; | ||
| 3427 | w->height = w->orig_height; | ||
| 3428 | w->orig_height = w->orig_top = Qnil; | ||
| 3429 | } | ||
| 3430 | |||
| 3431 | XSETFASTINT (w->last_modified, 0); | ||
| 3432 | XSETFASTINT (w->last_overlay_modified, 0); | ||
| 3433 | w = NILP (w->next) ? NULL : XWINDOW (w->next); | ||
| 3434 | } | ||
| 3435 | } | ||
| 3436 | |||
| 3437 | |||
| 3438 | /* Grow mini-window W by DELTA lines, DELTA >= 0, or as much as we can | ||
| 3439 | without deleting other windows. */ | ||
| 3440 | |||
| 3441 | void | ||
| 3442 | grow_mini_window (w, delta) | ||
| 3443 | struct window *w; | ||
| 3444 | int delta; | ||
| 3445 | { | ||
| 3446 | struct frame *f = XFRAME (w->frame); | ||
| 3447 | struct window *root; | ||
| 3448 | |||
| 3449 | xassert (MINI_WINDOW_P (w)); | ||
| 3450 | xassert (delta >= 0); | ||
| 3451 | |||
| 3452 | /* Check values of window_min_width and window_min_height for | ||
| 3453 | validity. */ | ||
| 3454 | check_min_window_sizes (); | ||
| 3455 | |||
| 3456 | /* Compute how much we can enlarge the mini-window without deleting | ||
| 3457 | other windows. */ | ||
| 3458 | root = XWINDOW (FRAME_ROOT_WINDOW (f)); | ||
| 3459 | if (delta) | ||
| 3460 | { | ||
| 3461 | int min_height = window_min_size (root, 0, 0, 0); | ||
| 3462 | if (XFASTINT (root->height) - delta < min_height) | ||
| 3463 | delta = XFASTINT (root->height) - min_height; | ||
| 3464 | } | ||
| 3465 | |||
| 3466 | if (delta) | ||
| 3467 | { | ||
| 3468 | /* Save original window sizes and positions, if not already done. */ | ||
| 3469 | if (NILP (root->orig_top)) | ||
| 3470 | save_restore_orig_size (root, 1); | ||
| 3471 | |||
| 3472 | /* Shrink other windows. */ | ||
| 3473 | shrink_window_lowest_first (root, XFASTINT (root->height) - delta); | ||
| 3474 | |||
| 3475 | /* Grow the mini-window. */ | ||
| 3476 | w->top = make_number (XFASTINT (root->top) + XFASTINT (root)->height); | ||
| 3477 | w->height = make_number (XFASTINT (w->height) + delta); | ||
| 3478 | XSETFASTINT (w->last_modified, 0); | ||
| 3479 | XSETFASTINT (w->last_overlay_modified, 0); | ||
| 3480 | |||
| 3481 | adjust_glyphs (f); | ||
| 3482 | } | ||
| 3483 | } | ||
| 3484 | |||
| 3485 | |||
| 3486 | /* Shrink mini-window W back to its original size before the first | ||
| 3487 | call to grow_mini_window. Resize other windows on the same frame | ||
| 3488 | back to their original size. */ | ||
| 3489 | |||
| 3490 | void | ||
| 3491 | shrink_mini_window (w) | ||
| 3492 | struct window *w; | ||
| 3493 | { | ||
| 3494 | struct frame *f = XFRAME (w->frame); | ||
| 3495 | struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f)); | ||
| 3496 | |||
| 3497 | if (!NILP (root->orig_height)) | ||
| 3498 | { | ||
| 3499 | save_restore_orig_size (root, 0); | ||
| 3500 | adjust_glyphs (f); | ||
| 3501 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; | ||
| 3502 | windows_or_buffers_changed = 1; | ||
| 3503 | } | ||
| 3504 | } | ||
| 3505 | |||
| 3506 | |||
| 3507 | |||
| 3312 | /* Mark window cursors off for all windows in the window tree rooted | 3508 | /* Mark window cursors off for all windows in the window tree rooted |
| 3313 | at W by setting their phys_cursor_on_p flag to zero. Called from | 3509 | at W by setting their phys_cursor_on_p flag to zero. Called from |
| 3314 | xterm.c, e.g. when a frame is cleared and thereby all cursors on | 3510 | xterm.c, e.g. when a frame is cleared and thereby all cursors on |