aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann1999-10-16 11:24:23 +0000
committerGerd Moellmann1999-10-16 11:24:23 +0000
commit43b4a21f4e1ad5a085af3d56be3c9d62f54174e3 (patch)
tree6c6061138425224bee1cecf1dc09fa6d1b04e367 /src
parent01fdb1dd7391bdd1c5b9d8fee71bbf537db0ffb6 (diff)
downloademacs-43b4a21f4e1ad5a085af3d56be3c9d62f54174e3.tar.gz
emacs-43b4a21f4e1ad5a085af3d56be3c9d62f54174e3.zip
(enum save_restore_action): New.
(save_restore_orig_size): Change parameter list. Add functionality to check for valid orig_top and orig_height members in a window tree. (grow_mini_window): Call save_restore_orig_size with new parameter list. (shrink_mini_window): Restore old window sizes only if old size information is valid in all windows in a window tree.
Diffstat (limited to 'src')
-rw-r--r--src/window.c80
1 files changed, 59 insertions, 21 deletions
diff --git a/src/window.c b/src/window.c
index dc25039aa8c..683cdc5b363 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3318,8 +3318,16 @@ enlarge_window (window, delta, widthflag)
3318 ***********************************************************************/ 3318 ***********************************************************************/
3319 3319
3320static void shrink_window_lowest_first P_ ((struct window *, int)); 3320static void shrink_window_lowest_first P_ ((struct window *, int));
3321static void save_restore_orig_size P_ ((struct window *, int));
3322 3321
3322enum save_restore_action
3323{
3324 CHECK_ORIG_SIZES,
3325 SAVE_ORIG_SIZES,
3326 RESTORE_ORIG_SIZES
3327};
3328
3329static int save_restore_orig_size P_ ((struct window *,
3330 enum save_restore_action));
3323 3331
3324/* Shrink windows rooted in window W to HEIGHT. Take the space needed 3332/* Shrink windows rooted in window W to HEIGHT. Take the space needed
3325 from lowest windows first. */ 3333 from lowest windows first. */
@@ -3393,40 +3401,70 @@ shrink_window_lowest_first (w, height)
3393} 3401}
3394 3402
3395 3403
3396/* Save or restore positions and sizes in the window tree rooted at W. 3404/* Save, restore, or check positions and sizes in the window tree
3397 SAVE_P non-zero means save top position and height in orig_top and 3405 rooted at W. ACTION says what to do.
3398 orig_height members of the window structure. Otherwise, restore top
3399 and height from orig_top and orig_height. */
3400 3406
3401static void 3407 If ACTION is CHECK_ORIG_SIZES, check if orig_top and orig_height
3402save_restore_orig_size (w, save_p) 3408 members are valid for all windows in the window tree. Value is
3409 non-zero if they are valid.
3410
3411 If ACTION is SAVE_ORIG_SIZES, save members top and height in
3412 orig_top and orig_height for all windows in the tree.
3413
3414 If ACTION is RESTORE_ORIG_SIZES, restore top and height from
3415 values stored in orig_top and orig_height for all windows. */
3416
3417static int
3418save_restore_orig_size (w, action)
3403 struct window *w; 3419 struct window *w;
3404 int save_p; 3420 enum save_restore_action action;
3405{ 3421{
3422 int success_p = 1;
3423
3406 while (w) 3424 while (w)
3407 { 3425 {
3408 if (!NILP (w->hchild)) 3426 if (!NILP (w->hchild))
3409 save_restore_orig_size (XWINDOW (w->hchild), save_p); 3427 {
3428 if (!save_restore_orig_size (XWINDOW (w->hchild), action))
3429 success_p = 0;
3430 }
3410 else if (!NILP (w->vchild)) 3431 else if (!NILP (w->vchild))
3411 save_restore_orig_size (XWINDOW (w->vchild), save_p); 3432 {
3433 if (!save_restore_orig_size (XWINDOW (w->vchild), action))
3434 success_p = 0;
3435 }
3412 3436
3413 if (save_p) 3437 switch (action)
3414 { 3438 {
3439 case CHECK_ORIG_SIZES:
3440 if (!INTEGERP (w->orig_top) || !INTEGERP (w->orig_height))
3441 return 0;
3442 break;
3443
3444 case SAVE_ORIG_SIZES:
3415 w->orig_top = w->top; 3445 w->orig_top = w->top;
3416 w->orig_height = w->height; 3446 w->orig_height = w->height;
3417 } 3447 XSETFASTINT (w->last_modified, 0);
3418 else 3448 XSETFASTINT (w->last_overlay_modified, 0);
3419 { 3449 break;
3450
3451 case RESTORE_ORIG_SIZES:
3420 xassert (INTEGERP (w->orig_top) && INTEGERP (w->orig_height)); 3452 xassert (INTEGERP (w->orig_top) && INTEGERP (w->orig_height));
3421 w->top = w->orig_top; 3453 w->top = w->orig_top;
3422 w->height = w->orig_height; 3454 w->height = w->orig_height;
3423 w->orig_height = w->orig_top = Qnil; 3455 w->orig_height = w->orig_top = Qnil;
3456 XSETFASTINT (w->last_modified, 0);
3457 XSETFASTINT (w->last_overlay_modified, 0);
3458 break;
3459
3460 default:
3461 abort ();
3424 } 3462 }
3425 3463
3426 XSETFASTINT (w->last_modified, 0);
3427 XSETFASTINT (w->last_overlay_modified, 0);
3428 w = NILP (w->next) ? NULL : XWINDOW (w->next); 3464 w = NILP (w->next) ? NULL : XWINDOW (w->next);
3429 } 3465 }
3466
3467 return success_p;
3430} 3468}
3431 3469
3432 3470
@@ -3461,8 +3499,8 @@ grow_mini_window (w, delta)
3461 if (delta) 3499 if (delta)
3462 { 3500 {
3463 /* Save original window sizes and positions, if not already done. */ 3501 /* Save original window sizes and positions, if not already done. */
3464 if (NILP (root->orig_top)) 3502 if (!save_restore_orig_size (root, CHECK_ORIG_SIZES))
3465 save_restore_orig_size (root, 1); 3503 save_restore_orig_size (root, SAVE_ORIG_SIZES);
3466 3504
3467 /* Shrink other windows. */ 3505 /* Shrink other windows. */
3468 shrink_window_lowest_first (root, XFASTINT (root->height) - delta); 3506 shrink_window_lowest_first (root, XFASTINT (root->height) - delta);
@@ -3490,9 +3528,9 @@ shrink_mini_window (w)
3490 struct frame *f = XFRAME (w->frame); 3528 struct frame *f = XFRAME (w->frame);
3491 struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f)); 3529 struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f));
3492 3530
3493 if (!NILP (root->orig_height)) 3531 if (save_restore_orig_size (root, CHECK_ORIG_SIZES))
3494 { 3532 {
3495 save_restore_orig_size (root, 0); 3533 save_restore_orig_size (root, RESTORE_ORIG_SIZES);
3496 adjust_glyphs (f); 3534 adjust_glyphs (f);
3497 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 3535 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
3498 windows_or_buffers_changed = 1; 3536 windows_or_buffers_changed = 1;