aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorGerd Moellmann2000-07-21 14:34:08 +0000
committerGerd Moellmann2000-07-21 14:34:08 +0000
commitf95464e4700cd32aa4cf1de188f3951b7a006451 (patch)
treef3b92f72276ba28fe9835d2364f7ac9cac3a083d /src/window.c
parentf5588a407c60a6cdff1a6ba7262ba094a5e9ad49 (diff)
downloademacs-f95464e4700cd32aa4cf1de188f3951b7a006451.tar.gz
emacs-f95464e4700cd32aa4cf1de188f3951b7a006451.zip
(foreach_window): Instead of a fake variable argument
list, take one USER_DATA argument. (foreach_window_1): Likewise, and call callback functions with two args, the window and USER_DATA. (struct check_window_data): New struct. (check_window_containing): Use it. (window_from_coordinates): Set up a struct check_window_data for foreach_window. (add_window_to_list, freeze_window_start): Change parameters according to new calling convention.
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c91
1 files changed, 50 insertions, 41 deletions
diff --git a/src/window.c b/src/window.c
index d6eb2e06a0c..ef4ea78c138 100644
--- a/src/window.c
+++ b/src/window.c
@@ -62,21 +62,20 @@ static void window_scroll_line_based P_ ((Lisp_Object, int, int, int));
62static int window_min_size_1 P_ ((struct window *, int)); 62static int window_min_size_1 P_ ((struct window *, int));
63static int window_min_size P_ ((struct window *, int, int, int *)); 63static int window_min_size P_ ((struct window *, int, int, int *));
64static void size_window P_ ((Lisp_Object, int, int, int)); 64static void size_window P_ ((Lisp_Object, int, int, int));
65static int foreach_window_1 P_ ((struct window *, int (*fn) (), int, int, 65static int freeze_window_start P_ ((struct window *, void *));
66 int, int, int, int, int, int, int));
67static int freeze_window_start P_ ((struct window *, int));
68static int window_fixed_size_p P_ ((struct window *, int, int)); 66static int window_fixed_size_p P_ ((struct window *, int, int));
69static void enlarge_window P_ ((Lisp_Object, int, int)); 67static void enlarge_window P_ ((Lisp_Object, int, int));
70static Lisp_Object window_list P_ ((void)); 68static Lisp_Object window_list P_ ((void));
71static int add_window_to_list P_ ((struct window *, Lisp_Object *)); 69static int add_window_to_list P_ ((struct window *, void *));
72static int candidate_window_p P_ ((Lisp_Object, Lisp_Object, Lisp_Object, 70static int candidate_window_p P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
73 Lisp_Object)); 71 Lisp_Object));
74static Lisp_Object next_window P_ ((Lisp_Object, Lisp_Object, 72static Lisp_Object next_window P_ ((Lisp_Object, Lisp_Object,
75 Lisp_Object, int)); 73 Lisp_Object, int));
76static void decode_next_window_args P_ ((Lisp_Object *, Lisp_Object *, 74static void decode_next_window_args P_ ((Lisp_Object *, Lisp_Object *,
77 Lisp_Object *)); 75 Lisp_Object *));
78 76static int foreach_window_1 P_ ((struct window *,
79 77 int (* fn) (struct window *, void *),
78 void *));
80 79
81/* This is the window in which the terminal's cursor should 80/* This is the window in which the terminal's cursor should
82 be left when nothing is being done with it. This must 81 be left when nothing is being done with it. This must
@@ -605,24 +604,33 @@ If they are on the border between WINDOW and its right sibling,\n\
605 604
606 605
607/* Callback for foreach_window, used in window_from_coordinates. 606/* Callback for foreach_window, used in window_from_coordinates.
608 Check if window W contains coordinates *X/*Y. If it does, return W 607 Check if window W contains coordinates specified by USER_DATA which
609 in *WINDOW, as Lisp_Object, and return in *PART the part of the 608 is actually a pointer to a struct check_window_data CW.
610 window under coordinates *X/*Y. Return zero from this function to 609
611 stop iterating over windows. */ 610 Check if window W contains coordinates *CW->x and *CW->y. If it
611 does, return W in *CW->window, as Lisp_Object, and return in
612 *CW->part the part of the window under coordinates *X/*Y. Return
613 zero from this function to stop iterating over windows. */
614
615struct check_window_data
616{
617 Lisp_Object *window;
618 int *x, *y, *part;
619};
612 620
613static int 621static int
614check_window_containing (w, window, x, y, part) 622check_window_containing (w, user_data)
615 struct window *w; 623 struct window *w;
616 Lisp_Object *window; 624 void *user_data;
617 int *x, *y, *part;
618{ 625{
626 struct check_window_data *cw = (struct check_window_data *) user_data;
619 int found; 627 int found;
620 628
621 found = coordinates_in_window (w, x, y); 629 found = coordinates_in_window (w, cw->x, cw->y);
622 if (found) 630 if (found)
623 { 631 {
624 *part = found - 1; 632 *cw->part = found - 1;
625 XSETWINDOW (*window, w); 633 XSETWINDOW (*cw->window, w);
626 } 634 }
627 635
628 return !found; 636 return !found;
@@ -653,9 +661,11 @@ window_from_coordinates (f, x, y, part, tool_bar_p)
653 int tool_bar_p; 661 int tool_bar_p;
654{ 662{
655 Lisp_Object window; 663 Lisp_Object window;
664 struct check_window_data cw;
656 665
657 window = Qnil; 666 window = Qnil;
658 foreach_window (f, check_window_containing, &window, &x, &y, part); 667 cw.window = &window, cw.x = &x, cw.y = &y; cw.part = part;
668 foreach_window (f, check_window_containing, &cw);
659 669
660 /* If not found above, see if it's in the tool bar window, if a tool 670 /* If not found above, see if it's in the tool bar window, if a tool
661 bar exists. */ 671 bar exists. */
@@ -1181,14 +1191,16 @@ delete_window (window)
1181 Window List 1191 Window List
1182 ***********************************************************************/ 1192 ***********************************************************************/
1183 1193
1184/* Add window W to *LIST. This is a callback function for 1194/* Add window W to *USER_DATA. USER_DATA is actually a Lisp_Object
1185 foreach_window, used in function window_list. */ 1195 pointer. This is a callback function for foreach_window, used in
1196 function window_list. */
1186 1197
1187static int 1198static int
1188add_window_to_list (w, list) 1199add_window_to_list (w, user_data)
1189 struct window *w; 1200 struct window *w;
1190 Lisp_Object *list; 1201 void *user_data;
1191{ 1202{
1203 Lisp_Object *list = (Lisp_Object *) user_data;
1192 Lisp_Object window; 1204 Lisp_Object window;
1193 XSETWINDOW (window, w); 1205 XSETWINDOW (window, w);
1194 *list = Fcons (window, *list); 1206 *list = Fcons (window, *list);
@@ -5079,41 +5091,38 @@ non-negative multiple of the canonical character height of WINDOW.")
5079 5091
5080/* Call FN for all leaf windows on frame F. FN is called with the 5092/* Call FN for all leaf windows on frame F. FN is called with the
5081 first argument being a pointer to the leaf window, and with 5093 first argument being a pointer to the leaf window, and with
5082 additional arguments A1..A9. Stops when FN returns 0. */ 5094 additional argument USER_DATA. Stops when FN returns 0. */
5083 5095
5084void 5096void
5085foreach_window (f, fn, a1, a2, a3, a4, a5, a6, a7, a8, a9) 5097foreach_window (f, fn, user_data)
5086 struct frame *f; 5098 struct frame *f;
5087 int (* fn) (); 5099 int (* fn) P_ ((struct window *, void *));
5088 int a1, a2, a3, a4, a5, a6, a7, a8, a9; 5100 void *user_data;
5089{ 5101{
5090 foreach_window_1 (XWINDOW (FRAME_ROOT_WINDOW (f)), 5102 foreach_window_1 (XWINDOW (FRAME_ROOT_WINDOW (f)), fn, user_data);
5091 fn, a1, a2, a3, a4, a5, a6, a7, a8, a9);
5092} 5103}
5093 5104
5094 5105
5095/* Helper function for foreach_window. Call FN for all leaf windows 5106/* Helper function for foreach_window. Call FN for all leaf windows
5096 reachable from W. FN is called with the first argument being a 5107 reachable from W. FN is called with the first argument being a
5097 pointer to the leaf window, and with additional arguments A1..A9. 5108 pointer to the leaf window, and with additional argument USER_DATA.
5098 Stop when FN returns 0. Value is 0 if stopped by FN. */ 5109 Stop when FN returns 0. Value is 0 if stopped by FN. */
5099 5110
5100static int 5111static int
5101foreach_window_1 (w, fn, a1, a2, a3, a4, a5, a6, a7, a8, a9) 5112foreach_window_1 (w, fn, user_data)
5102 struct window *w; 5113 struct window *w;
5103 int (* fn) (); 5114 int (* fn) P_ ((struct window *, void *));
5104 int a1, a2, a3, a4, a5, a6, a7, a8, a9; 5115 void *user_data;
5105{ 5116{
5106 int cont; 5117 int cont;
5107 5118
5108 for (cont = 1; w && cont;) 5119 for (cont = 1; w && cont;)
5109 { 5120 {
5110 if (!NILP (w->hchild)) 5121 if (!NILP (w->hchild))
5111 cont = foreach_window_1 (XWINDOW (w->hchild), 5122 cont = foreach_window_1 (XWINDOW (w->hchild), fn, user_data);
5112 fn, a1, a2, a3, a4, a5, a6, a7, a8, a9);
5113 else if (!NILP (w->vchild)) 5123 else if (!NILP (w->vchild))
5114 cont = foreach_window_1 (XWINDOW (w->vchild), 5124 cont = foreach_window_1 (XWINDOW (w->vchild), fn, user_data);
5115 fn, a1, a2, a3, a4, a5, a6, a7, a8, a9); 5125 else if (fn (w, user_data))
5116 else if (fn (w, a1, a2, a3, a4, a5, a6, a7, a8, a9) == 0)
5117 cont = 0; 5126 cont = 0;
5118 5127
5119 w = NILP (w->next) ? 0 : XWINDOW (w->next); 5128 w = NILP (w->next) ? 0 : XWINDOW (w->next);
@@ -5124,22 +5133,22 @@ foreach_window_1 (w, fn, a1, a2, a3, a4, a5, a6, a7, a8, a9)
5124 5133
5125 5134
5126/* Freeze or unfreeze the window start of W if unless it is a 5135/* Freeze or unfreeze the window start of W if unless it is a
5127 mini-window or the selected window. FREEZE_P non-zero means freeze 5136 mini-window or the selected window. FREEZE_P non-null means freeze
5128 the window start. */ 5137 the window start. */
5129 5138
5130static int 5139static int
5131freeze_window_start (w, freeze_p) 5140freeze_window_start (w, freeze_p)
5132 struct window *w; 5141 struct window *w;
5133 int freeze_p; 5142 void *freeze_p;
5134{ 5143{
5135 if (w == XWINDOW (selected_window) 5144 if (w == XWINDOW (selected_window)
5136 || MINI_WINDOW_P (w) 5145 || MINI_WINDOW_P (w)
5137 || (MINI_WINDOW_P (XWINDOW (selected_window)) 5146 || (MINI_WINDOW_P (XWINDOW (selected_window))
5138 && ! NILP (Vminibuf_scroll_window) 5147 && ! NILP (Vminibuf_scroll_window)
5139 && w == XWINDOW (Vminibuf_scroll_window))) 5148 && w == XWINDOW (Vminibuf_scroll_window)))
5140 freeze_p = 0; 5149 freeze_p = NULL;
5141 5150
5142 w->frozen_window_start_p = freeze_p; 5151 w->frozen_window_start_p = freeze_p != NULL;
5143 return 1; 5152 return 1;
5144} 5153}
5145 5154
@@ -5153,7 +5162,7 @@ freeze_window_starts (f, freeze_p)
5153 struct frame *f; 5162 struct frame *f;
5154 int freeze_p; 5163 int freeze_p;
5155{ 5164{
5156 foreach_window (f, freeze_window_start, freeze_p); 5165 foreach_window (f, freeze_window_start, (void *) freeze_p);
5157} 5166}
5158 5167
5159 5168