Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 196996
Collapse All | Expand All

(-)src/window.c (-70 / +47 lines)
Lines 62-68 Link Here
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));
66
static int window_min_size P_ ((struct window *, int, int, int *));
65
static int window_min_size P_ ((struct window *, int, int, int *));
67
static void size_window P_ ((Lisp_Object, int, int, int, int, int));
66
static void size_window P_ ((Lisp_Object, int, int, int, int, int));
68
static int freeze_window_start P_ ((struct window *, void *));
67
static int freeze_window_start P_ ((struct window *, void *));
Lines 557-571 Link Here
557
  return make_number (window_box_text_cols (decode_any_window (window)));
556
  return make_number (window_box_text_cols (decode_any_window (window)));
558
}
557
}
559
558
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
569
DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0,
559
DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0,
570
       doc: /* Return the number of columns by which WINDOW is scrolled from left margin.
560
       doc: /* Return the number of columns by which WINDOW is scrolled from left margin.
571
WINDOW defaults to the selected window.  */)
561
WINDOW defaults to the selected window.  */)
Lines 2563-2568 Link Here
2563
    *cols = MIN_SAFE_WINDOW_WIDTH;
2553
    *cols = MIN_SAFE_WINDOW_WIDTH;
2564
}
2554
}
2565
2555
2556
2566
/* 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
2567
   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.
2568
   CHECK_SIBLINGS_P non-zero means check resizablity of WINDOW's
2559
   CHECK_SIBLINGS_P non-zero means check resizablity of WINDOW's
Lines 2664-2696 Link Here
2664
  return fixed_p;
2655
  return fixed_p;
2665
}
2656
}
2666
2657
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
}
2694
2658
2695
/* Return the minimum size of window W, not taking fixed-width windows
2659
/* Return the minimum size of window W, not taking fixed-width windows
2696
   into account.  WIDTH_P non-zero means return the minimum width,
2660
   into account.  WIDTH_P non-zero means return the minimum width,
Lines 2760-2766 Link Here
2760
	}
2724
	}
2761
    }
2725
    }
2762
  else
2726
  else
2763
    size = window_min_size_2 (w, width_p);
2727
    {
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
    }
2764
2743
2765
  return size;
2744
  return size;
2766
}
2745
}
Lines 3002-3007 Link Here
3002
  Lisp_Object child, *forward, *sideward;
2981
  Lisp_Object child, *forward, *sideward;
3003
  int old_size, min_size, safe_min_size;
2982
  int old_size, min_size, safe_min_size;
3004
2983
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
3005
  check_min_window_sizes ();
2989
  check_min_window_sizes ();
3006
  size = max (0, size);
2990
  size = max (0, size);
3007
2991
Lines 3012-3034 Link Here
3012
    {
2996
    {
3013
      old_size = WINDOW_TOTAL_COLS (w);
2997
      old_size = WINDOW_TOTAL_COLS (w);
3014
      min_size = window_min_width;
2998
      min_size = window_min_width;
3015
      safe_min_size = window_min_size_2 (w, 1);
2999
      /* Ensure that there is room for the scroll bar and fringes!
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));
3016
    }
3004
    }
3017
  else
3005
  else
3018
    {
3006
    {
3019
      old_size = XINT (w->total_lines);
3007
      old_size = XINT (w->total_lines);
3020
      min_size = window_min_height;
3008
      min_size = window_min_height;
3021
      safe_min_size = window_min_size_2 (w, 0);
3009
      safe_min_size = MIN_SAFE_WINDOW_HEIGHT;
3022
    }
3010
    }
3023
3011
3024
  if (old_size < min_size && nodelete_p != 2)
3012
  if (old_size < min_size && nodelete_p != 2)
3025
    w->too_small_ok = Qt;
3013
    w->too_small_ok = Qt;
3026
3014
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
3032
  /* Maybe delete WINDOW if it's too small.  */
3015
  /* Maybe delete WINDOW if it's too small.  */
3033
  if (nodelete_p != 1 && !NILP (w->parent))
3016
  if (nodelete_p != 1 && !NILP (w->parent))
3034
    {
3017
    {
Lines 3725-3730 Link Here
3725
      frames = Qnil;
3708
      frames = Qnil;
3726
      if (FRAME_MINIBUF_ONLY_P (f))
3709
      if (FRAME_MINIBUF_ONLY_P (f))
3727
	XSETFRAME (frames, last_nonminibuf_frame);
3710
	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;
3728
3714
3729
      /* Note that both Fget_largest_window and Fget_lru_window
3715
      /* Note that both Fget_largest_window and Fget_lru_window
3730
	 ignore minibuffers and dedicated windows.
3716
	 ignore minibuffers and dedicated windows.
Lines 3747-3776 Link Here
3747
      else
3733
      else
3748
	window = Fget_largest_window (frames, Qt);
3734
	window = Fget_largest_window (frames, Qt);
3749
3735
3750
      /* If the largest window is tall enough, full-width, and either eligible
3736
      /* If we got a tall enough full-width window that can be split,
3751
	 for splitting or the only window, split it.  */
3737
	 split it.  */
3752
      if (!NILP (window)
3738
      if (!NILP (window)
3753
	  && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3739
	  && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3754
	  && WINDOW_FULL_WIDTH_P (XWINDOW (window))
3740
	  && window_height (window) >= split_height_threshold
3755
	  && (window_height (window) >= split_height_threshold
3741
	  && WINDOW_FULL_WIDTH_P (XWINDOW (window)))
3756
	      || (NILP (XWINDOW (window)->parent)))
3757
	  && (window_height (window)
3758
	      >= (2 * window_min_size_2 (XWINDOW (window), 0))))
3759
	window = Fsplit_window (window, Qnil, Qnil);
3742
	window = Fsplit_window (window, Qnil, Qnil);
3760
      else
3743
      else
3761
	{
3744
	{
3762
	  Lisp_Object upper, lower, other;
3745
	  Lisp_Object upper, lower, other;
3763
3746
3764
	  window = Fget_lru_window (frames, Qt);
3747
	  window = Fget_lru_window (frames, Qt);
3765
	  /* If the LRU window is tall enough, and either eligible for splitting
3748
	  /* If the LRU window is selected, and big enough,
3766
	  and selected or the only window, split it.  */
3749
	     and can be split, split it.  */
3767
	  if (!NILP (window)
3750
	  if (!NILP (window)
3768
	      && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3751
	      && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window)->frame))
3769
	      && ((EQ (window, selected_window)
3752
	      && (EQ (window, selected_window)
3770
		   && window_height (window) >= split_height_threshold)
3753
		  || EQ (XWINDOW (window)->parent, Qnil))
3771
		  || (NILP (XWINDOW (window)->parent)))
3754
	      && window_height (window) >= window_min_height << 1)
3772
	      && (window_height (window)
3773
		  >= (2 * window_min_size_2 (XWINDOW (window), 0))))
3774
	    window = Fsplit_window (window, Qnil, Qnil);
3755
	    window = Fsplit_window (window, Qnil, Qnil);
3775
	  else
3756
	  else
3776
	    window = Fget_lru_window (frames, Qnil);
3757
	    window = Fget_lru_window (frames, Qnil);
Lines 4019-4029 Link Here
4019
4000
4020
  if (NILP (horflag))
4001
  if (NILP (horflag))
4021
    {
4002
    {
4022
      int window_safe_height = window_min_size_2 (o, 0);
4003
      if (size_int < window_min_height)
4023
      
4024
      if (size_int < window_safe_height)
4025
	error ("Window height %d too small (after splitting)", size_int);
4004
	error ("Window height %d too small (after splitting)", size_int);
4026
      if (size_int + window_safe_height > XFASTINT (o->total_lines))
4005
      if (size_int + window_min_height > XFASTINT (o->total_lines))
4027
	error ("Window height %d too small (after splitting)",
4006
	error ("Window height %d too small (after splitting)",
4028
	       XFASTINT (o->total_lines) - size_int);
4007
	       XFASTINT (o->total_lines) - size_int);
4029
      if (NILP (o->parent)
4008
      if (NILP (o->parent)
Lines 4036-4046 Link Here
4036
    }
4015
    }
4037
  else
4016
  else
4038
    {
4017
    {
4039
      int window_safe_width = window_min_size_2 (o, 1);
4018
      if (size_int < window_min_width)
4040
      
4041
      if (size_int < window_safe_width)
4042
	error ("Window width %d too small (after splitting)", size_int);
4019
	error ("Window width %d too small (after splitting)", size_int);
4043
      if (size_int + window_safe_width > XFASTINT (o->total_cols))
4020
4021
      if (size_int + window_min_width > XFASTINT (o->total_cols))
4044
	error ("Window width %d too small (after splitting)",
4022
	error ("Window width %d too small (after splitting)",
4045
	       XFASTINT (o->total_cols) - size_int);
4023
	       XFASTINT (o->total_cols) - size_int);
4046
      if (NILP (o->parent)
4024
      if (NILP (o->parent)
Lines 4521-4527 Link Here
4521
4499
4522
      /* Don't make this window too small.  */
4500
      /* Don't make this window too small.  */
4523
      if (XINT (CURSIZE (window)) + delta
4501
      if (XINT (CURSIZE (window)) + delta
4524
	  < window_min_size_2 (XWINDOW (window), horiz_flag))
4502
	  < (horiz_flag ? window_min_width : window_min_height))
4525
	{
4503
	{
4526
	  Fset_window_configuration (old_config);
4504
	  Fset_window_configuration (old_config);
4527
	  error ("Cannot adjust window size as specified");
4505
	  error ("Cannot adjust window size as specified");
Lines 6919-6925 Link Here
6919
	vertical_type = Qnil;
6897
	vertical_type = Qnil;
6920
    }
6898
    }
6921
6899
6922
  if (!(NILP (vertical_type)
6900
  if (!(EQ (vertical_type, Qnil)
6923
	|| EQ (vertical_type, Qleft)
6901
	|| EQ (vertical_type, Qleft)
6924
	|| EQ (vertical_type, Qright)
6902
	|| EQ (vertical_type, Qright)
6925
	|| EQ (vertical_type, Qt)))
6903
	|| EQ (vertical_type, Qt)))
Lines 7524-7530 Link Here
7524
  defsubr (&Swindow_buffer);
7502
  defsubr (&Swindow_buffer);
7525
  defsubr (&Swindow_height);
7503
  defsubr (&Swindow_height);
7526
  defsubr (&Swindow_width);
7504
  defsubr (&Swindow_width);
7527
  defsubr (&Swindow_full_width_p);
7528
  defsubr (&Swindow_hscroll);
7505
  defsubr (&Swindow_hscroll);
7529
  defsubr (&Sset_window_hscroll);
7506
  defsubr (&Sset_window_hscroll);
7530
  defsubr (&Swindow_redisplay_end_trigger);
7507
  defsubr (&Swindow_redisplay_end_trigger);

Return to bug 196996