comparison src/window.c @ 63045:872de430453e

* window.c (delete_window): Handle the case where a h/vchild has a h/vchild.
author Jan Djärv <jan.h.d@swipnet.se>
date Mon, 06 Jun 2005 10:38:40 +0000
parents 5283bd0173e6
children dd0624f7bb99 173dee4e2611
comparison
equal deleted inserted replaced
63044:c0b03fb8ef01 63045:872de430453e
1450 /* If parent now has only one child, 1450 /* If parent now has only one child,
1451 put the child into the parent's place. */ 1451 put the child into the parent's place. */
1452 tem = par->hchild; 1452 tem = par->hchild;
1453 if (NILP (tem)) 1453 if (NILP (tem))
1454 tem = par->vchild; 1454 tem = par->vchild;
1455 if (NILP (XWINDOW (tem)->next)) 1455 if (NILP (XWINDOW (tem)->next)) {
1456 replace_window (parent, tem); 1456 replace_window (parent, tem);
1457 par = XWINDOW (tem);
1458 }
1457 1459
1458 /* Since we may be deleting combination windows, we must make sure that 1460 /* Since we may be deleting combination windows, we must make sure that
1459 not only p but all its children have been marked as deleted. */ 1461 not only p but all its children have been marked as deleted. */
1460 if (! NILP (p->hchild)) 1462 if (! NILP (p->hchild))
1461 delete_all_subwindows (XWINDOW (p->hchild)); 1463 delete_all_subwindows (XWINDOW (p->hchild));
1462 else if (! NILP (p->vchild)) 1464 else if (! NILP (p->vchild))
1463 delete_all_subwindows (XWINDOW (p->vchild)); 1465 delete_all_subwindows (XWINDOW (p->vchild));
1464 1466
1465 /* Mark this window as deleted. */ 1467 /* Mark this window as deleted. */
1466 p->buffer = p->hchild = p->vchild = Qnil; 1468 p->buffer = p->hchild = p->vchild = Qnil;
1469
1470 if (! NILP (par->parent))
1471 par = XWINDOW (par->parent);
1472
1473 /* Check if we have a v/hchild with a v/hchild. In that case remove
1474 one of them. */
1475
1476 if (! NILP (par->vchild) && ! NILP (XWINDOW (par->vchild)->vchild))
1477 {
1478 p = XWINDOW (par->vchild);
1479 par->vchild = p->vchild;
1480 tem = p->vchild;
1481 }
1482 else if (! NILP (par->hchild) && ! NILP (XWINDOW (par->hchild)->hchild))
1483 {
1484 p = XWINDOW (par->hchild);
1485 par->hchild = p->hchild;
1486 tem = p->hchild;
1487 }
1488 else
1489 p = 0;
1490
1491 if (p)
1492 {
1493 while (! NILP (tem)) {
1494 XWINDOW (tem)->parent = p->parent;
1495 if (NILP (XWINDOW (tem)->next))
1496 break;
1497 tem = XWINDOW (tem)->next;
1498 }
1499 if (! NILP (tem)) {
1500 /* The next of the v/hchild we are removing is now the next of the
1501 last child for the v/hchild:
1502 Before v/hchild -> v/hchild -> next1 -> next2
1503 |
1504 -> next3
1505 After: v/hchild -> next1 -> next2 -> next3
1506 */
1507 XWINDOW (tem)->next = p->next;
1508 if (! NILP (p->next))
1509 XWINDOW (p->next)->prev = tem;
1510 }
1511 p->next = p->prev = p->vchild = p->hchild = p->buffer = Qnil;
1512 }
1513
1467 1514
1468 /* Adjust glyph matrices. */ 1515 /* Adjust glyph matrices. */
1469 adjust_glyphs (f); 1516 adjust_glyphs (f);
1470 UNBLOCK_INPUT; 1517 UNBLOCK_INPUT;
1471 } 1518 }