comparison src/window.c @ 81886:f18e4c78670d

(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.
author Martin Rudalics <rudalics@gmx.at>
date Sun, 15 Jul 2007 08:21:41 +0000
parents d3aae5f80fb1
children bb87fadde067
comparison
equal deleted inserted replaced
81885:e0cd45299f77 81886:f18e4c78670d
60 static int get_leaf_windows P_ ((struct window *, struct window **, int)); 60 static int get_leaf_windows P_ ((struct window *, struct window **, int));
61 static void window_scroll P_ ((Lisp_Object, int, int, int)); 61 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 *));
68 static int window_fixed_size_p P_ ((struct window *, int, int)); 69 static int window_fixed_size_p P_ ((struct window *, int, int));
69 static void enlarge_window P_ ((Lisp_Object, int, int)); 70 static void enlarge_window P_ ((Lisp_Object, int, int));
2551 *rows = min_height; 2552 *rows = min_height;
2552 if (*cols < MIN_SAFE_WINDOW_WIDTH) 2553 if (*cols < MIN_SAFE_WINDOW_WIDTH)
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
2560 siblings, too. If none of the siblings is resizable, WINDOW isn't 2560 siblings, too. If none of the siblings is resizable, WINDOW isn't
2561 either. */ 2561 either. */
2653 fixed_p = 1; 2653 fixed_p = 1;
2654 2654
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,
2661 otherwise return the minimum height. If W is a combination window, 2688 otherwise return the minimum height. If W is a combination window,
2662 compute the minimum size from the minimum sizes of W's children. */ 2689 compute the minimum size from the minimum sizes of W's children. */
2722 c = WINDOWP (c->next) ? XWINDOW (c->next) : NULL; 2749 c = WINDOWP (c->next) ? XWINDOW (c->next) : NULL;
2723 } 2750 }
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 }
2746 2758
2747 2759
2979 struct window *w = XWINDOW (window); 2991 struct window *w = XWINDOW (window);
2980 struct window *c; 2992 struct window *c;
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
2992 /* If the window has been "too small" at one point, 2999 /* If the window has been "too small" at one point,
2993 don't delete it for being "too small" in the future. 3000 don't delete it for being "too small" in the future.
2994 Preserve it as long as that is at all possible. */ 3001 Preserve it as long as that is at all possible. */
2995 if (width_p) 3002 if (width_p)
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;
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;
3014 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 {
3018 if (!MINI_WINDOW_P (w) && !NILP (w->too_small_ok)) 3026 if (!MINI_WINDOW_P (w) && !NILP (w->too_small_ok))
3706 Lisp_Object frames; 3714 Lisp_Object frames;
3707 3715
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.
3717 This means they can return nil. */ 3722 This means they can return nil. */
3718 3723
3735 3740
3736 /* If we got a tall enough full-width window that can be split, 3741 /* If we got a tall enough full-width window that can be split,
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 {
3745 Lisp_Object upper, lower, other; 3752 Lisp_Object upper, lower, other;
3746 3753
3749 and can be split, split it. */ 3756 and can be split, split it. */
3750 if (!NILP (window) 3757 if (!NILP (window)
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);
3758 /* If Fget_lru_window returned nil, try other approaches. */ 3767 /* If Fget_lru_window returned nil, try other approaches. */
3759 3768
3998 4007
3999 check_min_window_sizes (); 4008 check_min_window_sizes ();
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)
4009 || NILP (XWINDOW (o->parent)->vchild)) 4020 || NILP (XWINDOW (o->parent)->vchild))
4010 { 4021 {
4013 XWINDOW (new)->vchild = window; 4024 XWINDOW (new)->vchild = window;
4014 } 4025 }
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)
4025 || NILP (XWINDOW (o->parent)->hchild)) 4037 || NILP (XWINDOW (o->parent)->hchild))
4026 { 4038 {
4497 error ("Specified window edge is fixed"); 4509 error ("Specified window edge is fixed");
4498 } 4510 }
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");
4506 } 4518 }
4507 4519