comparison src/window.c @ 26046:9204dfa34c1b

(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.
author Gerd Moellmann <gerd@gnu.org>
date Sat, 16 Oct 1999 11:24:23 +0000
parents 0d73a1e7b7f2
children da4e7625a62d
comparison
equal deleted inserted replaced
26045:03ebfe42764f 26046:9204dfa34c1b
3316 /*********************************************************************** 3316 /***********************************************************************
3317 Resizing Mini-Windows 3317 Resizing Mini-Windows
3318 ***********************************************************************/ 3318 ***********************************************************************/
3319 3319
3320 static void shrink_window_lowest_first P_ ((struct window *, int)); 3320 static void shrink_window_lowest_first P_ ((struct window *, int));
3321 static void save_restore_orig_size P_ ((struct window *, int)); 3321
3322 3322 enum save_restore_action
3323 {
3324 CHECK_ORIG_SIZES,
3325 SAVE_ORIG_SIZES,
3326 RESTORE_ORIG_SIZES
3327 };
3328
3329 static 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. */
3326 3334
3327 static void 3335 static void
3391 } 3399 }
3392 } 3400 }
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 3406
3399 and height from orig_top and orig_height. */ 3407 If ACTION is CHECK_ORIG_SIZES, check if orig_top and orig_height
3400 3408 members are valid for all windows in the window tree. Value is
3401 static void 3409 non-zero if they are valid.
3402 save_restore_orig_size (w, save_p) 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
3417 static int
3418 save_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
3433 /* Grow mini-window W by DELTA lines, DELTA >= 0, or as much as we can 3471 /* Grow mini-window W by DELTA lines, DELTA >= 0, or as much as we can
3434 without deleting other windows. */ 3472 without deleting other windows. */
3459 } 3497 }
3460 3498
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);
3469 3507
3470 /* Grow the mini-window. */ 3508 /* Grow the mini-window. */
3488 struct window *w; 3526 struct window *w;
3489 { 3527 {
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;
3499 } 3537 }
3500 else if (XFASTINT (w->height) > 1) 3538 else if (XFASTINT (w->height) > 1)