aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorRichard M. Stallman1997-02-08 18:34:53 +0000
committerRichard M. Stallman1997-02-08 18:34:53 +0000
commitdb98a733f233eb929be98919fbf0da12b2418196 (patch)
tree53b3b53fd012c218256e66e2e210eae8591c12be /src/window.c
parentc5fe2ff17b803e7dc414cc58546fb531d4f2567b (diff)
downloademacs-db98a733f233eb929be98919fbf0da12b2418196.tar.gz
emacs-db98a733f233eb929be98919fbf0da12b2418196.zip
(change_window_height): Take size from multiple siblings,
nearest ones first, when that can be done without deleting any of them.
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c81
1 files changed, 66 insertions, 15 deletions
diff --git a/src/window.c b/src/window.c
index 071c3dc903c..34b64ca24d4 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2497,6 +2497,8 @@ change_window_height (delta, widthflag)
2497 register int (*setsizefun) () = (widthflag 2497 register int (*setsizefun) () = (widthflag
2498 ? set_window_width 2498 ? set_window_width
2499 : set_window_height); 2499 : set_window_height);
2500 int maximum;
2501 Lisp_Object next, prev;
2500 2502
2501 check_min_window_sizes (); 2503 check_min_window_sizes ();
2502 2504
@@ -2545,22 +2547,71 @@ change_window_height (delta, widthflag)
2545 if (delta == 0) 2547 if (delta == 0)
2546 return; 2548 return;
2547 2549
2548 if (!NILP (p->next) 2550 /* Find the total we can get from other siblings. */
2549 && (*sizefun) (p->next) - delta >= MINSIZE (p->next)) 2551 maximum = 0;
2550 { 2552 for (next = p->next; ! NILP (next); next = XWINDOW (next)->next)
2551 (*setsizefun) (p->next, (*sizefun) (p->next) - delta, 0); 2553 maximum += (*sizefun) (next) - MINSIZE (next);
2552 (*setsizefun) (window, *sizep + delta, 0); 2554 for (prev = p->prev; ! NILP (prev); prev = XWINDOW (prev)->prev)
2553 CURBEG (p->next) += delta; 2555 maximum += (*sizefun) (prev) - MINSIZE (prev);
2554 /* This does not change size of p->next, 2556
2555 but it propagates the new top edge to its children */ 2557 /* If we can get it all from them, do so. */
2556 (*setsizefun) (p->next, (*sizefun) (p->next), 0); 2558 if (delta < maximum)
2557 }
2558 else if (!NILP (p->prev)
2559 && (*sizefun) (p->prev) - delta >= MINSIZE (p->prev))
2560 { 2559 {
2561 (*setsizefun) (p->prev, (*sizefun) (p->prev) - delta, 0); 2560 Lisp_Object first_unaffected;
2562 CURBEG (window) -= delta; 2561 Lisp_Object first_affected;
2563 (*setsizefun) (window, *sizep + delta, 0); 2562
2563 next = p->next;
2564 prev = p->prev;
2565 first_affected = window;
2566 /* Look at one sibling at a time,
2567 moving away from this window in both directions alternately,
2568 and take as much as we can get without deleting that sibling. */
2569 while (delta > 0)
2570 {
2571 if (delta == 0)
2572 break;
2573 if (! NILP (next))
2574 {
2575 int this_one = (*sizefun) (next) - MINSIZE (next);
2576 if (this_one > delta)
2577 this_one = delta;
2578
2579 (*setsizefun) (next, (*sizefun) (next) - this_one, 0);
2580 (*setsizefun) (window, *sizep + this_one, 0);
2581
2582 delta -= this_one;
2583 next = XWINDOW (next)->next;
2584 }
2585 if (delta == 0)
2586 break;
2587 if (! NILP (prev))
2588 {
2589 int this_one = (*sizefun) (prev) - MINSIZE (prev);
2590 if (this_one > delta)
2591 this_one = delta;
2592
2593 first_affected = prev;
2594
2595 (*setsizefun) (prev, (*sizefun) (prev) - this_one, 0);
2596 (*setsizefun) (window, *sizep + this_one, 0);
2597
2598 delta -= this_one;
2599 prev = XWINDOW (prev)->prev;
2600 }
2601 }
2602
2603 /* Now recalculate the edge positions of all the windows affected,
2604 based on the new sizes. */
2605 first_unaffected = next;
2606 prev = first_affected;
2607 for (next = XWINDOW (prev)->next; ! EQ (next, first_unaffected);
2608 prev = next, next = XWINDOW (next)->next)
2609 {
2610 CURBEG (next) = CURBEG (prev) + (*sizefun) (prev);
2611 /* This does not change size of NEXT,
2612 but it propagates the new top edge to its children */
2613 (*setsizefun) (next, (*sizefun) (next), 0);
2614 }
2564 } 2615 }
2565 else 2616 else
2566 { 2617 {