aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c169
1 files changed, 79 insertions, 90 deletions
diff --git a/src/window.c b/src/window.c
index 75a8d42d8d1..9f3474fcd53 100644
--- a/src/window.c
+++ b/src/window.c
@@ -273,7 +273,7 @@ decode_valid_window (register Lisp_Object window)
273/* Build a frequently used 4-integer (X Y W H) list. */ 273/* Build a frequently used 4-integer (X Y W H) list. */
274 274
275static Lisp_Object 275static Lisp_Object
276quad (ptrdiff_t x, ptrdiff_t y, ptrdiff_t w, ptrdiff_t h) 276list4i (EMACS_INT x, EMACS_INT y, EMACS_INT w, EMACS_INT h)
277{ 277{
278 return list4 (make_number (x), make_number (y), 278 return list4 (make_number (x), make_number (y),
279 make_number (w), make_number (h)); 279 make_number (w), make_number (h));
@@ -340,10 +340,7 @@ DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0,
340If FRAME is omitted or nil, it defaults to the selected frame. */) 340If FRAME is omitted or nil, it defaults to the selected frame. */)
341 (Lisp_Object frame) 341 (Lisp_Object frame)
342{ 342{
343 if (NILP (frame)) 343 return FRAME_MINIBUF_WINDOW (decode_live_frame (frame));
344 frame = selected_frame;
345 CHECK_LIVE_FRAME (frame);
346 return FRAME_MINIBUF_WINDOW (XFRAME (frame));
347} 344}
348 345
349DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, 346DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p,
@@ -605,24 +602,29 @@ Return nil if WINDOW has no previous sibling. */)
605 return decode_valid_window (window)->prev; 602 return decode_valid_window (window)->prev;
606} 603}
607 604
608DEFUN ("window-combination-limit", Fwindow_combination_limit, Swindow_combination_limit, 0, 1, 0, 605DEFUN ("window-combination-limit", Fwindow_combination_limit, Swindow_combination_limit, 1, 1, 0,
609 doc: /* Return combination limit of window WINDOW. 606 doc: /* Return combination limit of window WINDOW.
610WINDOW must be a valid window and defaults to the selected one.
611If the return value is nil, child windows of WINDOW can be recombined with 607If the return value is nil, child windows of WINDOW can be recombined with
612WINDOW's siblings. A return value of t means that child windows of 608WINDOW's siblings. A return value of t means that child windows of
613WINDOW are never \(re-)combined with WINDOW's siblings. */) 609WINDOW are never \(re-)combined with WINDOW's siblings.
610
611WINDOW must be a valid window. The return value is meaningful for
612internal windows only. */)
614 (Lisp_Object window) 613 (Lisp_Object window)
615{ 614{
616 return decode_valid_window (window)->combination_limit; 615 CHECK_VALID_WINDOW (window);
616 return XWINDOW (window)->combination_limit;
617} 617}
618 618
619DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0, 619DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0,
620 doc: /* Set combination limit of window WINDOW to LIMIT; return LIMIT. 620 doc: /* Set combination limit of window WINDOW to LIMIT; return LIMIT.
621WINDOW must be a valid window and defaults to the selected one.
622If LIMIT is nil, child windows of WINDOW can be recombined with WINDOW's 621If LIMIT is nil, child windows of WINDOW can be recombined with WINDOW's
623siblings. LIMIT t means that child windows of WINDOW are never 622siblings. LIMIT t means that child windows of WINDOW are never
624\(re-)combined with WINDOW's siblings. Other values are reserved for 623\(re-)combined with WINDOW's siblings. Other values are reserved for
625future use. */) 624future use.
625
626WINDOW must be a valid window. Setting the combination limit is
627meaningful for internal windows only. */)
626 (Lisp_Object window, Lisp_Object limit) 628 (Lisp_Object window, Lisp_Object limit)
627{ 629{
628 wset_combination_limit (decode_valid_window (window), limit); 630 wset_combination_limit (decode_valid_window (window), limit);
@@ -882,8 +884,8 @@ header line, and/or mode line. For the edges of just the text area, use
882{ 884{
883 register struct window *w = decode_valid_window (window); 885 register struct window *w = decode_valid_window (window);
884 886
885 return quad (WINDOW_LEFT_EDGE_COL (w), WINDOW_TOP_EDGE_LINE (w), 887 return list4i (WINDOW_LEFT_EDGE_COL (w), WINDOW_TOP_EDGE_LINE (w),
886 WINDOW_RIGHT_EDGE_COL (w), WINDOW_BOTTOM_EDGE_LINE (w)); 888 WINDOW_RIGHT_EDGE_COL (w), WINDOW_BOTTOM_EDGE_LINE (w));
887} 889}
888 890
889DEFUN ("window-pixel-edges", Fwindow_pixel_edges, Swindow_pixel_edges, 0, 1, 0, 891DEFUN ("window-pixel-edges", Fwindow_pixel_edges, Swindow_pixel_edges, 0, 1, 0,
@@ -902,8 +904,8 @@ of just the text area, use `window-inside-pixel-edges'. */)
902{ 904{
903 register struct window *w = decode_valid_window (window); 905 register struct window *w = decode_valid_window (window);
904 906
905 return quad (WINDOW_LEFT_EDGE_X (w), WINDOW_TOP_EDGE_Y (w), 907 return list4i (WINDOW_LEFT_EDGE_X (w), WINDOW_TOP_EDGE_Y (w),
906 WINDOW_RIGHT_EDGE_X (w), WINDOW_BOTTOM_EDGE_Y (w)); 908 WINDOW_RIGHT_EDGE_X (w), WINDOW_BOTTOM_EDGE_Y (w));
907} 909}
908 910
909static void 911static void
@@ -948,10 +950,10 @@ of just the text area, use `window-inside-absolute-pixel-edges'. */)
948 950
949 calc_absolute_offset (w, &add_x, &add_y); 951 calc_absolute_offset (w, &add_x, &add_y);
950 952
951 return quad (WINDOW_LEFT_EDGE_X (w) + add_x, 953 return list4i (WINDOW_LEFT_EDGE_X (w) + add_x,
952 WINDOW_TOP_EDGE_Y (w) + add_y, 954 WINDOW_TOP_EDGE_Y (w) + add_y,
953 WINDOW_RIGHT_EDGE_X (w) + add_x, 955 WINDOW_RIGHT_EDGE_X (w) + add_x,
954 WINDOW_BOTTOM_EDGE_Y (w) + add_y); 956 WINDOW_BOTTOM_EDGE_Y (w) + add_y);
955} 957}
956 958
957DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0, 959DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0,
@@ -970,16 +972,16 @@ display margins, fringes, header line, and/or mode line. */)
970{ 972{
971 register struct window *w = decode_live_window (window); 973 register struct window *w = decode_live_window (window);
972 974
973 return quad (WINDOW_BOX_LEFT_EDGE_COL (w) 975 return list4i ((WINDOW_BOX_LEFT_EDGE_COL (w)
974 + WINDOW_LEFT_MARGIN_COLS (w) 976 + WINDOW_LEFT_MARGIN_COLS (w)
975 + WINDOW_LEFT_FRINGE_COLS (w), 977 + WINDOW_LEFT_FRINGE_COLS (w)),
976 WINDOW_TOP_EDGE_LINE (w) 978 (WINDOW_TOP_EDGE_LINE (w)
977 + WINDOW_HEADER_LINE_LINES (w), 979 + WINDOW_HEADER_LINE_LINES (w)),
978 WINDOW_BOX_RIGHT_EDGE_COL (w) 980 (WINDOW_BOX_RIGHT_EDGE_COL (w)
979 - WINDOW_RIGHT_MARGIN_COLS (w) 981 - WINDOW_RIGHT_MARGIN_COLS (w)
980 - WINDOW_RIGHT_FRINGE_COLS (w), 982 - WINDOW_RIGHT_FRINGE_COLS (w)),
981 WINDOW_BOTTOM_EDGE_LINE (w) 983 (WINDOW_BOTTOM_EDGE_LINE (w)
982 - WINDOW_MODE_LINE_LINES (w)); 984 - WINDOW_MODE_LINE_LINES (w)));
983} 985}
984 986
985DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges, Swindow_inside_pixel_edges, 0, 1, 0, 987DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges, Swindow_inside_pixel_edges, 0, 1, 0,
@@ -997,16 +999,16 @@ display margins, fringes, header line, and/or mode line. */)
997{ 999{
998 register struct window *w = decode_live_window (window); 1000 register struct window *w = decode_live_window (window);
999 1001
1000 return quad (WINDOW_BOX_LEFT_EDGE_X (w) 1002 return list4i ((WINDOW_BOX_LEFT_EDGE_X (w)
1001 + WINDOW_LEFT_MARGIN_WIDTH (w) 1003 + WINDOW_LEFT_MARGIN_WIDTH (w)
1002 + WINDOW_LEFT_FRINGE_WIDTH (w), 1004 + WINDOW_LEFT_FRINGE_WIDTH (w)),
1003 WINDOW_TOP_EDGE_Y (w) 1005 (WINDOW_TOP_EDGE_Y (w)
1004 + WINDOW_HEADER_LINE_HEIGHT (w), 1006 + WINDOW_HEADER_LINE_HEIGHT (w)),
1005 WINDOW_BOX_RIGHT_EDGE_X (w) 1007 (WINDOW_BOX_RIGHT_EDGE_X (w)
1006 - WINDOW_RIGHT_MARGIN_WIDTH (w) 1008 - WINDOW_RIGHT_MARGIN_WIDTH (w)
1007 - WINDOW_RIGHT_FRINGE_WIDTH (w), 1009 - WINDOW_RIGHT_FRINGE_WIDTH (w)),
1008 WINDOW_BOTTOM_EDGE_Y (w) 1010 (WINDOW_BOTTOM_EDGE_Y (w)
1009 - WINDOW_MODE_LINE_HEIGHT (w)); 1011 - WINDOW_MODE_LINE_HEIGHT (w)));
1010} 1012}
1011 1013
1012DEFUN ("window-inside-absolute-pixel-edges", 1014DEFUN ("window-inside-absolute-pixel-edges",
@@ -1029,16 +1031,16 @@ display margins, fringes, header line, and/or mode line. */)
1029 1031
1030 calc_absolute_offset (w, &add_x, &add_y); 1032 calc_absolute_offset (w, &add_x, &add_y);
1031 1033
1032 return quad (WINDOW_BOX_LEFT_EDGE_X (w) 1034 return list4i ((WINDOW_BOX_LEFT_EDGE_X (w)
1033 + WINDOW_LEFT_MARGIN_WIDTH (w) 1035 + WINDOW_LEFT_MARGIN_WIDTH (w)
1034 + WINDOW_LEFT_FRINGE_WIDTH (w) + add_x, 1036 + WINDOW_LEFT_FRINGE_WIDTH (w) + add_x),
1035 WINDOW_TOP_EDGE_Y (w) 1037 (WINDOW_TOP_EDGE_Y (w)
1036 + WINDOW_HEADER_LINE_HEIGHT (w) + add_y, 1038 + WINDOW_HEADER_LINE_HEIGHT (w) + add_y),
1037 WINDOW_BOX_RIGHT_EDGE_X (w) 1039 (WINDOW_BOX_RIGHT_EDGE_X (w)
1038 - WINDOW_RIGHT_MARGIN_WIDTH (w) 1040 - WINDOW_RIGHT_MARGIN_WIDTH (w)
1039 - WINDOW_RIGHT_FRINGE_WIDTH (w) + add_x, 1041 - WINDOW_RIGHT_FRINGE_WIDTH (w) + add_x),
1040 WINDOW_BOTTOM_EDGE_Y (w) 1042 (WINDOW_BOTTOM_EDGE_Y (w)
1041 - WINDOW_MODE_LINE_HEIGHT (w) + add_y); 1043 - WINDOW_MODE_LINE_HEIGHT (w) + add_y));
1042} 1044}
1043 1045
1044/* Test if the character at column X, row Y is within window W. 1046/* Test if the character at column X, row Y is within window W.
@@ -1371,12 +1373,7 @@ The top left corner of the frame is considered to be row 0,
1371column 0. */) 1373column 0. */)
1372 (Lisp_Object x, Lisp_Object y, Lisp_Object frame) 1374 (Lisp_Object x, Lisp_Object y, Lisp_Object frame)
1373{ 1375{
1374 struct frame *f; 1376 struct frame *f = decode_live_frame (frame);
1375
1376 if (NILP (frame))
1377 frame = selected_frame;
1378 CHECK_LIVE_FRAME (frame);
1379 f = XFRAME (frame);
1380 1377
1381 /* Check that arguments are integers or floats. */ 1378 /* Check that arguments are integers or floats. */
1382 CHECK_NUMBER_OR_FLOAT (x); 1379 CHECK_NUMBER_OR_FLOAT (x);
@@ -1624,7 +1621,7 @@ display row, and VPOS is the row number (0-based) containing POS. */)
1624 { 1621 {
1625 Lisp_Object part = Qnil; 1622 Lisp_Object part = Qnil;
1626 if (!fully_p) 1623 if (!fully_p)
1627 part = quad (rtop, rbot, rowh, vpos); 1624 part = list4i (rtop, rbot, rowh, vpos);
1628 in_window = Fcons (make_number (x), 1625 in_window = Fcons (make_number (x),
1629 Fcons (make_number (y), part)); 1626 Fcons (make_number (y), part));
1630 } 1627 }
@@ -1690,17 +1687,18 @@ Return nil if window display is not up-to-date. In that case, use
1690 if (!WINDOW_WANTS_HEADER_LINE_P (w)) 1687 if (!WINDOW_WANTS_HEADER_LINE_P (w))
1691 return Qnil; 1688 return Qnil;
1692 row = MATRIX_HEADER_LINE_ROW (w->current_matrix); 1689 row = MATRIX_HEADER_LINE_ROW (w->current_matrix);
1693 return row->enabled_p ? quad (row->height, 0, 0, 0) : Qnil; 1690 return row->enabled_p ? list4i (row->height, 0, 0, 0) : Qnil;
1694 } 1691 }
1695 1692
1696 if (EQ (line, Qmode_line)) 1693 if (EQ (line, Qmode_line))
1697 { 1694 {
1698 row = MATRIX_MODE_LINE_ROW (w->current_matrix); 1695 row = MATRIX_MODE_LINE_ROW (w->current_matrix);
1699 return (row->enabled_p ? 1696 return (row->enabled_p ?
1700 quad (row->height, 1697 list4i (row->height,
1701 0, /* not accurate */ 1698 0, /* not accurate */
1702 WINDOW_HEADER_LINE_HEIGHT (w) 1699 (WINDOW_HEADER_LINE_HEIGHT (w)
1703 + window_text_bottom_y (w), 0) 1700 + window_text_bottom_y (w)),
1701 0)
1704 : Qnil); 1702 : Qnil);
1705 } 1703 }
1706 1704
@@ -1730,7 +1728,7 @@ Return nil if window display is not up-to-date. In that case, use
1730 1728
1731 found_row: 1729 found_row:
1732 crop = max (0, (row->y + row->height) - max_y); 1730 crop = max (0, (row->y + row->height) - max_y);
1733 return quad (row->height + min (0, row->y) - crop, i, row->y, crop); 1731 return list4i (row->height + min (0, row->y) - crop, i, row->y, crop);
1734} 1732}
1735 1733
1736DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p, 1734DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p,
@@ -2135,10 +2133,10 @@ window_list (void)
2135{ 2133{
2136 if (!CONSP (Vwindow_list)) 2134 if (!CONSP (Vwindow_list))
2137 { 2135 {
2138 Lisp_Object tail; 2136 Lisp_Object tail, frame;
2139 2137
2140 Vwindow_list = Qnil; 2138 Vwindow_list = Qnil;
2141 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 2139 FOR_EACH_FRAME (tail, frame)
2142 { 2140 {
2143 Lisp_Object args[2]; 2141 Lisp_Object args[2];
2144 2142
@@ -2146,7 +2144,7 @@ window_list (void)
2146 new windows at the front of args[1], which means we 2144 new windows at the front of args[1], which means we
2147 have to reverse this list at the end. */ 2145 have to reverse this list at the end. */
2148 args[1] = Qnil; 2146 args[1] = Qnil;
2149 foreach_window (XFRAME (XCAR (tail)), add_window_to_list, &args[1]); 2147 foreach_window (XFRAME (frame), add_window_to_list, &args[1]);
2150 args[0] = Vwindow_list; 2148 args[0] = Vwindow_list;
2151 args[1] = Fnreverse (args[1]); 2149 args[1] = Fnreverse (args[1]);
2152 Vwindow_list = Fnconc (2, args); 2150 Vwindow_list = Fnconc (2, args);
@@ -3109,12 +3107,12 @@ run_window_configuration_change_hook (struct frame *f)
3109} 3107}
3110 3108
3111DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook, 3109DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook,
3112 Srun_window_configuration_change_hook, 1, 1, 0, 3110 Srun_window_configuration_change_hook, 0, 1, 0,
3113 doc: /* Run `window-configuration-change-hook' for FRAME. */) 3111 doc: /* Run `window-configuration-change-hook' for FRAME.
3112If FRAME is omitted or nil, it defaults to the selected frame. */)
3114 (Lisp_Object frame) 3113 (Lisp_Object frame)
3115{ 3114{
3116 CHECK_LIVE_FRAME (frame); 3115 run_window_configuration_change_hook (decode_live_frame (frame));
3117 run_window_configuration_change_hook (XFRAME (frame));
3118 return Qnil; 3116 return Qnil;
3119} 3117}
3120 3118
@@ -3641,10 +3639,12 @@ window_resize_apply (struct window *w, int horflag)
3641} 3639}
3642 3640
3643 3641
3644DEFUN ("window-resize-apply", Fwindow_resize_apply, Swindow_resize_apply, 1, 2, 0, 3642DEFUN ("window-resize-apply", Fwindow_resize_apply, Swindow_resize_apply, 0, 2, 0,
3645 doc: /* Apply requested size values for window-tree of FRAME. 3643 doc: /* Apply requested size values for window-tree of FRAME.
3646Optional argument HORIZONTAL omitted or nil means apply requested height 3644If FRAME is omitted or nil, it defaults to the selected frame.
3647values. HORIZONTAL non-nil means apply requested width values. 3645
3646Optional argument HORIZONTAL omitted or nil means apply requested
3647height values. HORIZONTAL non-nil means apply requested width values.
3648 3648
3649This function checks whether the requested values sum up to a valid 3649This function checks whether the requested values sum up to a valid
3650window layout, recursively assigns the new sizes of all child windows 3650window layout, recursively assigns the new sizes of all child windows
@@ -3655,17 +3655,10 @@ Note: This function does not check any of `window-fixed-size-p',
3655be applied on the Elisp level. */) 3655be applied on the Elisp level. */)
3656 (Lisp_Object frame, Lisp_Object horizontal) 3656 (Lisp_Object frame, Lisp_Object horizontal)
3657{ 3657{
3658 struct frame *f; 3658 struct frame *f = decode_live_frame (frame);
3659 struct window *r; 3659 struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f));
3660 int horflag = !NILP (horizontal); 3660 int horflag = !NILP (horizontal);
3661 3661
3662 if (NILP (frame))
3663 frame = selected_frame;
3664 CHECK_LIVE_FRAME (frame);
3665
3666 f = XFRAME (frame);
3667 r = XWINDOW (FRAME_ROOT_WINDOW (f));
3668
3669 if (!window_resize_check (r, horflag) 3662 if (!window_resize_check (r, horflag)
3670 || ! EQ (r->new_total, 3663 || ! EQ (r->new_total,
3671 (horflag ? r->total_cols : r->total_lines))) 3664 (horflag ? r->total_cols : r->total_lines)))
@@ -3879,9 +3872,10 @@ set correctly. See the code of `split-window' for how this is done. */)
3879 3872
3880 make_parent_window (old, horflag); 3873 make_parent_window (old, horflag);
3881 p = XWINDOW (o->parent); 3874 p = XWINDOW (o->parent);
3882 /* Store t in the new parent's combination_limit slot to avoid 3875 if (EQ (Vwindow_combination_limit, Qt))
3883 that its children get merged into another window. */ 3876 /* Store t in the new parent's combination_limit slot to avoid
3884 wset_combination_limit (p, Qt); 3877 that its children get merged into another window. */
3878 wset_combination_limit (p, Qt);
3885 /* These get applied below. */ 3879 /* These get applied below. */
3886 wset_new_total (p, horflag ? o->total_cols : o->total_lines); 3880 wset_new_total (p, horflag ? o->total_cols : o->total_lines);
3887 wset_new_normal (p, new_normal); 3881 wset_new_normal (p, new_normal);
@@ -6148,12 +6142,7 @@ saved by this function. */)
6148 register int n_windows; 6142 register int n_windows;
6149 register struct save_window_data *data; 6143 register struct save_window_data *data;
6150 register int i; 6144 register int i;
6151 FRAME_PTR f; 6145 struct frame *f = decode_live_frame (frame);
6152
6153 if (NILP (frame))
6154 frame = selected_frame;
6155 CHECK_LIVE_FRAME (frame);
6156 f = XFRAME (frame);
6157 6146
6158 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f))); 6147 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
6159 data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols, 6148 data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols,