diff options
| author | Martin Rudalics | 2007-07-15 08:23:02 +0000 |
|---|---|---|
| committer | Martin Rudalics | 2007-07-15 08:23:02 +0000 |
| commit | f1de8c774164ebf596d101200e2e87222dbd8523 (patch) | |
| tree | 7d5c99907e06d309badf42f5cc6bd1595126d830 | |
| parent | 6f8a87c027ebd6f9cfdac5c0df97d651227bec62 (diff) | |
| download | emacs-f1de8c774164ebf596d101200e2e87222dbd8523.tar.gz emacs-f1de8c774164ebf596d101200e2e87222dbd8523.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.
| -rw-r--r-- | src/ChangeLog | 15 | ||||
| -rw-r--r-- | src/window.c | 90 |
2 files changed, 66 insertions, 39 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index a707d884454..ab4210134f0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2007-07-15 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.c (window_min_size_2): New function. | ||
| 4 | (window_min_size_1, size_window, Fdisplay_buffer) | ||
| 5 | (Fsplit_window, adjust_window_trailing_edge): Use it to avoid | ||
| 6 | windows without mode- or header-lines when window-min-height is | ||
| 7 | too small. | ||
| 8 | (size_window): Reset nodelete_p after testing it, following an | ||
| 9 | earlier note by Kim F. Storm. | ||
| 10 | (display_buffer): Do not set split_height_threshold to twice the | ||
| 11 | value of window_min_height to avoid changing the value of a | ||
| 12 | customizable variable. Rather explicitly check whether the | ||
| 13 | height of the window that shall be splitted is at least as large | ||
| 14 | as split_height_threshold. | ||
| 15 | |||
| 1 | 2007-07-14 Jason Rumney <jasonr@gnu.org> | 16 | 2007-07-14 Jason Rumney <jasonr@gnu.org> |
| 2 | 17 | ||
| 3 | * process.c [WINDOWSNT]: Don't undefine AF_INET6. | 18 | * process.c [WINDOWSNT]: Don't undefine AF_INET6. |
diff --git a/src/window.c b/src/window.c index 3cb4292d346..90e2e09da51 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 *)); |
| @@ -2553,7 +2554,6 @@ check_frame_size (frame, rows, cols) | |||
| 2553 | *cols = MIN_SAFE_WINDOW_WIDTH; | 2554 | *cols = MIN_SAFE_WINDOW_WIDTH; |
| 2554 | } | 2555 | } |
| 2555 | 2556 | ||
| 2556 | |||
| 2557 | /* Value is non-zero if window W is fixed-size. WIDTH_P non-zero means | 2557 | /* 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. | 2558 | 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 | 2559 | CHECK_SIBLINGS_P non-zero means check resizablity of WINDOW's |
| @@ -2655,6 +2655,33 @@ window_fixed_size_p (w, width_p, check_siblings_p) | |||
| 2655 | return fixed_p; | 2655 | return fixed_p; |
| 2656 | } | 2656 | } |
| 2657 | 2657 | ||
| 2658 | /* Return the minimum size for leaf window W. WIDTH_P non-zero means | ||
| 2659 | take into account fringes and the scrollbar of W. WIDTH_P zero | ||
| 2660 | means take into account mode-line and header-line of W. Return 1 | ||
| 2661 | for the minibuffer. */ | ||
| 2662 | |||
| 2663 | static int | ||
| 2664 | window_min_size_2 (w, width_p) | ||
| 2665 | struct window *w; | ||
| 2666 | int width_p; | ||
| 2667 | { | ||
| 2668 | int size; | ||
| 2669 | |||
| 2670 | if (width_p) | ||
| 2671 | size = max (window_min_width, | ||
| 2672 | (MIN_SAFE_WINDOW_WIDTH | ||
| 2673 | + WINDOW_FRINGE_COLS (w) | ||
| 2674 | + WINDOW_SCROLL_BAR_COLS (w))); | ||
| 2675 | else if (MINI_WINDOW_P (w)) | ||
| 2676 | size = 1; | ||
| 2677 | else | ||
| 2678 | size = max (window_min_height, | ||
| 2679 | (MIN_SAFE_WINDOW_HEIGHT | ||
| 2680 | + (WINDOW_WANTS_MODELINE_P (w) ? 1 : 0) | ||
| 2681 | + (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0 ))); | ||
| 2682 | |||
| 2683 | return size; | ||
| 2684 | } | ||
| 2658 | 2685 | ||
| 2659 | /* Return the minimum size of window W, not taking fixed-width windows | 2686 | /* Return the minimum size of window W, not taking fixed-width windows |
| 2660 | into account. WIDTH_P non-zero means return the minimum width, | 2687 | into account. WIDTH_P non-zero means return the minimum width, |
| @@ -2724,22 +2751,7 @@ window_min_size_1 (w, width_p) | |||
| 2724 | } | 2751 | } |
| 2725 | } | 2752 | } |
| 2726 | else | 2753 | else |
| 2727 | { | 2754 | 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 | 2755 | ||
| 2744 | return size; | 2756 | return size; |
| 2745 | } | 2757 | } |
| @@ -2981,11 +2993,6 @@ size_window (window, size, width_p, nodelete_p, first_only, last_only) | |||
| 2981 | Lisp_Object child, *forward, *sideward; | 2993 | Lisp_Object child, *forward, *sideward; |
| 2982 | int old_size, min_size, safe_min_size; | 2994 | int old_size, min_size, safe_min_size; |
| 2983 | 2995 | ||
| 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 (); | 2996 | check_min_window_sizes (); |
| 2990 | size = max (0, size); | 2997 | size = max (0, size); |
| 2991 | 2998 | ||
| @@ -2996,22 +3003,23 @@ size_window (window, size, width_p, nodelete_p, first_only, last_only) | |||
| 2996 | { | 3003 | { |
| 2997 | old_size = WINDOW_TOTAL_COLS (w); | 3004 | old_size = WINDOW_TOTAL_COLS (w); |
| 2998 | min_size = window_min_width; | 3005 | min_size = window_min_width; |
| 2999 | /* Ensure that there is room for the scroll bar and fringes! | 3006 | 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 | } | 3007 | } |
| 3005 | else | 3008 | else |
| 3006 | { | 3009 | { |
| 3007 | old_size = XINT (w->total_lines); | 3010 | old_size = XINT (w->total_lines); |
| 3008 | min_size = window_min_height; | 3011 | min_size = window_min_height; |
| 3009 | safe_min_size = MIN_SAFE_WINDOW_HEIGHT; | 3012 | safe_min_size = window_min_size_2 (w, 0); |
| 3010 | } | 3013 | } |
| 3011 | 3014 | ||
| 3012 | if (old_size < min_size && nodelete_p != 2) | 3015 | if (old_size < min_size && nodelete_p != 2) |
| 3013 | w->too_small_ok = Qt; | 3016 | w->too_small_ok = Qt; |
| 3014 | 3017 | ||
| 3018 | /* Move the following test here since otherwise the | ||
| 3019 | preceding test doesn't make sense. martin. */ | ||
| 3020 | if (nodelete_p == 2) | ||
| 3021 | nodelete_p = 0; | ||
| 3022 | |||
| 3015 | /* Maybe delete WINDOW if it's too small. */ | 3023 | /* Maybe delete WINDOW if it's too small. */ |
| 3016 | if (nodelete_p != 1 && !NILP (w->parent)) | 3024 | if (nodelete_p != 1 && !NILP (w->parent)) |
| 3017 | { | 3025 | { |
| @@ -3708,9 +3716,6 @@ displayed. */) | |||
| 3708 | frames = Qnil; | 3716 | frames = Qnil; |
| 3709 | if (FRAME_MINIBUF_ONLY_P (f)) | 3717 | if (FRAME_MINIBUF_ONLY_P (f)) |
| 3710 | XSETFRAME (frames, last_nonminibuf_frame); | 3718 | 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 | 3719 | ||
| 3715 | /* Note that both Fget_largest_window and Fget_lru_window | 3720 | /* Note that both Fget_largest_window and Fget_lru_window |
| 3716 | ignore minibuffers and dedicated windows. | 3721 | ignore minibuffers and dedicated windows. |
| @@ -3737,8 +3742,10 @@ displayed. */) | |||
| 3737 | split it. */ | 3742 | split it. */ |
| 3738 | if (!NILP (window) | 3743 | if (!NILP (window) |
| 3739 | && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) | 3744 | && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) |
| 3745 | && WINDOW_FULL_WIDTH_P (XWINDOW (window)) | ||
| 3740 | && window_height (window) >= split_height_threshold | 3746 | && window_height (window) >= split_height_threshold |
| 3741 | && WINDOW_FULL_WIDTH_P (XWINDOW (window))) | 3747 | && (window_height (window) |
| 3748 | >= (2 * window_min_size_2 (XWINDOW (window), 0)))) | ||
| 3742 | window = Fsplit_window (window, Qnil, Qnil); | 3749 | window = Fsplit_window (window, Qnil, Qnil); |
| 3743 | else | 3750 | else |
| 3744 | { | 3751 | { |
| @@ -3751,7 +3758,9 @@ displayed. */) | |||
| 3751 | && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) | 3758 | && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame)) |
| 3752 | && (EQ (window, selected_window) | 3759 | && (EQ (window, selected_window) |
| 3753 | || EQ (XWINDOW (window)->parent, Qnil)) | 3760 | || EQ (XWINDOW (window)->parent, Qnil)) |
| 3754 | && window_height (window) >= window_min_height << 1) | 3761 | && window_height (window) >= split_height_threshold |
| 3762 | && (window_height (window) | ||
| 3763 | >= (2 * window_min_size_2 (XWINDOW (window), 0)))) | ||
| 3755 | window = Fsplit_window (window, Qnil, Qnil); | 3764 | window = Fsplit_window (window, Qnil, Qnil); |
| 3756 | else | 3765 | else |
| 3757 | window = Fget_lru_window (frames, Qnil); | 3766 | window = Fget_lru_window (frames, Qnil); |
| @@ -4000,9 +4009,11 @@ See Info node `(elisp)Splitting Windows' for more details and examples.*/) | |||
| 4000 | 4009 | ||
| 4001 | if (NILP (horflag)) | 4010 | if (NILP (horflag)) |
| 4002 | { | 4011 | { |
| 4003 | if (size_int < window_min_height) | 4012 | int window_safe_height = window_min_size_2 (o, 0); |
| 4013 | |||
| 4014 | if (size_int < window_safe_height) | ||
| 4004 | error ("Window height %d too small (after splitting)", size_int); | 4015 | error ("Window height %d too small (after splitting)", size_int); |
| 4005 | if (size_int + window_min_height > XFASTINT (o->total_lines)) | 4016 | if (size_int + window_safe_height > XFASTINT (o->total_lines)) |
| 4006 | error ("Window height %d too small (after splitting)", | 4017 | error ("Window height %d too small (after splitting)", |
| 4007 | XFASTINT (o->total_lines) - size_int); | 4018 | XFASTINT (o->total_lines) - size_int); |
| 4008 | if (NILP (o->parent) | 4019 | if (NILP (o->parent) |
| @@ -4015,10 +4026,11 @@ See Info node `(elisp)Splitting Windows' for more details and examples.*/) | |||
| 4015 | } | 4026 | } |
| 4016 | else | 4027 | else |
| 4017 | { | 4028 | { |
| 4018 | if (size_int < window_min_width) | 4029 | int window_safe_width = window_min_size_2 (o, 1); |
| 4030 | |||
| 4031 | if (size_int < window_safe_width) | ||
| 4019 | error ("Window width %d too small (after splitting)", size_int); | 4032 | error ("Window width %d too small (after splitting)", size_int); |
| 4020 | 4033 | 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)", | 4034 | error ("Window width %d too small (after splitting)", |
| 4023 | XFASTINT (o->total_cols) - size_int); | 4035 | XFASTINT (o->total_cols) - size_int); |
| 4024 | if (NILP (o->parent) | 4036 | if (NILP (o->parent) |
| @@ -4499,7 +4511,7 @@ adjust_window_trailing_edge (window, delta, horiz_flag) | |||
| 4499 | 4511 | ||
| 4500 | /* Don't make this window too small. */ | 4512 | /* Don't make this window too small. */ |
| 4501 | if (XINT (CURSIZE (window)) + delta | 4513 | if (XINT (CURSIZE (window)) + delta |
| 4502 | < (horiz_flag ? window_min_width : window_min_height)) | 4514 | < window_min_size_2 (XWINDOW (window), horiz_flag)) |
| 4503 | { | 4515 | { |
| 4504 | Fset_window_configuration (old_config); | 4516 | Fset_window_configuration (old_config); |
| 4505 | error ("Cannot adjust window size as specified"); | 4517 | error ("Cannot adjust window size as specified"); |