aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorJoakim Verona2013-03-26 16:20:17 +0100
committerJoakim Verona2013-03-26 16:20:17 +0100
commit6f6db22fc74ffb7fbdd4d805545b7e28cd59f0c8 (patch)
tree4a58903b4c3d010e90fc37fe10ea4d9895876d01 /src/window.c
parent62dd123f7c11ddbe156bc0e84dcb7ca1da5368bb (diff)
parent48c226c2c2592e31a47559bd1689fcc4354d9479 (diff)
downloademacs-6f6db22fc74ffb7fbdd4d805545b7e28cd59f0c8.tar.gz
emacs-6f6db22fc74ffb7fbdd4d805545b7e28cd59f0c8.zip
conflict resolve
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c228
1 files changed, 112 insertions, 116 deletions
diff --git a/src/window.c b/src/window.c
index c987d08534e..a2e6a5a0602 100644
--- a/src/window.c
+++ b/src/window.c
@@ -85,8 +85,8 @@ static int foreach_window_1 (struct window *,
85 int (* fn) (struct window *, void *), 85 int (* fn) (struct window *, void *),
86 void *); 86 void *);
87static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object); 87static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object);
88static int window_resize_check (struct window *, int); 88static int window_resize_check (struct window *, bool);
89static void window_resize_apply (struct window *, int); 89static void window_resize_apply (struct window *, bool);
90static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); 90static Lisp_Object select_window (Lisp_Object, Lisp_Object, int);
91static void select_window_1 (Lisp_Object, bool); 91static void select_window_1 (Lisp_Object, bool);
92 92
@@ -636,30 +636,37 @@ Return nil if WINDOW has no previous sibling. */)
636 636
637DEFUN ("window-combination-limit", Fwindow_combination_limit, Swindow_combination_limit, 1, 1, 0, 637DEFUN ("window-combination-limit", Fwindow_combination_limit, Swindow_combination_limit, 1, 1, 0,
638 doc: /* Return combination limit of window WINDOW. 638 doc: /* Return combination limit of window WINDOW.
639WINDOW must be a valid window used in horizontal or vertical combination.
639If the return value is nil, child windows of WINDOW can be recombined with 640If the return value is nil, child windows of WINDOW can be recombined with
640WINDOW's siblings. A return value of t means that child windows of 641WINDOW's siblings. A return value of t means that child windows of
641WINDOW are never \(re-)combined with WINDOW's siblings. 642WINDOW are never \(re-)combined with WINDOW's siblings. */)
642
643WINDOW must be a valid window. The return value is meaningful for
644internal windows only. */)
645 (Lisp_Object window) 643 (Lisp_Object window)
646{ 644{
645 struct window *w;
646
647 CHECK_VALID_WINDOW (window); 647 CHECK_VALID_WINDOW (window);
648 w = XWINDOW (window);
649 if (!NILP (w->buffer))
650 error ("Combination limit is meaningful for internal windows only");
648 return XWINDOW (window)->combination_limit; 651 return XWINDOW (window)->combination_limit;
649} 652}
650 653
651DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0, 654DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0,
652 doc: /* Set combination limit of window WINDOW to LIMIT; return LIMIT. 655 doc: /* Set combination limit of window WINDOW to LIMIT; return LIMIT.
656WINDOW must be a valid window used in horizontal or vertical combination.
653If LIMIT is nil, child windows of WINDOW can be recombined with WINDOW's 657If LIMIT is nil, child windows of WINDOW can be recombined with WINDOW's
654siblings. LIMIT t means that child windows of WINDOW are never 658siblings. LIMIT t means that child windows of WINDOW are never
655\(re-)combined with WINDOW's siblings. Other values are reserved for 659\(re-)combined with WINDOW's siblings. Other values are reserved for
656future use. 660future use. */)
657
658WINDOW must be a valid window. Setting the combination limit is
659meaningful for internal windows only. */)
660 (Lisp_Object window, Lisp_Object limit) 661 (Lisp_Object window, Lisp_Object limit)
661{ 662{
662 wset_combination_limit (decode_valid_window (window), limit); 663 struct window *w;
664
665 CHECK_VALID_WINDOW (window);
666 w = XWINDOW (window);
667 if (!NILP (w->buffer))
668 error ("Combination limit is meaningful for internal windows only");
669 wset_combination_limit (w, limit);
663 return limit; 670 return limit;
664} 671}
665 672
@@ -686,7 +693,7 @@ On a graphical display, this total height is reported as an
686integer multiple of the default character height. */) 693integer multiple of the default character height. */)
687 (Lisp_Object window) 694 (Lisp_Object window)
688{ 695{
689 return decode_valid_window (window)->total_lines; 696 return make_number (decode_valid_window (window)->total_lines);
690} 697}
691 698
692DEFUN ("window-total-width", Fwindow_total_width, Swindow_total_width, 0, 1, 0, 699DEFUN ("window-total-width", Fwindow_total_width, Swindow_total_width, 0, 1, 0,
@@ -701,7 +708,7 @@ On a graphical display, this total width is reported as an
701integer multiple of the default character width. */) 708integer multiple of the default character width. */)
702 (Lisp_Object window) 709 (Lisp_Object window)
703{ 710{
704 return decode_valid_window (window)->total_cols; 711 return make_number (decode_valid_window (window)->total_cols);
705} 712}
706 713
707DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0, 714DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0,
@@ -740,7 +747,7 @@ value is 0 if there is no window to the left of WINDOW.
740WINDOW must be a valid window and defaults to the selected one. */) 747WINDOW must be a valid window and defaults to the selected one. */)
741 (Lisp_Object window) 748 (Lisp_Object window)
742{ 749{
743 return decode_valid_window (window)->left_col; 750 return make_number (decode_valid_window (window)->left_col);
744} 751}
745 752
746DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0, 753DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0,
@@ -752,7 +759,7 @@ there is no window above WINDOW.
752WINDOW must be a valid window and defaults to the selected one. */) 759WINDOW must be a valid window and defaults to the selected one. */)
753 (Lisp_Object window) 760 (Lisp_Object window)
754{ 761{
755 return decode_valid_window (window)->top_line; 762 return make_number (decode_valid_window (window)->top_line);
756} 763}
757 764
758/* Return the number of lines of W's body. Don't count any mode or 765/* Return the number of lines of W's body. Don't count any mode or
@@ -761,7 +768,7 @@ WINDOW must be a valid window and defaults to the selected one. */)
761static int 768static int
762window_body_lines (struct window *w) 769window_body_lines (struct window *w)
763{ 770{
764 int height = XFASTINT (w->total_lines); 771 int height = w->total_lines;
765 772
766 if (!MINI_WINDOW_P (w)) 773 if (!MINI_WINDOW_P (w))
767 { 774 {
@@ -783,7 +790,7 @@ int
783window_body_cols (struct window *w) 790window_body_cols (struct window *w)
784{ 791{
785 struct frame *f = XFRAME (WINDOW_FRAME (w)); 792 struct frame *f = XFRAME (WINDOW_FRAME (w));
786 int width = XINT (w->total_cols); 793 int width = w->total_cols;
787 794
788 if (WINDOW_HAS_VERTICAL_SCROLL_BAR (w)) 795 if (WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
789 /* Scroll bars occupy a few columns. */ 796 /* Scroll bars occupy a few columns. */
@@ -1369,7 +1376,7 @@ check_window_containing (struct window *w, void *user_data)
1369 1376
1370Lisp_Object 1377Lisp_Object
1371window_from_coordinates (struct frame *f, int x, int y, 1378window_from_coordinates (struct frame *f, int x, int y,
1372 enum window_part *part, int tool_bar_p) 1379 enum window_part *part, bool tool_bar_p)
1373{ 1380{
1374 Lisp_Object window; 1381 Lisp_Object window;
1375 struct check_window_data cw; 1382 struct check_window_data cw;
@@ -2001,12 +2008,12 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag)
2001 if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame)))) 2008 if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame))))
2002 fset_root_window (XFRAME (o->frame), new); 2009 fset_root_window (XFRAME (o->frame), new);
2003 2010
2004 if (setflag) 2011 if (setflag)
2005 { 2012 {
2006 wset_left_col (n, o->left_col); 2013 n->left_col = o->left_col;
2007 wset_top_line (n, o->top_line); 2014 n->top_line = o->top_line;
2008 wset_total_cols (n, o->total_cols); 2015 n->total_cols = o->total_cols;
2009 wset_total_lines (n, o->total_lines); 2016 n->total_lines = o->total_lines;
2010 wset_normal_cols (n, o->normal_cols); 2017 wset_normal_cols (n, o->normal_cols);
2011 wset_normal_cols (o, make_float (1.0)); 2018 wset_normal_cols (o, make_float (1.0));
2012 wset_normal_lines (n, o->normal_lines); 2019 wset_normal_lines (n, o->normal_lines);
@@ -2056,7 +2063,7 @@ recombine_windows (Lisp_Object window)
2056{ 2063{
2057 struct window *w, *p, *c; 2064 struct window *w, *p, *c;
2058 Lisp_Object parent, child; 2065 Lisp_Object parent, child;
2059 int horflag; 2066 bool horflag;
2060 2067
2061 w = XWINDOW (window); 2068 w = XWINDOW (window);
2062 parent = w->parent; 2069 parent = w->parent;
@@ -2091,12 +2098,12 @@ recombine_windows (Lisp_Object window)
2091 2098
2092 if (horflag) 2099 if (horflag)
2093 wset_normal_cols (c, 2100 wset_normal_cols (c,
2094 make_float (XFLOATINT (c->total_cols) 2101 make_float ((double) c->total_cols
2095 / XFLOATINT (p->total_cols))); 2102 / (double) p->total_cols));
2096 else 2103 else
2097 wset_normal_lines (c, 2104 wset_normal_lines (c,
2098 make_float (XFLOATINT (c->total_lines) 2105 make_float ((double) c->total_lines
2099 / XFLOATINT (p->total_lines))); 2106 / (double) p->total_lines));
2100 2107
2101 if (NILP (c->next)) 2108 if (NILP (c->next))
2102 { 2109 {
@@ -2855,9 +2862,8 @@ window-start value is reasonable when this function is called. */)
2855 if (NILP (w->buffer)) 2862 if (NILP (w->buffer))
2856 { 2863 {
2857 /* Resize child windows vertically. */ 2864 /* Resize child windows vertically. */
2858 XSETINT (delta, XINT (r->total_lines) 2865 XSETINT (delta, r->total_lines - w->total_lines);
2859 - XINT (w->total_lines)); 2866 w->top_line = r->top_line;
2860 wset_top_line (w, r->top_line);
2861 resize_root_window (window, delta, Qnil, Qnil); 2867 resize_root_window (window, delta, Qnil, Qnil);
2862 if (window_resize_check (w, 0)) 2868 if (window_resize_check (w, 0))
2863 window_resize_apply (w, 0); 2869 window_resize_apply (w, 0);
@@ -2873,10 +2879,8 @@ window-start value is reasonable when this function is called. */)
2873 /* Resize child windows horizontally. */ 2879 /* Resize child windows horizontally. */
2874 if (!resize_failed) 2880 if (!resize_failed)
2875 { 2881 {
2876 wset_left_col (w, r->left_col); 2882 w->left_col = r->left_col;
2877 XSETINT (delta, 2883 XSETINT (delta, r->total_cols - w->total_cols);
2878 XINT (r->total_cols) - XINT (w->total_cols));
2879 wset_left_col (w, r->left_col);
2880 resize_root_window (window, delta, Qt, Qnil); 2884 resize_root_window (window, delta, Qt, Qnil);
2881 if (window_resize_check (w, 1)) 2885 if (window_resize_check (w, 1))
2882 window_resize_apply (w, 1); 2886 window_resize_apply (w, 1);
@@ -3149,7 +3153,8 @@ If FRAME is omitted or nil, it defaults to the selected frame. */)
3149 reset from the buffer's local settings. */ 3153 reset from the buffer's local settings. */
3150 3154
3151void 3155void
3152set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int keep_margins_p) 3156set_window_buffer (Lisp_Object window, Lisp_Object buffer,
3157 bool run_hooks_p, bool keep_margins_p)
3153{ 3158{
3154 struct window *w = XWINDOW (window); 3159 struct window *w = XWINDOW (window);
3155 struct buffer *b = XBUFFER (buffer); 3160 struct buffer *b = XBUFFER (buffer);
@@ -3407,7 +3412,7 @@ temp_output_buffer_show (register Lisp_Object buf)
3407 WINDOW its only vertical child (HORFLAG 1 means make WINDOW its only 3412 WINDOW its only vertical child (HORFLAG 1 means make WINDOW its only
3408 horizontal child). */ 3413 horizontal child). */
3409static void 3414static void
3410make_parent_window (Lisp_Object window, int horflag) 3415make_parent_window (Lisp_Object window, bool horflag)
3411{ 3416{
3412 Lisp_Object parent; 3417 Lisp_Object parent;
3413 register struct window *o, *p; 3418 register struct window *o, *p;
@@ -3446,10 +3451,6 @@ make_window (void)
3446 w = allocate_window (); 3451 w = allocate_window ();
3447 /* Initialize Lisp data. Note that allocate_window initializes all 3452 /* Initialize Lisp data. Note that allocate_window initializes all
3448 Lisp data to nil, so do it only for slots which should not be nil. */ 3453 Lisp data to nil, so do it only for slots which should not be nil. */
3449 wset_left_col (w, make_number (0));
3450 wset_top_line (w, make_number (0));
3451 wset_total_lines (w, make_number (0));
3452 wset_total_cols (w, make_number (0));
3453 wset_normal_lines (w, make_float (1.0)); 3454 wset_normal_lines (w, make_float (1.0));
3454 wset_normal_cols (w, make_float (1.0)); 3455 wset_normal_cols (w, make_float (1.0));
3455 wset_new_total (w, make_number (0)); 3456 wset_new_total (w, make_number (0));
@@ -3520,7 +3521,7 @@ Note: This function does not operate on any child windows of WINDOW. */)
3520 `window-min-height' or `window-min-width'. It does check that window 3521 `window-min-height' or `window-min-width'. It does check that window
3521 sizes do not drop below one line (two columns). */ 3522 sizes do not drop below one line (two columns). */
3522static int 3523static int
3523window_resize_check (struct window *w, int horflag) 3524window_resize_check (struct window *w, bool horflag)
3524{ 3525{
3525 struct window *c; 3526 struct window *c;
3526 3527
@@ -3601,7 +3602,7 @@ window_resize_check (struct window *w, int horflag)
3601 This function does not perform any error checks. Make sure you have 3602 This function does not perform any error checks. Make sure you have
3602 run window_resize_check on W before applying this function. */ 3603 run window_resize_check on W before applying this function. */
3603static void 3604static void
3604window_resize_apply (struct window *w, int horflag) 3605window_resize_apply (struct window *w, bool horflag)
3605{ 3606{
3606 struct window *c; 3607 struct window *c;
3607 int pos; 3608 int pos;
@@ -3610,19 +3611,19 @@ window_resize_apply (struct window *w, int horflag)
3610 parent window has been set *before*. */ 3611 parent window has been set *before*. */
3611 if (horflag) 3612 if (horflag)
3612 { 3613 {
3613 wset_total_cols (w, w->new_total); 3614 w->total_cols = XFASTINT (w->new_total);
3614 if (NUMBERP (w->new_normal)) 3615 if (NUMBERP (w->new_normal))
3615 wset_normal_cols (w, w->new_normal); 3616 wset_normal_cols (w, w->new_normal);
3616 3617
3617 pos = XINT (w->left_col); 3618 pos = w->left_col;
3618 } 3619 }
3619 else 3620 else
3620 { 3621 {
3621 wset_total_lines (w, w->new_total); 3622 w->total_lines = XFASTINT (w->new_total);
3622 if (NUMBERP (w->new_normal)) 3623 if (NUMBERP (w->new_normal))
3623 wset_normal_lines (w, w->new_normal); 3624 wset_normal_lines (w, w->new_normal);
3624 3625
3625 pos = XINT (w->top_line); 3626 pos = w->top_line;
3626 } 3627 }
3627 3628
3628 if (!NILP (w->vchild)) 3629 if (!NILP (w->vchild))
@@ -3632,12 +3633,12 @@ window_resize_apply (struct window *w, int horflag)
3632 while (c) 3633 while (c)
3633 { 3634 {
3634 if (horflag) 3635 if (horflag)
3635 wset_left_col (c, make_number (pos)); 3636 c->left_col = pos;
3636 else 3637 else
3637 wset_top_line (c, make_number (pos)); 3638 c->top_line = pos;
3638 window_resize_apply (c, horflag); 3639 window_resize_apply (c, horflag);
3639 if (!horflag) 3640 if (!horflag)
3640 pos = pos + XINT (c->total_lines); 3641 pos = pos + c->total_lines;
3641 c = NILP (c->next) ? 0 : XWINDOW (c->next); 3642 c = NILP (c->next) ? 0 : XWINDOW (c->next);
3642 } 3643 }
3643 } 3644 }
@@ -3648,12 +3649,12 @@ window_resize_apply (struct window *w, int horflag)
3648 while (c) 3649 while (c)
3649 { 3650 {
3650 if (horflag) 3651 if (horflag)
3651 wset_left_col (c, make_number (pos)); 3652 c->left_col = pos;
3652 else 3653 else
3653 wset_top_line (c, make_number (pos)); 3654 c->top_line = pos;
3654 window_resize_apply (c, horflag); 3655 window_resize_apply (c, horflag);
3655 if (horflag) 3656 if (horflag)
3656 pos = pos + XINT (c->total_cols); 3657 pos = pos + c->total_cols;
3657 c = NILP (c->next) ? 0 : XWINDOW (c->next); 3658 c = NILP (c->next) ? 0 : XWINDOW (c->next);
3658 } 3659 }
3659 } 3660 }
@@ -3682,11 +3683,11 @@ be applied on the Elisp level. */)
3682{ 3683{
3683 struct frame *f = decode_live_frame (frame); 3684 struct frame *f = decode_live_frame (frame);
3684 struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f)); 3685 struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f));
3685 int horflag = !NILP (horizontal); 3686 bool horflag = !NILP (horizontal);
3686 3687
3687 if (!window_resize_check (r, horflag) 3688 if (!window_resize_check (r, horflag)
3688 || ! EQ (r->new_total, 3689 || (XINT (r->new_total)
3689 (horflag ? r->total_cols : r->total_lines))) 3690 != (horflag ? r->total_cols : r->total_lines)))
3690 return Qnil; 3691 return Qnil;
3691 3692
3692 block_input (); 3693 block_input ();
@@ -3712,7 +3713,7 @@ be applied on the Elisp level. */)
3712 satisfy the request. The result will be meaningful if and only if 3713 satisfy the request. The result will be meaningful if and only if
3713 F's windows have meaningful sizes when you call this. */ 3714 F's windows have meaningful sizes when you call this. */
3714void 3715void
3715resize_frame_windows (struct frame *f, int size, int horflag) 3716resize_frame_windows (struct frame *f, int size, bool horflag)
3716{ 3717{
3717 Lisp_Object root = f->root_window; 3718 Lisp_Object root = f->root_window;
3718 struct window *r = XWINDOW (root); 3719 struct window *r = XWINDOW (root);
@@ -3726,18 +3727,17 @@ resize_frame_windows (struct frame *f, int size, int horflag)
3726 - ((FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f)) 3727 - ((FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f))
3727 ? 1 : 0))); 3728 ? 1 : 0)));
3728 3729
3729 wset_top_line (r, make_number (FRAME_TOP_MARGIN (f))); 3730 r->top_line = FRAME_TOP_MARGIN (f);
3730 if (NILP (r->vchild) && NILP (r->hchild)) 3731 if (NILP (r->vchild) && NILP (r->hchild))
3731 /* For a leaf root window just set the size. */ 3732 /* For a leaf root window just set the size. */
3732 if (horflag) 3733 if (horflag)
3733 wset_total_cols (r, make_number (new_size)); 3734 r->total_cols = new_size;
3734 else 3735 else
3735 wset_total_lines (r, make_number (new_size)); 3736 r->total_lines = new_size;
3736 else 3737 else
3737 { 3738 {
3738 /* old_size is the old size of the frame's root window. */ 3739 /* old_size is the old size of the frame's root window. */
3739 int old_size = XFASTINT (horflag ? r->total_cols 3740 int old_size = horflag ? r->total_cols : r->total_lines;
3740 : r->total_lines);
3741 Lisp_Object delta; 3741 Lisp_Object delta;
3742 3742
3743 XSETINT (delta, new_size - old_size); 3743 XSETINT (delta, new_size - old_size);
@@ -3767,9 +3767,9 @@ resize_frame_windows (struct frame *f, int size, int horflag)
3767 root = f->selected_window; 3767 root = f->selected_window;
3768 Fdelete_other_windows_internal (root, Qnil); 3768 Fdelete_other_windows_internal (root, Qnil);
3769 if (horflag) 3769 if (horflag)
3770 wset_total_cols (XWINDOW (root), make_number (new_size)); 3770 XWINDOW (root)->total_cols = new_size;
3771 else 3771 else
3772 wset_total_lines (XWINDOW (root), make_number (new_size)); 3772 XWINDOW (root)->total_lines = new_size;
3773 } 3773 }
3774 } 3774 }
3775 } 3775 }
@@ -3779,13 +3779,12 @@ resize_frame_windows (struct frame *f, int size, int horflag)
3779 { 3779 {
3780 m = XWINDOW (mini); 3780 m = XWINDOW (mini);
3781 if (horflag) 3781 if (horflag)
3782 wset_total_cols (m, make_number (size)); 3782 m->total_cols = size;
3783 else 3783 else
3784 { 3784 {
3785 /* Are we sure we always want 1 line here? */ 3785 /* Are we sure we always want 1 line here? */
3786 wset_total_lines (m, make_number (1)); 3786 m->total_lines = 1;
3787 wset_top_line 3787 m->top_line = r->top_line + r->total_lines;
3788 (m, make_number (XINT (r->top_line) + XINT (r->total_lines)));
3789 } 3788 }
3790 } 3789 }
3791 3790
@@ -3826,7 +3825,7 @@ set correctly. See the code of `split-window' for how this is done. */)
3826 register Lisp_Object new, frame, reference; 3825 register Lisp_Object new, frame, reference;
3827 register struct window *o, *p, *n, *r; 3826 register struct window *o, *p, *n, *r;
3828 struct frame *f; 3827 struct frame *f;
3829 int horflag 3828 bool horflag
3830 /* HORFLAG is 1 when we split side-by-side, 0 otherwise. */ 3829 /* HORFLAG is 1 when we split side-by-side, 0 otherwise. */
3831 = EQ (side, Qt) || EQ (side, Qleft) || EQ (side, Qright); 3830 = EQ (side, Qt) || EQ (side, Qleft) || EQ (side, Qright);
3832 int combination_limit = 0; 3831 int combination_limit = 0;
@@ -3869,20 +3868,21 @@ set correctly. See the code of `split-window' for how this is done. */)
3869 p = XWINDOW (o->parent); 3868 p = XWINDOW (o->parent);
3870 /* Temporarily pretend we split the parent window. */ 3869 /* Temporarily pretend we split the parent window. */
3871 wset_new_total 3870 wset_new_total
3872 (p, make_number (XINT (horflag ? p->total_cols : p->total_lines) 3871 (p, make_number ((horflag ? p->total_cols : p->total_lines)
3873 - XINT (total_size))); 3872 - XINT (total_size)));
3874 if (!window_resize_check (p, horflag)) 3873 if (!window_resize_check (p, horflag))
3875 error ("Window sizes don't fit"); 3874 error ("Window sizes don't fit");
3876 else 3875 else
3877 /* Undo the temporary pretension. */ 3876 /* Undo the temporary pretension. */
3878 wset_new_total (p, horflag ? p->total_cols : p->total_lines); 3877 wset_new_total (p, make_number
3878 (horflag ? p->total_cols : p->total_lines));
3879 } 3879 }
3880 else 3880 else
3881 { 3881 {
3882 if (!window_resize_check (o, horflag)) 3882 if (!window_resize_check (o, horflag))
3883 error ("Resizing old window failed"); 3883 error ("Resizing old window failed");
3884 else if (XINT (total_size) + XINT (o->new_total) 3884 else if (XINT (total_size) + XINT (o->new_total)
3885 != XINT (horflag ? o->total_cols : o->total_lines)) 3885 != (horflag ? o->total_cols : o->total_lines))
3886 error ("Sum of sizes of old and new window don't fit"); 3886 error ("Sum of sizes of old and new window don't fit");
3887 } 3887 }
3888 3888
@@ -3902,7 +3902,8 @@ set correctly. See the code of `split-window' for how this is done. */)
3902 that its children get merged into another window. */ 3902 that its children get merged into another window. */
3903 wset_combination_limit (p, Qt); 3903 wset_combination_limit (p, Qt);
3904 /* These get applied below. */ 3904 /* These get applied below. */
3905 wset_new_total (p, horflag ? o->total_cols : o->total_lines); 3905 wset_new_total (p, make_number
3906 (horflag ? o->total_cols : o->total_lines));
3906 wset_new_normal (p, new_normal); 3907 wset_new_normal (p, new_normal);
3907 } 3908 }
3908 else 3909 else
@@ -3954,13 +3955,13 @@ set correctly. See the code of `split-window' for how this is done. */)
3954 /* Directly assign orthogonal coordinates and sizes. */ 3955 /* Directly assign orthogonal coordinates and sizes. */
3955 if (horflag) 3956 if (horflag)
3956 { 3957 {
3957 wset_top_line (n, o->top_line); 3958 n->top_line = o->top_line;
3958 wset_total_lines (n, o->total_lines); 3959 n->total_lines = o->total_lines;
3959 } 3960 }
3960 else 3961 else
3961 { 3962 {
3962 wset_left_col (n, o->left_col); 3963 n->left_col = o->left_col;
3963 wset_total_cols (n, o->total_cols); 3964 n->total_cols = o->total_cols;
3964 } 3965 }
3965 3966
3966 /* Iso-coordinates and sizes are assigned by window_resize_apply, 3967 /* Iso-coordinates and sizes are assigned by window_resize_apply,
@@ -3995,7 +3996,7 @@ Signal an error when WINDOW is the only window on its frame. */)
3995 register Lisp_Object parent, sibling, frame, root; 3996 register Lisp_Object parent, sibling, frame, root;
3996 struct window *w, *p, *s, *r; 3997 struct window *w, *p, *s, *r;
3997 struct frame *f; 3998 struct frame *f;
3998 int horflag; 3999 bool horflag;
3999 int before_sibling = 0; 4000 int before_sibling = 0;
4000 4001
4001 w = decode_any_window (window); 4002 w = decode_any_window (window);
@@ -4049,8 +4050,8 @@ Signal an error when WINDOW is the only window on its frame. */)
4049 } 4050 }
4050 4051
4051 if (window_resize_check (r, horflag) 4052 if (window_resize_check (r, horflag)
4052 && EQ (r->new_total, 4053 && (XINT (r->new_total)
4053 (horflag ? r->total_cols : r->total_lines))) 4054 == (horflag ? r->total_cols : r->total_lines)))
4054 /* We can delete WINDOW now. */ 4055 /* We can delete WINDOW now. */
4055 { 4056 {
4056 4057
@@ -4199,10 +4200,8 @@ grow_mini_window (struct window *w, int delta)
4199 window_resize_apply (r, 0); 4200 window_resize_apply (r, 0);
4200 4201
4201 /* Grow the mini-window. */ 4202 /* Grow the mini-window. */
4202 wset_top_line 4203 w->top_line = r->top_line + r->total_lines;
4203 (w, make_number (XFASTINT (r->top_line) + XFASTINT (r->total_lines))); 4204 w->total_lines -= XINT (value);
4204 wset_total_lines
4205 (w, make_number (XFASTINT (w->total_lines) - XINT (value)));
4206 w->last_modified = 0; 4205 w->last_modified = 0;
4207 w->last_overlay_modified = 0; 4206 w->last_overlay_modified = 0;
4208 4207
@@ -4224,7 +4223,7 @@ shrink_mini_window (struct window *w)
4224 4223
4225 eassert (MINI_WINDOW_P (w)); 4224 eassert (MINI_WINDOW_P (w));
4226 4225
4227 size = XINT (w->total_lines); 4226 size = w->total_lines;
4228 if (size > 1) 4227 if (size > 1)
4229 { 4228 {
4230 root = FRAME_ROOT_WINDOW (f); 4229 root = FRAME_ROOT_WINDOW (f);
@@ -4237,9 +4236,8 @@ shrink_mini_window (struct window *w)
4237 window_resize_apply (r, 0); 4236 window_resize_apply (r, 0);
4238 4237
4239 /* Shrink the mini-window. */ 4238 /* Shrink the mini-window. */
4240 wset_top_line (w, make_number (XFASTINT (r->top_line) 4239 w->top_line = r->top_line + r->total_lines;
4241 + XFASTINT (r->total_lines))); 4240 w->total_lines = 1;
4242 wset_total_lines (w, make_number (1));
4243 4241
4244 w->last_modified = 0; 4242 w->last_modified = 0;
4245 w->last_overlay_modified = 0; 4243 w->last_overlay_modified = 0;
@@ -4273,7 +4271,7 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini
4273 error ("Cannot resize a minibuffer-only frame"); 4271 error ("Cannot resize a minibuffer-only frame");
4274 4272
4275 r = XWINDOW (FRAME_ROOT_WINDOW (f)); 4273 r = XWINDOW (FRAME_ROOT_WINDOW (f));
4276 height = XINT (r->total_lines) + XINT (w->total_lines); 4274 height = r->total_lines + w->total_lines;
4277 if (window_resize_check (r, 0) 4275 if (window_resize_check (r, 0)
4278 && XINT (w->new_total) > 0 4276 && XINT (w->new_total) > 0
4279 && height == XINT (r->new_total) + XINT (w->new_total)) 4277 && height == XINT (r->new_total) + XINT (w->new_total))
@@ -4281,9 +4279,8 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini
4281 block_input (); 4279 block_input ();
4282 window_resize_apply (r, 0); 4280 window_resize_apply (r, 0);
4283 4281
4284 wset_total_lines (w, w->new_total); 4282 w->total_lines = XFASTINT (w->new_total);
4285 wset_top_line (w, make_number (XINT (r->top_line) 4283 w->top_line = r->top_line + r->total_lines;
4286 + XINT (r->total_lines)));
4287 4284
4288 windows_or_buffers_changed++; 4285 windows_or_buffers_changed++;
4289 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 4286 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
@@ -4323,7 +4320,7 @@ mark_window_cursors_off (struct window *w)
4323int 4320int
4324window_internal_height (struct window *w) 4321window_internal_height (struct window *w)
4325{ 4322{
4326 int ht = XFASTINT (w->total_lines); 4323 int ht = w->total_lines;
4327 4324
4328 if (!MINI_WINDOW_P (w)) 4325 if (!MINI_WINDOW_P (w))
4329 { 4326 {
@@ -4633,7 +4630,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4633 even if there is a header line. */ 4630 even if there is a header line. */
4634 this_scroll_margin = max (0, scroll_margin); 4631 this_scroll_margin = max (0, scroll_margin);
4635 this_scroll_margin 4632 this_scroll_margin
4636 = min (this_scroll_margin, XFASTINT (w->total_lines) / 4); 4633 = min (this_scroll_margin, w->total_lines / 4);
4637 this_scroll_margin *= FRAME_LINE_HEIGHT (it.f); 4634 this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
4638 4635
4639 if (n > 0) 4636 if (n > 0)
@@ -4810,7 +4807,7 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror)
4810 { 4807 {
4811 /* Don't use a scroll margin that is negative or too large. */ 4808 /* Don't use a scroll margin that is negative or too large. */
4812 int this_scroll_margin = 4809 int this_scroll_margin =
4813 max (0, min (scroll_margin, XINT (w->total_lines) / 4)); 4810 max (0, min (scroll_margin, w->total_lines / 4));
4814 4811
4815 set_marker_restricted_both (w->start, w->buffer, pos, pos_byte); 4812 set_marker_restricted_both (w->start, w->buffer, pos, pos_byte);
4816 w->start_at_line_beg = !NILP (bolp); 4813 w->start_at_line_beg = !NILP (bolp);
@@ -5227,7 +5224,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5227 /* Do this after making BUF current 5224 /* Do this after making BUF current
5228 in case scroll_margin is buffer-local. */ 5225 in case scroll_margin is buffer-local. */
5229 this_scroll_margin = 5226 this_scroll_margin =
5230 max (0, min (scroll_margin, XFASTINT (w->total_lines) / 4)); 5227 max (0, min (scroll_margin, w->total_lines / 4));
5231 5228
5232 /* Handle centering on a graphical frame specially. Such frames can 5229 /* Handle centering on a graphical frame specially. Such frames can
5233 have variable-height lines and centering point on the basis of 5230 have variable-height lines and centering point on the basis of
@@ -5701,7 +5698,7 @@ the return value is nil. Otherwise the value is t. */)
5701 wset_prev (w, Qnil); 5698 wset_prev (w, Qnil);
5702 if (!NILP (w->parent)) 5699 if (!NILP (w->parent))
5703 { 5700 {
5704 if (EQ (p->total_cols, XWINDOW (w->parent)->total_cols)) 5701 if (XINT (p->total_cols) == XWINDOW (w->parent)->total_cols)
5705 { 5702 {
5706 wset_vchild (XWINDOW (w->parent), p->window); 5703 wset_vchild (XWINDOW (w->parent), p->window);
5707 wset_hchild (XWINDOW (w->parent), Qnil); 5704 wset_hchild (XWINDOW (w->parent), Qnil);
@@ -5714,14 +5711,13 @@ the return value is nil. Otherwise the value is t. */)
5714 } 5711 }
5715 } 5712 }
5716 5713
5717 /* If we squirreled away the buffer in the window's height, 5714 /* If we squirreled away the buffer, restore it now. */
5718 restore it now. */ 5715 if (BUFFERP (w->combination_limit))
5719 if (BUFFERP (w->total_lines)) 5716 wset_buffer (w, w->combination_limit);
5720 wset_buffer (w, w->total_lines); 5717 w->left_col = XFASTINT (p->left_col);
5721 wset_left_col (w, p->left_col); 5718 w->top_line = XFASTINT (p->top_line);
5722 wset_top_line (w, p->top_line); 5719 w->total_cols = XFASTINT (p->total_cols);
5723 wset_total_cols (w, p->total_cols); 5720 w->total_lines = XFASTINT (p->total_lines);
5724 wset_total_lines (w, p->total_lines);
5725 wset_normal_cols (w, p->normal_cols); 5721 wset_normal_cols (w, p->normal_cols);
5726 wset_normal_lines (w, p->normal_lines); 5722 wset_normal_lines (w, p->normal_lines);
5727 w->hscroll = XFASTINT (p->hscroll); 5723 w->hscroll = XFASTINT (p->hscroll);
@@ -5921,9 +5917,6 @@ delete_all_child_windows (Lisp_Object window)
5921 /* Delete WINDOW's siblings (we traverse postorderly). */ 5917 /* Delete WINDOW's siblings (we traverse postorderly). */
5922 delete_all_child_windows (w->next); 5918 delete_all_child_windows (w->next);
5923 5919
5924 /* See Fset_window_configuration for excuse. */
5925 wset_total_lines (w, w->buffer);
5926
5927 if (!NILP (w->vchild)) 5920 if (!NILP (w->vchild))
5928 { 5921 {
5929 delete_all_child_windows (w->vchild); 5922 delete_all_child_windows (w->vchild);
@@ -5939,6 +5932,10 @@ delete_all_child_windows (Lisp_Object window)
5939 unshow_buffer (w); 5932 unshow_buffer (w);
5940 unchain_marker (XMARKER (w->pointm)); 5933 unchain_marker (XMARKER (w->pointm));
5941 unchain_marker (XMARKER (w->start)); 5934 unchain_marker (XMARKER (w->start));
5935 /* Since combination limit makes sense for an internal windows
5936 only, we use this slot to save the buffer for the sake of
5937 possible resurrection in Fset_window_configuration. */
5938 wset_combination_limit (w, w->buffer);
5942 wset_buffer (w, Qnil); 5939 wset_buffer (w, Qnil);
5943 } 5940 }
5944 5941
@@ -6009,8 +6006,7 @@ get_phys_cursor_glyph (struct window *w)
6009 hpos = row->used[TEXT_AREA] - 1; 6006 hpos = row->used[TEXT_AREA] - 1;
6010 } 6007 }
6011 6008
6012 if (row->used[TEXT_AREA] > hpos 6009 if (hpos >= 0 && hpos < row->used[TEXT_AREA])
6013 && 0 <= hpos)
6014 glyph = row->glyphs[TEXT_AREA] + hpos; 6010 glyph = row->glyphs[TEXT_AREA] + hpos;
6015 else 6011 else
6016 glyph = NULL; 6012 glyph = NULL;
@@ -6034,10 +6030,10 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6034 wset_temslot (w, make_number (i)); i++; 6030 wset_temslot (w, make_number (i)); i++;
6035 p->window = window; 6031 p->window = window;
6036 p->buffer = w->buffer; 6032 p->buffer = w->buffer;
6037 p->left_col = w->left_col; 6033 p->left_col = make_number (w->left_col);
6038 p->top_line = w->top_line; 6034 p->top_line = make_number (w->top_line);
6039 p->total_cols = w->total_cols; 6035 p->total_cols = make_number (w->total_cols);
6040 p->total_lines = w->total_lines; 6036 p->total_lines = make_number (w->total_lines);
6041 p->normal_cols = w->normal_cols; 6037 p->normal_cols = w->normal_cols;
6042 p->normal_lines = w->normal_lines; 6038 p->normal_lines = w->normal_lines;
6043 XSETFASTINT (p->hscroll, w->hscroll); 6039 XSETFASTINT (p->hscroll, w->hscroll);
@@ -6531,7 +6527,7 @@ freeze_window_start (struct window *w, void *freeze_p)
6531 means freeze the window start. */ 6527 means freeze the window start. */
6532 6528
6533void 6529void
6534freeze_window_starts (struct frame *f, int freeze_p) 6530freeze_window_starts (struct frame *f, bool freeze_p)
6535{ 6531{
6536 foreach_window (f, freeze_window_start, (void *) (freeze_p ? f : 0)); 6532 foreach_window (f, freeze_window_start, (void *) (freeze_p ? f : 0));
6537} 6533}