diff options
| author | Martin Rudalics | 2007-08-06 06:44:31 +0000 |
|---|---|---|
| committer | Martin Rudalics | 2007-08-06 06:44:31 +0000 |
| commit | 35ea56c96a85e8ecc3c97210a2006e6b3694b062 (patch) | |
| tree | e13a483e26983d1c57068ae5038ba3de6284fc46 /src | |
| parent | a6f882f597eb7238df3ec104b93089511f3c3adc (diff) | |
| download | emacs-35ea56c96a85e8ecc3c97210a2006e6b3694b062.tar.gz emacs-35ea56c96a85e8ecc3c97210a2006e6b3694b062.zip | |
(window_min_size_2): New function.
(window_min_size_1, size_window, Fdisplay_buffer)
(Fsplit_window, adjust_window_trailing_edge): Use it to avoid
windows without mode- or header-lines when window-min-height is
too small.
(size_window): Reset nodelete_p after testing it, following an
earlier note by Kim F. Storm.
(display_buffer): Do not set split_height_threshold to twice the
value of window_min_height to avoid changing the value of a
customizable variable. Rather explicitly check whether the
height of the window that shall be splitted is at least as large
as split_height_threshold.
(Fwindow_full_width_p): New defun.
(syms_of_window): Defsubr it.
(Fdisplay_buffer): Use NILP.
(Fset_window_scroll_bars): Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/window.c | 117 |
1 files changed, 70 insertions, 47 deletions
diff --git a/src/window.c b/src/window.c index e6fe32ea506..6fe78166ba1 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -62,6 +62,7 @@ static void window_scroll P_ ((Lisp_Object, int, int, int)); | |||
| 62 | static void window_scroll_pixel_based P_ ((Lisp_Object, int, int, int)); | 62 | static void window_scroll_pixel_based P_ ((Lisp_Object, int, int, int)); |
| 63 | static void window_scroll_line_based P_ ((Lisp_Object, int, int, int)); | 63 | static void window_scroll_line_based P_ ((Lisp_Object, int, int, int)); |
| 64 | static int window_min_size_1 P_ ((struct window *, int)); | 64 | static int window_min_size_1 P_ ((struct window *, int)); |
| 65 | static int window_min_size_2 P_ ((struct window *, int)); | ||
| 65 | static int window_min_size P_ ((struct window *, int, int, int *)); | 66 | static int window_min_size P_ ((struct window *, int, int, int *)); |
| 66 | static void size_window P_ ((Lisp_Object, int, int, int, int, int)); | 67 | static void size_window P_ ((Lisp_Object, int, int, int, int, int)); |
| 67 | static int freeze_window_start P_ ((struct window *, void *)); | 68 | static int freeze_window_start P_ ((struct window *, void *)); |
| @@ -556,6 +557,15 @@ use (let ((edges (window-edges))) (- (nth 2 edges) (nth 0 edges))). */) | |||
| 556 | return make_number (window_box_text_cols (decode_any_window (window))); | 557 | return make_number (window_box_text_cols (decode_any_window (window))); |
| 557 | } | 558 | } |
| 558 | 559 | ||
| 560 | DEFUN ("window-full-width-p", Fwindow_full_width_p, Swindow_full_width_p, 0, 1, 0, | ||
| 561 | doc: /* Return t if WINDOW is as wide as its frame. | ||
| 562 | WINDOW defaults to the selected window. */) | ||
| 563 | (window) | ||
| 564 | Lisp_Object window; | ||
| 565 | { | ||
| 566 | return WINDOW_FULL_WIDTH_P (decode_any_window (window)) ? Qt : Qnil; | ||
| 567 | } | ||
| 568 | |||
| 559 | DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, | 569 | DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, |
| 560 | doc: /* Return the number of columns by which WINDOW is scrolled from left margin. | 570 | doc: /* Return the number of columns by which WINDOW is scrolled from left margin. |
| 561 | WINDOW defaults to the selected window. */) | 571 | WINDOW defaults to the selected window. */) |
| @@ -2553,7 +2563,6 @@ check_frame_size (frame, rows, cols) | |||
| 2553 | *cols = MIN_SAFE_WINDOW_WIDTH; | 2563 | *cols = MIN_SAFE_WINDOW_WIDTH; |
| 2554 | } | 2564 | } |
| 2555 | 2565 | ||
| 2556 | |||
| 2557 | /* Value is non-zero if window W is fixed-size. WIDTH_P non-zero means | 2566 | /* Value is non-zero if window W is fixed-size. WIDTH_P non-zero means |
| 2558 | check if W's width can be changed, otherwise check W's height. | 2567 | check if W's width can be changed, otherwise check W's height. |
| 2559 | CHECK_SIBLINGS_P non-zero means check resizablity of WINDOW's | 2568 | CHECK_SIBLINGS_P non-zero means check resizablity of WINDOW's |
| @@ -2655,6 +2664,33 @@ window_fixed_size_p (w, width_p, check_siblings_p) | |||
| 2655 | return fixed_p; | 2664 | return fixed_p; |
| 2656 | } | 2665 | } |
| 2657 | 2666 | ||
| 2667 | /* Return the minimum size for leaf window W. WIDTH_P non-zero means | ||
| 2668 | take into account fringes and the scrollbar of W. WIDTH_P zero | ||
| 2669 | means take into account mode-line and header-line of W. Return 1 | ||
| 2670 | for the minibuffer. */ | ||
| 2671 | |||
| 2672 | static int | ||
| 2673 | window_min_size_2 (w, width_p) | ||
| 2674 | struct window *w; | ||
| 2675 | int width_p; | ||
| 2676 | { | ||
| 2677 | int size; | ||
| 2678 | |||
| 2679 | if (width_p) | ||
| 2680 | size = max (window_min_width, | ||
| 2681 | (MIN_SAFE_WINDOW_WIDTH | ||
| 2682 | + WINDOW_FRINGE_COLS (w) | ||
| 2683 | + WINDOW_SCROLL_BAR_COLS (w))); | ||
| 2684 | else if (MINI_WINDOW_P (w)) | ||
| 2685 | size = 1; | ||
| 2686 | else | ||
| 2687 | size = max (window_min_height, | ||
| 2688 | (MIN_SAFE_WINDOW_HEIGHT | ||
| 2689 | + (WINDOW_WANTS_MODELINE_P (w) ? 1 : 0) | ||
| 2690 | + (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0 ))); | ||
| 2691 | |||
| 2692 | return size; | ||
| 2693 | } | ||
| 2658 | 2694 | ||
| 2659 | /* Return the minimum size of window W, not taking fixed-width windows | 2695 | /* Return the minimum size of window W, not taking fixed-width windows |
| 2660 | into account. WIDTH_P non-zero means return the minimum width, | 2696 | into account. WIDTH_P non-zero means return the minimum width, |
| @@ -2724,22 +2760,7 @@ window_min_size_1 (w, width_p) | |||
| 2724 | } | 2760 | } |
| 2725 | } | 2761 | } |
| 2726 | else | 2762 | else |
| 2727 | { | 2763 | size = window_min_size_2 (w, width_p); |
| 2728 | if (width_p) | ||
| 2729 | size = max (window_min_width, | ||
| 2730 | (MIN_SAFE_WINDOW_WIDTH | ||
| 2731 | + WINDOW_FRINGE_COLS (w) | ||
| 2732 | + WINDOW_SCROLL_BAR_COLS (w))); | ||
| 2733 | else | ||
| 2734 | { | ||
| 2735 | if (MINI_WINDOW_P (w) | ||
| 2736 | || (!WINDOW_WANTS_MODELINE_P (w) | ||
| 2737 | && !WINDOW_WANTS_HEADER_LINE_P (w))) | ||
| 2738 | size = 1; | ||
| 2739 | else | ||
| 2740 | size = window_min_height; | ||
| 2741 | } | ||
| 2742 | } | ||
| 2743 | 2764 | ||
| 2744 | return size; | 2765 | return size; |
| 2745 | } | 2766 | } |
| @@ -2981,11 +3002,6 @@ size_window (window, size, width_p, nodelete_p, first_only, last_only) | |||
| 2981 | Lisp_Object child, *forward, *sideward; | 3002 | Lisp_Object child, *forward, *sideward; |
| 2982 | int old_size, min_size, safe_min_size; | 3003 | int old_size, min_size, safe_min_size; |
| 2983 | 3004 | ||
| 2984 | /* We test nodelete_p != 2 and nodelete_p != 1 below, so it | ||
| 2985 | seems like it's too soon to do this here. ++KFS. */ | ||
| 2986 | if (nodelete_p == 2) | ||
| 2987 | nodelete_p = 0; | ||
| 2988 | |||
| 2989 | check_min_window_sizes (); | 3005 | check_min_window_sizes (); |
| 2990 | size = max (0, size); | 3006 | size = max (0, size); |
| 2991 | 3007 | ||
| @@ -2996,22 +3012,23 @@ size_window (window, size, width_p, nodelete_p, first_only, last_only) | |||
| 2996 | { | 3012 | { |
| 2997 | old_size = WINDOW_TOTAL_COLS (w); | 3013 | old_size = WINDOW_TOTAL_COLS (w); |
| 2998 | min_size = window_min_width; | 3014 | min_size = window_min_width; |
| 2999 | /* Ensure that there is room for the scroll bar and fringes! | 3015 | safe_min_size = window_min_size_2 (w, 1); |
| 3000 | We may reduce display margins though. */ | ||
| 3001 | safe_min_size = (MIN_SAFE_WINDOW_WIDTH | ||
| 3002 | + WINDOW_FRINGE_COLS (w) | ||
| 3003 | + WINDOW_SCROLL_BAR_COLS (w)); | ||
| 3004 | } | 3016 | } |
| 3005 | else | 3017 | else |
| 3006 | { | 3018 | { |
| 3007 | old_size = XINT (w->total_lines); | 3019 | old_size = XINT (w->total_lines); |
| 3008 | min_size = window_min_height; | 3020 | min_size = window_min_height; |
| 3009 | safe_min_size = MIN_SAFE_WINDOW_HEIGHT; | 3021 | safe_min_size = window_min_size_2 (w, 0); |
| 3010 | } | 3022 | } |
| 3011 | 3023 | ||
| 3012 | if (old_size < min_size && nodelete_p != 2) | 3024 | if (old_size < min_size && nodelete_p != 2) |
| 3013 | w->too_small_ok = Qt; | 3025 | w->too_small_ok = Qt; |
| 3014 | 3026 | ||
| 3027 | /* Move the following test here since otherwise the | ||
| 3028 | preceding test doesn't make sense. martin. */ | ||
| 3029 | if (nodelete_p == 2) | ||
| 3030 | nodelete_p = 0; | ||
| 3031 | |||
| 3015 | /* Maybe delete WINDOW if it's too small. */ | 3032 | /* Maybe delete WINDOW if it's too small. */ |
| 3016 | if (nodelete_p != 1 && !NILP (w->parent)) | 3033 | if (nodelete_p != 1 && !NILP (w->parent)) |
| 3017 | { | 3034 | { |
| @@ -3708,9 +3725,6 @@ displayed. */) | |||
| 3708 | frames = Qnil; | 3725 | frames = Qnil; |
| 3709 | if (FRAME_MINIBUF_ONLY_P (f)) | 3726 | if (FRAME_MINIBUF_ONLY_P (f)) |
| 3710 | XSETFRAME (frames, last_nonminibuf_frame); | 3727 | XSETFRAME (frames, last_nonminibuf_frame); |
| 3711 | /* Don't try to create a window if we would get an error. */ | ||
| 3712 | if (split_height_threshold < window_min_height << 1) | ||
| 3713 | split_height_threshold = window_min_height << 1; | ||
| 3714 | 3728 | ||
| 3715 | /* Note that both Fget_largest_window and Fget_lru_window | 3729 | /* Note that both Fget_largest_window and Fget_lru_window |
| 3716 | ignore minibuffers and dedicated windows. | 3730 | ignore minibuffers and dedicated windows. |
| @@ -3733,25 +3747,30 @@ displayed. */) | |||
| 3733 | else | 3747 | else |
| 3734 | window = Fget_largest_window (frames, Qt); | 3748 | window = Fget_largest_window (frames, Qt); |
| 3735 | 3749 | ||
| 3736 | /* If we got a tall enough full-width window that can be split, | 3750 | /* If the largest window is tall enough, full-width, and either eligible |
| 3737 | split it. */ | 3751 | for splitting or the only window, split it. */ |
| 3738 | if (!NILP (window) | 3752 | if (!NILP (window) |
| 3739 | && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) | 3753 | && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) |
| 3740 | && window_height (window) >= split_height_threshold | 3754 | && WINDOW_FULL_WIDTH_P (XWINDOW (window)) |
| 3741 | && WINDOW_FULL_WIDTH_P (XWINDOW (window))) | 3755 | && (window_height (window) >= split_height_threshold |
| 3756 | || (NILP (XWINDOW (window)->parent))) | ||
| 3757 | && (window_height (window) | ||
| 3758 | >= (2 * window_min_size_2 (XWINDOW (window), 0)))) | ||
| 3742 | window = Fsplit_window (window, Qnil, Qnil); | 3759 | window = Fsplit_window (window, Qnil, Qnil); |
| 3743 | else | 3760 | else |
| 3744 | { | 3761 | { |
| 3745 | Lisp_Object upper, lower, other; | 3762 | Lisp_Object upper, lower, other; |
| 3746 | 3763 | ||
| 3747 | window = Fget_lru_window (frames, Qt); | 3764 | window = Fget_lru_window (frames, Qt); |
| 3748 | /* If the LRU window is selected, and big enough, | 3765 | /* If the LRU window is tall enough, and either eligible for splitting |
| 3749 | and can be split, split it. */ | 3766 | and selected or the only window, split it. */ |
| 3750 | if (!NILP (window) | 3767 | if (!NILP (window) |
| 3751 | && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) | 3768 | && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) |
| 3752 | && (EQ (window, selected_window) | 3769 | && ((EQ (window, selected_window) |
| 3753 | || EQ (XWINDOW (window)->parent, Qnil)) | 3770 | && window_height (window) >= split_height_threshold) |
| 3754 | && window_height (window) >= window_min_height << 1) | 3771 | || (NILP (XWINDOW (window)->parent))) |
| 3772 | && (window_height (window) | ||
| 3773 | >= (2 * window_min_size_2 (XWINDOW (window), 0)))) | ||
| 3755 | window = Fsplit_window (window, Qnil, Qnil); | 3774 | window = Fsplit_window (window, Qnil, Qnil); |
| 3756 | else | 3775 | else |
| 3757 | window = Fget_lru_window (frames, Qnil); | 3776 | window = Fget_lru_window (frames, Qnil); |
| @@ -4000,9 +4019,11 @@ See Info node `(elisp)Splitting Windows' for more details and examples.*/) | |||
| 4000 | 4019 | ||
| 4001 | if (NILP (horflag)) | 4020 | if (NILP (horflag)) |
| 4002 | { | 4021 | { |
| 4003 | if (size_int < window_min_height) | 4022 | int window_safe_height = window_min_size_2 (o, 0); |
| 4023 | |||
| 4024 | if (size_int < window_safe_height) | ||
| 4004 | error ("Window height %d too small (after splitting)", size_int); | 4025 | error ("Window height %d too small (after splitting)", size_int); |
| 4005 | if (size_int + window_min_height > XFASTINT (o->total_lines)) | 4026 | if (size_int + window_safe_height > XFASTINT (o->total_lines)) |
| 4006 | error ("Window height %d too small (after splitting)", | 4027 | error ("Window height %d too small (after splitting)", |
| 4007 | XFASTINT (o->total_lines) - size_int); | 4028 | XFASTINT (o->total_lines) - size_int); |
| 4008 | if (NILP (o->parent) | 4029 | if (NILP (o->parent) |
| @@ -4015,10 +4036,11 @@ See Info node `(elisp)Splitting Windows' for more details and examples.*/) | |||
| 4015 | } | 4036 | } |
| 4016 | else | 4037 | else |
| 4017 | { | 4038 | { |
| 4018 | if (size_int < window_min_width) | 4039 | int window_safe_width = window_min_size_2 (o, 1); |
| 4040 | |||
| 4041 | if (size_int < window_safe_width) | ||
| 4019 | error ("Window width %d too small (after splitting)", size_int); | 4042 | error ("Window width %d too small (after splitting)", size_int); |
| 4020 | 4043 | if (size_int + window_safe_width > XFASTINT (o->total_cols)) | |
| 4021 | if (size_int + window_min_width > XFASTINT (o->total_cols)) | ||
| 4022 | error ("Window width %d too small (after splitting)", | 4044 | error ("Window width %d too small (after splitting)", |
| 4023 | XFASTINT (o->total_cols) - size_int); | 4045 | XFASTINT (o->total_cols) - size_int); |
| 4024 | if (NILP (o->parent) | 4046 | if (NILP (o->parent) |
| @@ -4499,7 +4521,7 @@ adjust_window_trailing_edge (window, delta, horiz_flag) | |||
| 4499 | 4521 | ||
| 4500 | /* Don't make this window too small. */ | 4522 | /* Don't make this window too small. */ |
| 4501 | if (XINT (CURSIZE (window)) + delta | 4523 | if (XINT (CURSIZE (window)) + delta |
| 4502 | < (horiz_flag ? window_min_width : window_min_height)) | 4524 | < window_min_size_2 (XWINDOW (window), horiz_flag)) |
| 4503 | { | 4525 | { |
| 4504 | Fset_window_configuration (old_config); | 4526 | Fset_window_configuration (old_config); |
| 4505 | error ("Cannot adjust window size as specified"); | 4527 | error ("Cannot adjust window size as specified"); |
| @@ -6897,7 +6919,7 @@ Fourth parameter HORIZONTAL-TYPE is currently unused. */) | |||
| 6897 | vertical_type = Qnil; | 6919 | vertical_type = Qnil; |
| 6898 | } | 6920 | } |
| 6899 | 6921 | ||
| 6900 | if (!(EQ (vertical_type, Qnil) | 6922 | if (!(NILP (vertical_type) |
| 6901 | || EQ (vertical_type, Qleft) | 6923 | || EQ (vertical_type, Qleft) |
| 6902 | || EQ (vertical_type, Qright) | 6924 | || EQ (vertical_type, Qright) |
| 6903 | || EQ (vertical_type, Qt))) | 6925 | || EQ (vertical_type, Qt))) |
| @@ -7502,6 +7524,7 @@ The selected frame is the one whose configuration has changed. */); | |||
| 7502 | defsubr (&Swindow_buffer); | 7524 | defsubr (&Swindow_buffer); |
| 7503 | defsubr (&Swindow_height); | 7525 | defsubr (&Swindow_height); |
| 7504 | defsubr (&Swindow_width); | 7526 | defsubr (&Swindow_width); |
| 7527 | defsubr (&Swindow_full_width_p); | ||
| 7505 | defsubr (&Swindow_hscroll); | 7528 | defsubr (&Swindow_hscroll); |
| 7506 | defsubr (&Sset_window_hscroll); | 7529 | defsubr (&Sset_window_hscroll); |
| 7507 | defsubr (&Swindow_redisplay_end_trigger); | 7530 | defsubr (&Swindow_redisplay_end_trigger); |