aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorJoakim Verona2011-02-05 11:23:09 +0100
committerJoakim Verona2011-02-05 11:23:09 +0100
commit4bd51ad5c3445b644dfb017d5b57b10a90aa325f (patch)
tree894801e7308ce4ecc34933f959e28f4b9cff9533 /src/window.c
parent13cfe8df462ab8da9f0028e16cc84dcaceaca3d1 (diff)
parent9bcaafce5351d270ac514e23cb69ff1a5fd35229 (diff)
downloademacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.tar.gz
emacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.zip
merge from upstream. currently seems to have bitroted and i get segfaults
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c407
1 files changed, 178 insertions, 229 deletions
diff --git a/src/window.c b/src/window.c
index 103324e424e..1a02a3b1cbb 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,7 +1,6 @@
1/* Window creation, deletion and examination for GNU Emacs. 1/* Window creation, deletion and examination for GNU Emacs.
2 Does not include redisplay. 2 Does not include redisplay.
3 Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 3 Copyright (C) 1985-1987, 1993-1998, 2000-2011
4 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
5 Free Software Foundation, Inc. 4 Free Software Foundation, Inc.
6 5
7This file is part of GNU Emacs. 6This file is part of GNU Emacs.
@@ -80,10 +79,14 @@ static Lisp_Object next_window (Lisp_Object, Lisp_Object,
80 Lisp_Object, int); 79 Lisp_Object, int);
81static void decode_next_window_args (Lisp_Object *, Lisp_Object *, 80static void decode_next_window_args (Lisp_Object *, Lisp_Object *,
82 Lisp_Object *); 81 Lisp_Object *);
82static void foreach_window (struct frame *,
83 int (* fn) (struct window *, void *),
84 void *);
83static int foreach_window_1 (struct window *, 85static int foreach_window_1 (struct window *,
84 int (* fn) (struct window *, void *), 86 int (* fn) (struct window *, void *),
85 void *); 87 void *);
86static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object); 88static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object);
89static Lisp_Object select_window (Lisp_Object, Lisp_Object, int);
87 90
88/* This is the window in which the terminal's cursor should 91/* This is the window in which the terminal's cursor should
89 be left when nothing is being done with it. This must 92 be left when nothing is being done with it. This must
@@ -113,42 +116,10 @@ Lisp_Object minibuf_window;
113 116
114Lisp_Object minibuf_selected_window; 117Lisp_Object minibuf_selected_window;
115 118
116/* Non-nil means it is the window for C-M-v to scroll
117 when the mini-buffer is selected. */
118
119Lisp_Object Vminibuf_scroll_window;
120
121/* Non-nil means this is the buffer whose window C-M-v should scroll. */
122
123Lisp_Object Vother_window_scroll_buffer;
124
125/* Non-nil means it's function to call to display temp buffers. */
126
127Lisp_Object Vtemp_buffer_show_function;
128
129/* Non-zero means line and page scrolling on tall lines (with images)
130 does partial scrolling by modifying window-vscroll. */
131
132int auto_window_vscroll_p;
133
134/* Non-zero means to use mode-line-inactive face in all windows but the
135 selected-window and the minibuffer-scroll-window when the
136 minibuffer is active. */
137int mode_line_in_non_selected_windows;
138
139/* If a window gets smaller than either of these, it is removed. */
140
141EMACS_INT window_min_height;
142EMACS_INT window_min_width;
143
144/* Hook run at end of temp_output_buffer_show. */ 119/* Hook run at end of temp_output_buffer_show. */
145 120
146Lisp_Object Qtemp_buffer_show_hook; 121Lisp_Object Qtemp_buffer_show_hook;
147 122
148/* Number of lines of continuity in scrolling by screenfuls. */
149
150EMACS_INT next_screen_context_lines;
151
152/* Incremented for each window created. */ 123/* Incremented for each window created. */
153 124
154static int sequence_number; 125static int sequence_number;
@@ -160,17 +131,6 @@ static int window_initialized;
160/* Hook to run when window config changes. */ 131/* Hook to run when window config changes. */
161 132
162static Lisp_Object Qwindow_configuration_change_hook; 133static Lisp_Object Qwindow_configuration_change_hook;
163static Lisp_Object Vwindow_configuration_change_hook;
164
165/* Non-nil means scroll commands try to put point
166 at the same screen height as previously. */
167
168Lisp_Object Vscroll_preserve_screen_position;
169
170/* Non-nil means that text is inserted before window's markers. */
171
172Lisp_Object Vwindow_point_insertion_type;
173
174/* Incremented by 1 whenever a window is deleted. */ 134/* Incremented by 1 whenever a window is deleted. */
175 135
176int window_deletion_count; 136int window_deletion_count;
@@ -188,13 +148,7 @@ static int window_scroll_preserve_vpos;
188#if 0 /* This isn't used anywhere. */ 148#if 0 /* This isn't used anywhere. */
189/* Nonzero means we can split a frame even if it is "unsplittable". */ 149/* Nonzero means we can split a frame even if it is "unsplittable". */
190static int inhibit_frame_unsplittable; 150static int inhibit_frame_unsplittable;
191#endif /* 0 */ 151#endif
192
193/* If non-nil, then the `recenter' command with a nil argument
194 the entire frame to be redrawn; the special value `tty' causes the
195 frame to be redrawn only if it is a tty frame. */
196
197static Lisp_Object Vrecenter_redisplay;
198 152
199 153
200DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, 154DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0,
@@ -757,32 +711,26 @@ display margins, fringes, header line, and/or mode line. */)
757 - WINDOW_MODE_LINE_HEIGHT (w) + add_y)); 711 - WINDOW_MODE_LINE_HEIGHT (w) + add_y));
758} 712}
759 713
760/* Test if the character at column *X, row *Y is within window W. 714/* Test if the character at column X, row Y is within window W.
761 If it is not, return ON_NOTHING; 715 If it is not, return ON_NOTHING;
762 if it is in the window's text area, 716 if it is in the window's text area, return ON_TEXT;
763 set *x and *y to its location relative to the upper left corner
764 of the window, and
765 return ON_TEXT;
766 if it is on the window's modeline, return ON_MODE_LINE; 717 if it is on the window's modeline, return ON_MODE_LINE;
767 if it is on the border between the window and its right sibling, 718 if it is on the border between the window and its right sibling,
768 return ON_VERTICAL_BORDER. 719 return ON_VERTICAL_BORDER.
769 if it is on a scroll bar, 720 if it is on a scroll bar, return ON_SCROLL_BAR.
770 return ON_SCROLL_BAR.
771 if it is on the window's top line, return ON_HEADER_LINE; 721 if it is on the window's top line, return ON_HEADER_LINE;
772 if it is in left or right fringe of the window, 722 if it is in left or right fringe of the window,
773 return ON_LEFT_FRINGE or ON_RIGHT_FRINGE, and convert *X and *Y 723 return ON_LEFT_FRINGE or ON_RIGHT_FRINGE;
774 to window-relative coordinates;
775 if it is in the marginal area to the left/right of the window, 724 if it is in the marginal area to the left/right of the window,
776 return ON_LEFT_MARGIN or ON_RIGHT_MARGIN, and convert *X and *Y 725 return ON_LEFT_MARGIN or ON_RIGHT_MARGIN.
777 to window-relative coordinates.
778 726
779 X and Y are frame relative pixel coordinates. */ 727 X and Y are frame relative pixel coordinates. */
780 728
781static enum window_part 729static enum window_part
782coordinates_in_window (register struct window *w, register int *x, register int *y) 730coordinates_in_window (register struct window *w, int x, int y)
783{ 731{
784 struct frame *f = XFRAME (WINDOW_FRAME (w)); 732 struct frame *f = XFRAME (WINDOW_FRAME (w));
785 int left_x, right_x, top_y, bottom_y; 733 int left_x, right_x;
786 enum window_part part; 734 enum window_part part;
787 int ux = FRAME_COLUMN_WIDTH (f); 735 int ux = FRAME_COLUMN_WIDTH (f);
788 int x0 = WINDOW_LEFT_EDGE_X (w); 736 int x0 = WINDOW_LEFT_EDGE_X (w);
@@ -791,6 +739,12 @@ coordinates_in_window (register struct window *w, register int *x, register int
791 (Between mode lines for instance. */ 739 (Between mode lines for instance. */
792 int grabbable_width = ux; 740 int grabbable_width = ux;
793 int lmargin_width, rmargin_width, text_left, text_right; 741 int lmargin_width, rmargin_width, text_left, text_right;
742 int top_y = WINDOW_TOP_EDGE_Y (w);
743 int bottom_y = WINDOW_BOTTOM_EDGE_Y (w);
744
745 /* Outside any interesting row? */
746 if (y < top_y || y >= bottom_y)
747 return ON_NOTHING;
794 748
795 /* In what's below, we subtract 1 when computing right_x because we 749 /* In what's below, we subtract 1 when computing right_x because we
796 want the rightmost pixel, which is given by left_pixel+width-1. */ 750 want the rightmost pixel, which is given by left_pixel+width-1. */
@@ -798,21 +752,13 @@ coordinates_in_window (register struct window *w, register int *x, register int
798 { 752 {
799 left_x = 0; 753 left_x = 0;
800 right_x = WINDOW_TOTAL_WIDTH (w) - 1; 754 right_x = WINDOW_TOTAL_WIDTH (w) - 1;
801 top_y = WINDOW_TOP_EDGE_Y (w);
802 bottom_y = WINDOW_BOTTOM_EDGE_Y (w);
803 } 755 }
804 else 756 else
805 { 757 {
806 left_x = WINDOW_BOX_LEFT_EDGE_X (w); 758 left_x = WINDOW_BOX_LEFT_EDGE_X (w);
807 right_x = WINDOW_BOX_RIGHT_EDGE_X (w) - 1; 759 right_x = WINDOW_BOX_RIGHT_EDGE_X (w) - 1;
808 top_y = WINDOW_TOP_EDGE_Y (w);
809 bottom_y = WINDOW_BOTTOM_EDGE_Y (w);
810 } 760 }
811 761
812 /* Outside any interesting row? */
813 if (*y < top_y || *y >= bottom_y)
814 return ON_NOTHING;
815
816 /* On the mode line or header line? If it's near the start of 762 /* On the mode line or header line? If it's near the start of
817 the mode or header line of window that's has a horizontal 763 the mode or header line of window that's has a horizontal
818 sibling, say it's on the vertical line. That's to be able 764 sibling, say it's on the vertical line. That's to be able
@@ -820,7 +766,7 @@ coordinates_in_window (register struct window *w, register int *x, register int
820 scroll bars. */ 766 scroll bars. */
821 767
822 if (WINDOW_WANTS_MODELINE_P (w) 768 if (WINDOW_WANTS_MODELINE_P (w)
823 && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) 769 && y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w))
824 { 770 {
825 part = ON_MODE_LINE; 771 part = ON_MODE_LINE;
826 772
@@ -829,60 +775,37 @@ coordinates_in_window (register struct window *w, register int *x, register int
829 between mode lines of horizontally adjacent mode lines 775 between mode lines of horizontally adjacent mode lines
830 as the vertical border. If scroll bars on the left, 776 as the vertical border. If scroll bars on the left,
831 return the right window. */ 777 return the right window. */
832 if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) 778 if ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w)
833 || WINDOW_RIGHTMOST_P (w)) 779 || WINDOW_RIGHTMOST_P (w))
834 { 780 && !WINDOW_LEFTMOST_P (w)
835 if (!WINDOW_LEFTMOST_P (w) && eabs (*x - x0) < grabbable_width) 781 && eabs (x - x0) < grabbable_width)
836 { 782 return ON_VERTICAL_BORDER;
837 /* Convert X and Y to window relative coordinates. 783
838 Vertical border is at the left edge of window. */ 784 /* Make sure we're not at the rightmost position of a
839 *x = max (0, *x - x0); 785 mode-/header-line and there's yet another window on the
840 *y -= top_y; 786 right. (Bug#1372) */
841 return ON_VERTICAL_BORDER; 787 else if ((WINDOW_RIGHTMOST_P (w) || x < x1)
842 } 788 && eabs (x - x1) < grabbable_width)
843 } 789 return ON_VERTICAL_BORDER;
844 else 790
845 { 791 if (x < x0 || x >= x1)
846 /* Make sure we're not at the rightmost position of a
847 mode-/header-line and there's yet another window on
848 the right. (Bug#1372) */
849 if ((WINDOW_RIGHTMOST_P (w) || *x < x1)
850 && eabs (*x - x1) < grabbable_width)
851 {
852 /* Convert X and Y to window relative coordinates.
853 Vertical border is at the right edge of window. */
854 *x = min (x1, *x) - x0;
855 *y -= top_y;
856 return ON_VERTICAL_BORDER;
857 }
858 }
859
860 if (*x < x0 || *x >= x1)
861 return ON_NOTHING; 792 return ON_NOTHING;
862 793
863 /* Convert X and Y to window relative coordinates.
864 Mode line starts at left edge of window. */
865 *x -= x0;
866 *y -= top_y;
867 return part; 794 return part;
868 } 795 }
869 796
870 if (WINDOW_WANTS_HEADER_LINE_P (w) 797 if (WINDOW_WANTS_HEADER_LINE_P (w)
871 && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)) 798 && y < top_y + CURRENT_HEADER_LINE_HEIGHT (w))
872 { 799 {
873 part = ON_HEADER_LINE; 800 part = ON_HEADER_LINE;
874 goto header_vertical_border_check; 801 goto header_vertical_border_check;
875 } 802 }
876 803
877 if (*x < x0 || *x >= x1) 804 if (x < x0 || x >= x1) return ON_NOTHING;
878 return ON_NOTHING;
879 805
880 /* Outside any interesting column? */ 806 /* Outside any interesting column? */
881 if (*x < left_x || *x > right_x) 807 if (x < left_x || x > right_x)
882 { 808 return ON_SCROLL_BAR;
883 *y -= top_y;
884 return ON_SCROLL_BAR;
885 }
886 809
887 lmargin_width = window_box_width (w, LEFT_MARGIN_AREA); 810 lmargin_width = window_box_width (w, LEFT_MARGIN_AREA);
888 rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA); 811 rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA);
@@ -895,77 +818,79 @@ coordinates_in_window (register struct window *w, register int *x, register int
895 if (!w->pseudo_window_p 818 if (!w->pseudo_window_p
896 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w) 819 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w)
897 && !WINDOW_RIGHTMOST_P (w) 820 && !WINDOW_RIGHTMOST_P (w)
898 && (eabs (*x - right_x) < grabbable_width)) 821 && (eabs (x - right_x) < grabbable_width))
899 { 822 return ON_VERTICAL_BORDER;
900 /* Convert X and Y to window relative coordinates.
901 Vertical border is at the right edge of window. */
902 *x = min (right_x, *x) - left_x;
903 *y -= top_y;
904 return ON_VERTICAL_BORDER;
905 }
906 }
907 else
908 {
909 /* Need to say "*x > right_x" rather than >=, since on character
910 terminals, the vertical line's x coordinate is right_x. */
911 if (!w->pseudo_window_p
912 && !WINDOW_RIGHTMOST_P (w)
913 && *x > right_x - ux)
914 {
915 /* On the border on the right side of the window? Assume that
916 this area begins at RIGHT_X minus a canonical char width. */
917 *x = min (right_x, *x) - left_x;
918 *y -= top_y;
919 return ON_VERTICAL_BORDER;
920 }
921 } 823 }
824 /* Need to say "x > right_x" rather than >=, since on character
825 terminals, the vertical line's x coordinate is right_x. */
826 else if (!w->pseudo_window_p
827 && !WINDOW_RIGHTMOST_P (w)
828 && x > right_x - ux)
829 return ON_VERTICAL_BORDER;
922 830
923 if (*x < text_left) 831 if (x < text_left)
924 { 832 {
925 if (lmargin_width > 0 833 if (lmargin_width > 0
926 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) 834 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
927 ? (*x >= left_x + WINDOW_LEFT_FRINGE_WIDTH (w)) 835 ? (x >= left_x + WINDOW_LEFT_FRINGE_WIDTH (w))
928 : (*x < left_x + lmargin_width))) 836 : (x < left_x + lmargin_width)))
929 { 837 return ON_LEFT_MARGIN;
930 *x -= left_x;
931 if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w))
932 *x -= WINDOW_LEFT_FRINGE_WIDTH (w);
933 *y -= top_y;
934 return ON_LEFT_MARGIN;
935 }
936 838
937 /* Convert X and Y to window-relative pixel coordinates. */
938 *x -= left_x;
939 *y -= top_y;
940 return ON_LEFT_FRINGE; 839 return ON_LEFT_FRINGE;
941 } 840 }
942 841
943 if (*x >= text_right) 842 if (x >= text_right)
944 { 843 {
945 if (rmargin_width > 0 844 if (rmargin_width > 0
946 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) 845 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
947 ? (*x < right_x - WINDOW_RIGHT_FRINGE_WIDTH (w)) 846 ? (x < right_x - WINDOW_RIGHT_FRINGE_WIDTH (w))
948 : (*x >= right_x - rmargin_width))) 847 : (x >= right_x - rmargin_width)))
949 { 848 return ON_RIGHT_MARGIN;
950 *x -= right_x - rmargin_width;
951 if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w))
952 *x += WINDOW_RIGHT_FRINGE_WIDTH (w);
953 *y -= top_y;
954 return ON_RIGHT_MARGIN;
955 }
956 849
957 /* Convert X and Y to window-relative pixel coordinates. */
958 *x -= left_x + WINDOW_LEFT_FRINGE_WIDTH (w);
959 *y -= top_y;
960 return ON_RIGHT_FRINGE; 850 return ON_RIGHT_FRINGE;
961 } 851 }
962 852
963 /* Everything special ruled out - must be on text area */ 853 /* Everything special ruled out - must be on text area */
964 *x -= text_left;
965 *y -= top_y;
966 return ON_TEXT; 854 return ON_TEXT;
967} 855}
968 856
857/* Take X is the frame-relative pixel x-coordinate, and return the
858 x-coordinate relative to part PART of window W. */
859int
860window_relative_x_coord (struct window *w, enum window_part part, int x)
861{
862 int left_x = (w->pseudo_window_p) ? 0 : WINDOW_BOX_LEFT_EDGE_X (w);
863
864 switch (part)
865 {
866 case ON_TEXT:
867 return x - window_box_left (w, TEXT_AREA);
868
869 case ON_LEFT_FRINGE:
870 return x - left_x;
871
872 case ON_RIGHT_FRINGE:
873 return x - left_x - WINDOW_LEFT_FRINGE_WIDTH (w);
874
875 case ON_LEFT_MARGIN:
876 return (x - left_x
877 - ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w))
878 ? WINDOW_LEFT_FRINGE_WIDTH (w) : 0));
879
880 case ON_RIGHT_MARGIN:
881 return (x + 1
882 - ((w->pseudo_window_p)
883 ? WINDOW_TOTAL_WIDTH (w)
884 : WINDOW_BOX_RIGHT_EDGE_X (w))
885 + window_box_width (w, RIGHT_MARGIN_AREA)
886 + ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w))
887 ? WINDOW_RIGHT_FRINGE_WIDTH (w) : 0));
888 }
889
890 /* ON_SCROLL_BAR, ON_NOTHING, and ON_VERTICAL_BORDER: */
891 return 0;
892}
893
969 894
970DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, 895DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p,
971 Scoordinates_in_window_p, 2, 2, 0, 896 Scoordinates_in_window_p, 2, 2, 0,
@@ -1002,14 +927,16 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\
1002 x = FRAME_PIXEL_X_FROM_CANON_X (f, lx) + FRAME_INTERNAL_BORDER_WIDTH (f); 927 x = FRAME_PIXEL_X_FROM_CANON_X (f, lx) + FRAME_INTERNAL_BORDER_WIDTH (f);
1003 y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly) + FRAME_INTERNAL_BORDER_WIDTH (f); 928 y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly) + FRAME_INTERNAL_BORDER_WIDTH (f);
1004 929
1005 switch (coordinates_in_window (w, &x, &y)) 930 switch (coordinates_in_window (w, x, y))
1006 { 931 {
1007 case ON_NOTHING: 932 case ON_NOTHING:
1008 return Qnil; 933 return Qnil;
1009 934
1010 case ON_TEXT: 935 case ON_TEXT:
1011 /* X and Y are now window relative pixel coordinates. Convert 936 /* Convert X and Y to window relative pixel coordinates, and
1012 them to canonical char units before returning them. */ 937 return the canonical char units. */
938 x -= window_box_left (w, TEXT_AREA);
939 y -= WINDOW_TOP_EDGE_Y (w);
1013 return Fcons (FRAME_CANON_X_FROM_PIXEL_X (f, x), 940 return Fcons (FRAME_CANON_X_FROM_PIXEL_X (f, x),
1014 FRAME_CANON_Y_FROM_PIXEL_Y (f, y)); 941 FRAME_CANON_Y_FROM_PIXEL_Y (f, y));
1015 942
@@ -1056,7 +983,7 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\
1056struct check_window_data 983struct check_window_data
1057{ 984{
1058 Lisp_Object *window; 985 Lisp_Object *window;
1059 int *x, *y; 986 int x, y;
1060 enum window_part *part; 987 enum window_part *part;
1061}; 988};
1062 989
@@ -1083,8 +1010,7 @@ check_window_containing (struct window *w, void *user_data)
1083 return it as a Lisp_Object. 1010 return it as a Lisp_Object.
1084 1011
1085 If X, Y is on one of the window's special `window_part' elements, 1012 If X, Y is on one of the window's special `window_part' elements,
1086 set *PART to the id of that element, and return X and Y converted 1013 set *PART to the id of that element.
1087 to window relative coordinates in WX and WY.
1088 1014
1089 If there is no window under X, Y return nil and leave *PART 1015 If there is no window under X, Y return nil and leave *PART
1090 unmodified. TOOL_BAR_P non-zero means detect tool-bar windows. 1016 unmodified. TOOL_BAR_P non-zero means detect tool-bar windows.
@@ -1099,7 +1025,8 @@ check_window_containing (struct window *w, void *user_data)
1099 case. */ 1025 case. */
1100 1026
1101Lisp_Object 1027Lisp_Object
1102window_from_coordinates (struct frame *f, int x, int y, enum window_part *part, int *wx, int *wy, int tool_bar_p) 1028window_from_coordinates (struct frame *f, int x, int y,
1029 enum window_part *part, int tool_bar_p)
1103{ 1030{
1104 Lisp_Object window; 1031 Lisp_Object window;
1105 struct check_window_data cw; 1032 struct check_window_data cw;
@@ -1109,7 +1036,7 @@ window_from_coordinates (struct frame *f, int x, int y, enum window_part *part,
1109 part = &dummy; 1036 part = &dummy;
1110 1037
1111 window = Qnil; 1038 window = Qnil;
1112 cw.window = &window, cw.x = &x, cw.y = &y; cw.part = part; 1039 cw.window = &window, cw.x = x, cw.y = y; cw.part = part;
1113 foreach_window (f, check_window_containing, &cw); 1040 foreach_window (f, check_window_containing, &cw);
1114 1041
1115 /* If not found above, see if it's in the tool bar window, if a tool 1042 /* If not found above, see if it's in the tool bar window, if a tool
@@ -1118,16 +1045,13 @@ window_from_coordinates (struct frame *f, int x, int y, enum window_part *part,
1118 && tool_bar_p 1045 && tool_bar_p
1119 && WINDOWP (f->tool_bar_window) 1046 && WINDOWP (f->tool_bar_window)
1120 && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)) > 0 1047 && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)) > 0
1121 && (coordinates_in_window (XWINDOW (f->tool_bar_window), &x, &y) 1048 && (coordinates_in_window (XWINDOW (f->tool_bar_window), x, y)
1122 != ON_NOTHING)) 1049 != ON_NOTHING))
1123 { 1050 {
1124 *part = ON_TEXT; 1051 *part = ON_TEXT;
1125 window = f->tool_bar_window; 1052 window = f->tool_bar_window;
1126 } 1053 }
1127 1054
1128 if (wx) *wx = x;
1129 if (wy) *wy = y;
1130
1131 return window; 1055 return window;
1132} 1056}
1133 1057
@@ -1154,7 +1078,7 @@ column 0. */)
1154 + FRAME_INTERNAL_BORDER_WIDTH (f)), 1078 + FRAME_INTERNAL_BORDER_WIDTH (f)),
1155 (FRAME_PIXEL_Y_FROM_CANON_Y (f, y) 1079 (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
1156 + FRAME_INTERNAL_BORDER_WIDTH (f)), 1080 + FRAME_INTERNAL_BORDER_WIDTH (f)),
1157 0, 0, 0, 0); 1081 0, 0);
1158} 1082}
1159 1083
1160DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, 1084DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0,
@@ -1457,6 +1381,8 @@ DEFUN ("set-window-display-table", Fset_window_display_table, Sset_window_displa
1457 return table; 1381 return table;
1458} 1382}
1459 1383
1384static void delete_window (Lisp_Object);
1385
1460/* Record info on buffer window w is displaying 1386/* Record info on buffer window w is displaying
1461 when it is about to cease to display that buffer. */ 1387 when it is about to cease to display that buffer. */
1462static void 1388static void
@@ -1580,7 +1506,7 @@ Signal an error when WINDOW is the only window on its frame. */)
1580 return Qnil; 1506 return Qnil;
1581} 1507}
1582 1508
1583void 1509static void
1584delete_window (register Lisp_Object window) 1510delete_window (register Lisp_Object window)
1585{ 1511{
1586 register Lisp_Object tem, parent, sib; 1512 register Lisp_Object tem, parent, sib;
@@ -2422,6 +2348,16 @@ check_all_windows (void)
2422 window_loop (CHECK_ALL_WINDOWS, Qnil, 1, Qt); 2348 window_loop (CHECK_ALL_WINDOWS, Qnil, 1, Qt);
2423} 2349}
2424 2350
2351DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0,
2352 doc: /* Return WINDOW's use time.
2353WINDOW defaults to the selected window. The window with the highest use
2354time is the most recently selected one. The window with the lowest use
2355time is the least recently selected one. */)
2356 (Lisp_Object window)
2357{
2358 return decode_window (window)->use_time;
2359}
2360
2425DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 2, 0, 2361DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 2, 0,
2426 doc: /* Return the window least recently selected or used for display. 2362 doc: /* Return the window least recently selected or used for display.
2427\(LRU means Least Recently Used.) 2363\(LRU means Least Recently Used.)
@@ -3544,11 +3480,12 @@ This function runs `window-scroll-functions' before running
3544 else if (!EQ (tem, Qt)) 3480 else if (!EQ (tem, Qt))
3545 /* w->buffer is t when the window is first being set up. */ 3481 /* w->buffer is t when the window is first being set up. */
3546 { 3482 {
3547 if (!EQ (tem, buffer)) 3483 if (EQ (tem, buffer))
3548 if (EQ (w->dedicated, Qt)) 3484 return Qnil;
3549 error ("Window is dedicated to `%s'", SDATA (XBUFFER (tem)->name)); 3485 else if (EQ (w->dedicated, Qt))
3550 else 3486 error ("Window is dedicated to `%s'", SDATA (XBUFFER (tem)->name));
3551 w->dedicated = Qnil; 3487 else
3488 w->dedicated = Qnil;
3552 3489
3553 unshow_buffer (w); 3490 unshow_buffer (w);
3554 } 3491 }
@@ -3557,20 +3494,14 @@ This function runs `window-scroll-functions' before running
3557 return Qnil; 3494 return Qnil;
3558} 3495}
3559 3496
3560/* Note that selected_window can be nil when this is called from 3497/* If select_window is called with inhibit_point_swap non-zero it will
3561 Fset_window_configuration. */ 3498 not store point of the old selected window's buffer back into that
3562 3499 window's pointm slot. This is needed by Fset_window_configuration to
3563DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, 3500 avoid that the display routine is called with selected_window set to
3564 doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer. 3501 Qnil causing a subsequent crash. */
3565If WINDOW is not already selected, make WINDOW's buffer current
3566and make WINDOW the frame's selected window. Return WINDOW.
3567Optional second arg NORECORD non-nil means do not put this buffer
3568at the front of the list of recently selected ones and do not
3569make this window the most recently selected one.
3570 3502
3571Note that the main editor command loop selects the buffer of the 3503static Lisp_Object
3572selected window before each command. */) 3504select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
3573 (register Lisp_Object window, Lisp_Object norecord)
3574{ 3505{
3575 register struct window *w; 3506 register struct window *w;
3576 register struct window *ow; 3507 register struct window *ow;
@@ -3610,7 +3541,7 @@ selected window before each command. */)
3610 /* Store the current buffer's actual point into the 3541 /* Store the current buffer's actual point into the
3611 old selected window. It belongs to that window, 3542 old selected window. It belongs to that window,
3612 and when the window is not selected, must be in the window. */ 3543 and when the window is not selected, must be in the window. */
3613 if (!NILP (selected_window)) 3544 if (!inhibit_point_swap)
3614 { 3545 {
3615 ow = XWINDOW (selected_window); 3546 ow = XWINDOW (selected_window);
3616 if (! NILP (ow->buffer)) 3547 if (! NILP (ow->buffer))
@@ -3645,6 +3576,25 @@ selected window before each command. */)
3645 return window; 3576 return window;
3646} 3577}
3647 3578
3579
3580/* Note that selected_window can be nil when this is called from
3581 Fset_window_configuration. */
3582
3583DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,
3584 doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer.
3585If WINDOW is not already selected, make WINDOW's buffer current
3586and make WINDOW the frame's selected window. Return WINDOW.
3587Optional second arg NORECORD non-nil means do not put this buffer
3588at the front of the list of recently selected ones and do not
3589make this window the most recently selected one.
3590
3591Note that the main editor command loop selects the buffer of the
3592selected window before each command. */)
3593 (register Lisp_Object window, Lisp_Object norecord)
3594{
3595 select_window (window, norecord, 0);
3596}
3597
3648static Lisp_Object 3598static Lisp_Object
3649select_window_norecord (Lisp_Object window) 3599select_window_norecord (Lisp_Object window)
3650{ 3600{
@@ -3980,14 +3930,14 @@ fixed size windows is not altered by this function. */)
3980 return Qnil; 3930 return Qnil;
3981} 3931}
3982 3932
3983int 3933static int
3984window_height (Lisp_Object window) 3934window_height (Lisp_Object window)
3985{ 3935{
3986 register struct window *p = XWINDOW (window); 3936 register struct window *p = XWINDOW (window);
3987 return WINDOW_TOTAL_LINES (p); 3937 return WINDOW_TOTAL_LINES (p);
3988} 3938}
3989 3939
3990int 3940static int
3991window_width (Lisp_Object window) 3941window_width (Lisp_Object window)
3992{ 3942{
3993 register struct window *p = XWINDOW (window); 3943 register struct window *p = XWINDOW (window);
@@ -5779,6 +5729,12 @@ zero means top of window, negative means relative to bottom of window. */)
5779 int this_scroll_margin; 5729 int this_scroll_margin;
5780#endif 5730#endif
5781 5731
5732 if (!(BUFFERP (w->buffer)
5733 && XBUFFER (w->buffer) == current_buffer))
5734 /* This test is needed to make sure PT/PT_BYTE make sense in w->buffer
5735 when passed below to set_marker_both. */
5736 error ("move-to-window-line called from unrelated buffer");
5737
5782 window = selected_window; 5738 window = selected_window;
5783 start = marker_position (w->start); 5739 start = marker_position (w->start);
5784 if (start < BEGV || start > ZV) 5740 if (start < BEGV || start > ZV)
@@ -6155,10 +6111,6 @@ the return value is nil. Otherwise the value is t. */)
6155 } 6111 }
6156 6112
6157 FRAME_ROOT_WINDOW (f) = data->root_window; 6113 FRAME_ROOT_WINDOW (f) = data->root_window;
6158 /* Prevent "swapping out point" in the old selected window
6159 using the buffer that has been restored into it.
6160 We already swapped out point that from that window's old buffer. */
6161 selected_window = Qnil;
6162 6114
6163 /* Arrange *not* to restore point in the buffer that was 6115 /* Arrange *not* to restore point in the buffer that was
6164 current when the window configuration was saved. */ 6116 current when the window configuration was saved. */
@@ -6167,7 +6119,11 @@ the return value is nil. Otherwise the value is t. */)
6167 make_number (old_point), 6119 make_number (old_point),
6168 XWINDOW (data->current_window)->buffer); 6120 XWINDOW (data->current_window)->buffer);
6169 6121
6170 Fselect_window (data->current_window, Qnil); 6122 /* In the following call to `select-window, prevent "swapping
6123 out point" in the old selected window using the buffer that
6124 has been restored into it. We already swapped out that point
6125 from that window's old buffer. */
6126 select_window (data->current_window, Qnil, 1);
6171 XBUFFER (XWINDOW (selected_window)->buffer)->last_selected_window 6127 XBUFFER (XWINDOW (selected_window)->buffer)->last_selected_window
6172 = selected_window; 6128 = selected_window;
6173 6129
@@ -6176,13 +6132,6 @@ the return value is nil. Otherwise the value is t. */)
6176 && FRAME_LIVE_P (XFRAME (data->focus_frame)))) 6132 && FRAME_LIVE_P (XFRAME (data->focus_frame))))
6177 Fredirect_frame_focus (frame, data->focus_frame); 6133 Fredirect_frame_focus (frame, data->focus_frame);
6178 6134
6179#if 0 /* I don't understand why this is needed, and it causes problems
6180 when the frame's old selected window has been deleted. */
6181 if (f != selected_frame && FRAME_WINDOW_P (f))
6182 do_switch_frame (WINDOW_FRAME (XWINDOW (data->root_window)),
6183 0, 0, Qnil);
6184#endif
6185
6186 /* Set the screen height to the value it had before this function. */ 6135 /* Set the screen height to the value it had before this function. */
6187 if (previous_frame_lines != FRAME_LINES (f) 6136 if (previous_frame_lines != FRAME_LINES (f)
6188 || previous_frame_cols != FRAME_COLS (f)) 6137 || previous_frame_cols != FRAME_COLS (f))
@@ -6839,8 +6788,9 @@ If PIXELS-P is non-nil, the return value is VSCROLL. */)
6839 first argument being a pointer to the leaf window, and with 6788 first argument being a pointer to the leaf window, and with
6840 additional argument USER_DATA. Stops when FN returns 0. */ 6789 additional argument USER_DATA. Stops when FN returns 0. */
6841 6790
6842void 6791static void
6843foreach_window (struct frame *f, int (*fn) (struct window *, void *), void *user_data) 6792foreach_window (struct frame *f, int (*fn) (struct window *, void *),
6793 void *user_data)
6844{ 6794{
6845 /* delete_frame may set FRAME_ROOT_WINDOW (f) to Qnil. */ 6795 /* delete_frame may set FRAME_ROOT_WINDOW (f) to Qnil. */
6846 if (WINDOWP (FRAME_ROOT_WINDOW (f))) 6796 if (WINDOWP (FRAME_ROOT_WINDOW (f)))
@@ -7104,7 +7054,7 @@ syms_of_window (void)
7104 window_scroll_preserve_hpos = -1; 7054 window_scroll_preserve_hpos = -1;
7105 window_scroll_preserve_vpos = -1; 7055 window_scroll_preserve_vpos = -1;
7106 7056
7107 DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, 7057 DEFVAR_LISP ("temp-buffer-show-function", Vtemp_buffer_show_function,
7108 doc: /* Non-nil means call as function to display a help buffer. 7058 doc: /* Non-nil means call as function to display a help buffer.
7109The function is called with one argument, the buffer to be displayed. 7059The function is called with one argument, the buffer to be displayed.
7110Used by `with-output-to-temp-buffer'. 7060Used by `with-output-to-temp-buffer'.
@@ -7112,29 +7062,29 @@ If this function is used, then it must do the entire job of showing
7112the buffer; `temp-buffer-show-hook' is not run unless this function runs it. */); 7062the buffer; `temp-buffer-show-hook' is not run unless this function runs it. */);
7113 Vtemp_buffer_show_function = Qnil; 7063 Vtemp_buffer_show_function = Qnil;
7114 7064
7115 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuf_scroll_window, 7065 DEFVAR_LISP ("minibuffer-scroll-window", Vminibuf_scroll_window,
7116 doc: /* Non-nil means it is the window that C-M-v in minibuffer should scroll. */); 7066 doc: /* Non-nil means it is the window that C-M-v in minibuffer should scroll. */);
7117 Vminibuf_scroll_window = Qnil; 7067 Vminibuf_scroll_window = Qnil;
7118 7068
7119 DEFVAR_BOOL ("mode-line-in-non-selected-windows", &mode_line_in_non_selected_windows, 7069 DEFVAR_BOOL ("mode-line-in-non-selected-windows", mode_line_in_non_selected_windows,
7120 doc: /* Non-nil means to use `mode-line-inactive' face in non-selected windows. 7070 doc: /* Non-nil means to use `mode-line-inactive' face in non-selected windows.
7121If the minibuffer is active, the `minibuffer-scroll-window' mode line 7071If the minibuffer is active, the `minibuffer-scroll-window' mode line
7122is displayed in the `mode-line' face. */); 7072is displayed in the `mode-line' face. */);
7123 mode_line_in_non_selected_windows = 1; 7073 mode_line_in_non_selected_windows = 1;
7124 7074
7125 DEFVAR_LISP ("other-window-scroll-buffer", &Vother_window_scroll_buffer, 7075 DEFVAR_LISP ("other-window-scroll-buffer", Vother_window_scroll_buffer,
7126 doc: /* If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window. */); 7076 doc: /* If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window. */);
7127 Vother_window_scroll_buffer = Qnil; 7077 Vother_window_scroll_buffer = Qnil;
7128 7078
7129 DEFVAR_BOOL ("auto-window-vscroll", &auto_window_vscroll_p, 7079 DEFVAR_BOOL ("auto-window-vscroll", auto_window_vscroll_p,
7130 doc: /* *Non-nil means to automatically adjust `window-vscroll' to view tall lines. */); 7080 doc: /* *Non-nil means to automatically adjust `window-vscroll' to view tall lines. */);
7131 auto_window_vscroll_p = 1; 7081 auto_window_vscroll_p = 1;
7132 7082
7133 DEFVAR_INT ("next-screen-context-lines", &next_screen_context_lines, 7083 DEFVAR_INT ("next-screen-context-lines", next_screen_context_lines,
7134 doc: /* *Number of lines of continuity when scrolling by screenfuls. */); 7084 doc: /* *Number of lines of continuity when scrolling by screenfuls. */);
7135 next_screen_context_lines = 2; 7085 next_screen_context_lines = 2;
7136 7086
7137 DEFVAR_INT ("window-min-height", &window_min_height, 7087 DEFVAR_INT ("window-min-height", window_min_height,
7138 doc: /* Allow deleting windows less than this tall. 7088 doc: /* Allow deleting windows less than this tall.
7139The value is measured in line units. If a window wants a modeline it 7089The value is measured in line units. If a window wants a modeline it
7140is counted as one line. 7090is counted as one line.
@@ -7143,7 +7093,7 @@ Emacs honors settings of this variable when enlarging or shrinking
7143windows vertically. A value less than 1 is invalid. */); 7093windows vertically. A value less than 1 is invalid. */);
7144 window_min_height = 4; 7094 window_min_height = 4;
7145 7095
7146 DEFVAR_INT ("window-min-width", &window_min_width, 7096 DEFVAR_INT ("window-min-width", window_min_width,
7147 doc: /* Allow deleting windows less than this wide. 7097 doc: /* Allow deleting windows less than this wide.
7148The value is measured in characters and includes any fringes or 7098The value is measured in characters and includes any fringes or
7149the scrollbar. 7099the scrollbar.
@@ -7153,7 +7103,7 @@ windows horizontally. A value less than 2 is invalid. */);
7153 window_min_width = 10; 7103 window_min_width = 10;
7154 7104
7155 DEFVAR_LISP ("scroll-preserve-screen-position", 7105 DEFVAR_LISP ("scroll-preserve-screen-position",
7156 &Vscroll_preserve_screen_position, 7106 Vscroll_preserve_screen_position,
7157 doc: /* *Controls if scroll commands move point to keep its screen position unchanged. 7107 doc: /* *Controls if scroll commands move point to keep its screen position unchanged.
7158A value of nil means point does not keep its screen position except 7108A value of nil means point does not keep its screen position except
7159at the scroll margin or window boundary respectively. 7109at the scroll margin or window boundary respectively.
@@ -7165,19 +7115,19 @@ Scroll commands should have the `scroll-command' property
7165on their symbols to be controlled by this variable. */); 7115on their symbols to be controlled by this variable. */);
7166 Vscroll_preserve_screen_position = Qnil; 7116 Vscroll_preserve_screen_position = Qnil;
7167 7117
7168 DEFVAR_LISP ("window-point-insertion-type", &Vwindow_point_insertion_type, 7118 DEFVAR_LISP ("window-point-insertion-type", Vwindow_point_insertion_type,
7169 doc: /* Type of marker to use for `window-point'. */); 7119 doc: /* Type of marker to use for `window-point'. */);
7170 Vwindow_point_insertion_type = Qnil; 7120 Vwindow_point_insertion_type = Qnil;
7171 7121
7172 DEFVAR_LISP ("window-configuration-change-hook", 7122 DEFVAR_LISP ("window-configuration-change-hook",
7173 &Vwindow_configuration_change_hook, 7123 Vwindow_configuration_change_hook,
7174 doc: /* Functions to call when window configuration changes. 7124 doc: /* Functions to call when window configuration changes.
7175The buffer-local part is run once per window, with the relevant window 7125The buffer-local part is run once per window, with the relevant window
7176selected; while the global part is run only once for the modified frame, 7126selected; while the global part is run only once for the modified frame,
7177with the relevant frame selected. */); 7127with the relevant frame selected. */);
7178 Vwindow_configuration_change_hook = Qnil; 7128 Vwindow_configuration_change_hook = Qnil;
7179 7129
7180 DEFVAR_LISP ("recenter-redisplay", &Vrecenter_redisplay, 7130 DEFVAR_LISP ("recenter-redisplay", Vrecenter_redisplay,
7181 doc: /* If non-nil, then the `recenter' command with a nil argument 7131 doc: /* If non-nil, then the `recenter' command with a nil argument
7182will redraw the entire frame; the special value `tty' causes the 7132will redraw the entire frame; the special value `tty' causes the
7183frame to be redrawn only if it is a tty frame. */); 7133frame to be redrawn only if it is a tty frame. */);
@@ -7220,6 +7170,7 @@ frame to be redrawn only if it is a tty frame. */);
7220 defsubr (&Sprevious_window); 7170 defsubr (&Sprevious_window);
7221 defsubr (&Sother_window); 7171 defsubr (&Sother_window);
7222 defsubr (&Sget_lru_window); 7172 defsubr (&Sget_lru_window);
7173 defsubr (&Swindow_use_time);
7223 defsubr (&Sget_largest_window); 7174 defsubr (&Sget_largest_window);
7224 defsubr (&Sget_buffer_window); 7175 defsubr (&Sget_buffer_window);
7225 defsubr (&Sdelete_other_windows); 7176 defsubr (&Sdelete_other_windows);
@@ -7281,5 +7232,3 @@ keys_of_window (void)
7281 initial_define_key (meta_map, 'v', "scroll-down-command"); 7232 initial_define_key (meta_map, 'v', "scroll-down-command");
7282} 7233}
7283 7234
7284/* arch-tag: 90a9c576-0590-48f1-a5f1-6c96a0452d9f
7285 (do not change this comment) */