Commit f95464e4 authored by Gerd Moellmann's avatar Gerd Moellmann

(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.
parent f5588a40
...@@ -62,21 +62,20 @@ static void window_scroll_line_based P_ ((Lisp_Object, int, int, int)); ...@@ -62,21 +62,20 @@ static void window_scroll_line_based P_ ((Lisp_Object, int, int, int));
static int window_min_size_1 P_ ((struct window *, int)); static int window_min_size_1 P_ ((struct window *, int));
static int window_min_size P_ ((struct window *, int, int, int *)); static int window_min_size P_ ((struct window *, int, int, int *));
static void size_window P_ ((Lisp_Object, int, int, int)); static void size_window P_ ((Lisp_Object, int, int, int));
static int foreach_window_1 P_ ((struct window *, int (*fn) (), int, int, static int freeze_window_start P_ ((struct window *, void *));
int, int, int, int, int, int, int));
static int freeze_window_start P_ ((struct window *, int));
static int window_fixed_size_p P_ ((struct window *, int, int)); static int window_fixed_size_p P_ ((struct window *, int, int));
static void enlarge_window P_ ((Lisp_Object, int, int)); static void enlarge_window P_ ((Lisp_Object, int, int));
static Lisp_Object window_list P_ ((void)); static Lisp_Object window_list P_ ((void));
static int add_window_to_list P_ ((struct window *, Lisp_Object *)); static int add_window_to_list P_ ((struct window *, void *));
static int candidate_window_p P_ ((Lisp_Object, Lisp_Object, Lisp_Object, static int candidate_window_p P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
Lisp_Object)); Lisp_Object));
static Lisp_Object next_window P_ ((Lisp_Object, Lisp_Object, static Lisp_Object next_window P_ ((Lisp_Object, Lisp_Object,
Lisp_Object, int)); Lisp_Object, int));
static void decode_next_window_args P_ ((Lisp_Object *, Lisp_Object *, static void decode_next_window_args P_ ((Lisp_Object *, Lisp_Object *,
Lisp_Object *)); Lisp_Object *));
static int foreach_window_1 P_ ((struct window *,
int (* fn) (struct window *, void *),
void *));
/* This is the window in which the terminal's cursor should /* This is the window in which the terminal's cursor should
be left when nothing is being done with it. This must 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,24 +604,33 @@ If they are on the border between WINDOW and its right sibling,\n\
/* Callback for foreach_window, used in window_from_coordinates. /* Callback for foreach_window, used in window_from_coordinates.
Check if window W contains coordinates *X/*Y. If it does, return W Check if window W contains coordinates specified by USER_DATA which
in *WINDOW, as Lisp_Object, and return in *PART the part of the is actually a pointer to a struct check_window_data CW.
window under coordinates *X/*Y. Return zero from this function to
stop iterating over windows. */ Check if window W contains coordinates *CW->x and *CW->y. If it
does, return W in *CW->window, as Lisp_Object, and return in
*CW->part the part of the window under coordinates *X/*Y. Return
zero from this function to stop iterating over windows. */
struct check_window_data
{
Lisp_Object *window;
int *x, *y, *part;
};
static int static int
check_window_containing (w, window, x, y, part) check_window_containing (w, user_data)
struct window *w; struct window *w;
Lisp_Object *window; void *user_data;
int *x, *y, *part;
{ {
struct check_window_data *cw = (struct check_window_data *) user_data;
int found; int found;
found = coordinates_in_window (w, x, y); found = coordinates_in_window (w, cw->x, cw->y);
if (found) if (found)
{ {
*part = found - 1; *cw->part = found - 1;
XSETWINDOW (*window, w); XSETWINDOW (*cw->window, w);
} }
return !found; return !found;
...@@ -653,9 +661,11 @@ window_from_coordinates (f, x, y, part, tool_bar_p) ...@@ -653,9 +661,11 @@ window_from_coordinates (f, x, y, part, tool_bar_p)
int tool_bar_p; int tool_bar_p;
{ {
Lisp_Object window; Lisp_Object window;
struct check_window_data cw;
window = Qnil; window = Qnil;
foreach_window (f, check_window_containing, &window, &x, &y, part); cw.window = &window, cw.x = &x, cw.y = &y; cw.part = part;
foreach_window (f, check_window_containing, &cw);
/* If not found above, see if it's in the tool bar window, if a tool /* If not found above, see if it's in the tool bar window, if a tool
bar exists. */ bar exists. */
...@@ -1181,14 +1191,16 @@ delete_window (window) ...@@ -1181,14 +1191,16 @@ delete_window (window)
Window List Window List
***********************************************************************/ ***********************************************************************/
/* Add window W to *LIST. This is a callback function for /* Add window W to *USER_DATA. USER_DATA is actually a Lisp_Object
foreach_window, used in function window_list. */ pointer. This is a callback function for foreach_window, used in
function window_list. */
static int static int
add_window_to_list (w, list) add_window_to_list (w, user_data)
struct window *w; struct window *w;
Lisp_Object *list; void *user_data;
{ {
Lisp_Object *list = (Lisp_Object *) user_data;
Lisp_Object window; Lisp_Object window;
XSETWINDOW (window, w); XSETWINDOW (window, w);
*list = Fcons (window, *list); *list = Fcons (window, *list);
...@@ -5079,41 +5091,38 @@ non-negative multiple of the canonical character height of WINDOW.") ...@@ -5079,41 +5091,38 @@ non-negative multiple of the canonical character height of WINDOW.")
/* Call FN for all leaf windows on frame F. FN is called with the /* Call FN for all leaf windows on frame F. FN is called with the
first argument being a pointer to the leaf window, and with first argument being a pointer to the leaf window, and with
additional arguments A1..A9. Stops when FN returns 0. */ additional argument USER_DATA. Stops when FN returns 0. */
void void
foreach_window (f, fn, a1, a2, a3, a4, a5, a6, a7, a8, a9) foreach_window (f, fn, user_data)
struct frame *f; struct frame *f;
int (* fn) (); int (* fn) P_ ((struct window *, void *));
int a1, a2, a3, a4, a5, a6, a7, a8, a9; void *user_data;
{ {
foreach_window_1 (XWINDOW (FRAME_ROOT_WINDOW (f)), foreach_window_1 (XWINDOW (FRAME_ROOT_WINDOW (f)), fn, user_data);
fn, a1, a2, a3, a4, a5, a6, a7, a8, a9);
} }
/* Helper function for foreach_window. Call FN for all leaf windows /* Helper function for foreach_window. Call FN for all leaf windows
reachable from W. FN is called with the first argument being a reachable from W. FN is called with the first argument being a
pointer to the leaf window, and with additional arguments A1..A9. pointer to the leaf window, and with additional argument USER_DATA.
Stop when FN returns 0. Value is 0 if stopped by FN. */ Stop when FN returns 0. Value is 0 if stopped by FN. */
static int static int
foreach_window_1 (w, fn, a1, a2, a3, a4, a5, a6, a7, a8, a9) foreach_window_1 (w, fn, user_data)
struct window *w; struct window *w;
int (* fn) (); int (* fn) P_ ((struct window *, void *));
int a1, a2, a3, a4, a5, a6, a7, a8, a9; void *user_data;
{ {
int cont; int cont;
for (cont = 1; w && cont;) for (cont = 1; w && cont;)
{ {
if (!NILP (w->hchild)) if (!NILP (w->hchild))
cont = foreach_window_1 (XWINDOW (w->hchild), cont = foreach_window_1 (XWINDOW (w->hchild), fn, user_data);
fn, a1, a2, a3, a4, a5, a6, a7, a8, a9);
else if (!NILP (w->vchild)) else if (!NILP (w->vchild))
cont = foreach_window_1 (XWINDOW (w->vchild), cont = foreach_window_1 (XWINDOW (w->vchild), fn, user_data);
fn, a1, a2, a3, a4, a5, a6, a7, a8, a9); else if (fn (w, user_data))
else if (fn (w, a1, a2, a3, a4, a5, a6, a7, a8, a9) == 0)
cont = 0; cont = 0;
w = NILP (w->next) ? 0 : XWINDOW (w->next); 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,22 +5133,22 @@ foreach_window_1 (w, fn, a1, a2, a3, a4, a5, a6, a7, a8, a9)
/* Freeze or unfreeze the window start of W if unless it is a /* Freeze or unfreeze the window start of W if unless it is a
mini-window or the selected window. FREEZE_P non-zero means freeze mini-window or the selected window. FREEZE_P non-null means freeze
the window start. */ the window start. */
static int static int
freeze_window_start (w, freeze_p) freeze_window_start (w, freeze_p)
struct window *w; struct window *w;
int freeze_p; void *freeze_p;
{ {
if (w == XWINDOW (selected_window) if (w == XWINDOW (selected_window)
|| MINI_WINDOW_P (w) || MINI_WINDOW_P (w)
|| (MINI_WINDOW_P (XWINDOW (selected_window)) || (MINI_WINDOW_P (XWINDOW (selected_window))
&& ! NILP (Vminibuf_scroll_window) && ! NILP (Vminibuf_scroll_window)
&& w == XWINDOW (Vminibuf_scroll_window))) && w == XWINDOW (Vminibuf_scroll_window)))
freeze_p = 0; freeze_p = NULL;
w->frozen_window_start_p = freeze_p; w->frozen_window_start_p = freeze_p != NULL;
return 1; return 1;
} }
...@@ -5153,7 +5162,7 @@ freeze_window_starts (f, freeze_p) ...@@ -5153,7 +5162,7 @@ freeze_window_starts (f, freeze_p)
struct frame *f; struct frame *f;
int freeze_p; int freeze_p;
{ {
foreach_window (f, freeze_window_start, freeze_p); foreach_window (f, freeze_window_start, (void *) freeze_p);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment