comparison src/window.c @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents 966663fcf606
children ca9a9ec9c1c1
comparison
equal deleted inserted replaced
271:c7b7086b0a39 272:c5d627a313b1
36 #include "glyphs.h" 36 #include "glyphs.h"
37 #include "redisplay.h" 37 #include "redisplay.h"
38 #include "window.h" 38 #include "window.h"
39 #include "commands.h" 39 #include "commands.h"
40 40
41 Lisp_Object Qwindowp, Qwindow_live_p; 41 Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configurationp;
42 Lisp_Object Qwindow_configurationp; 42 Lisp_Object Qscroll_up, Qscroll_down, Qdisplay_buffer;
43 Lisp_Object Qscroll_up;
44 Lisp_Object Qscroll_down;
45 Lisp_Object Qdisplay_buffer;
46 43
47 #ifdef MEMORY_USAGE_STATS 44 #ifdef MEMORY_USAGE_STATS
48 Lisp_Object Qface_cache; 45 Lisp_Object Qface_cache, Qglyph_cache, Qline_start_cache, Qother_redisplay;
49 Lisp_Object Qglyph_cache;
50 Lisp_Object Qline_start_cache;
51 #ifdef HAVE_SCROLLBARS 46 #ifdef HAVE_SCROLLBARS
52 Lisp_Object Qscrollbar_instances; 47 Lisp_Object Qscrollbar_instances;
53 #endif 48 #endif
54 Lisp_Object Qother_redisplay;
55 #endif 49 #endif
50
51 EXFUN (Fnext_window, 4);
56 52
57 static int window_pixel_width_to_char_width (struct window *w, 53 static int window_pixel_width_to_char_width (struct window *w,
58 int pixel_width, 54 int pixel_width,
59 int include_margins_p); 55 int include_margins_p);
60 static int window_char_width_to_pixel_width (struct window *w, 56 static int window_char_width_to_pixel_width (struct window *w,
68 int include_gutters_p); 64 int include_gutters_p);
69 static void change_window_height (struct window *w, int delta, int widthflag, 65 static void change_window_height (struct window *w, int delta, int widthflag,
70 int inpixels); 66 int inpixels);
71 static int window_displayed_pixel_height (struct window *); 67 static int window_displayed_pixel_height (struct window *);
72 68
73
74 /* Thickness of shadow border around 3d modelines. */ 69 /* Thickness of shadow border around 3d modelines. */
75 Lisp_Object Vmodeline_shadow_thickness; 70 Lisp_Object Vmodeline_shadow_thickness;
76 71
77 /* Whether a modeline should be displayed. */ 72 /* Whether a modeline should be displayed. */
78 Lisp_Object Vhas_modeline_p; 73 Lisp_Object Vhas_modeline_p;
127 (w)->last_facechange[DESIRED_DISP] = Qzero; \ 122 (w)->last_facechange[DESIRED_DISP] = Qzero; \
128 (w)->last_facechange[CMOTION_DISP] = Qzero; \ 123 (w)->last_facechange[CMOTION_DISP] = Qzero; \
129 } while (0) 124 } while (0)
130 125
131 126
132 static Lisp_Object mark_window (Lisp_Object, void (*) (Lisp_Object));
133 static void print_window (Lisp_Object, Lisp_Object, int);
134 static void finalize_window (void *header, int for_disksave);
135 DEFINE_LRECORD_IMPLEMENTATION ("window", window,
136 mark_window, print_window, finalize_window,
137 0, 0, struct window);
138
139 #define MARK_DISP_VARIABLE(field) \ 127 #define MARK_DISP_VARIABLE(field) \
140 ((markobj) (window->field[CURRENT_DISP])); \ 128 ((markobj) (window->field[CURRENT_DISP])); \
141 ((markobj) (window->field[DESIRED_DISP])); \ 129 ((markobj) (window->field[DESIRED_DISP])); \
142 ((markobj) (window->field[CMOTION_DISP])); 130 ((markobj) (window->field[CMOTION_DISP]));
143 131
261 Dynarr_free (w->glyph_cachels); 249 Dynarr_free (w->glyph_cachels);
262 w->glyph_cachels = 0; 250 w->glyph_cachels = 0;
263 } 251 }
264 } 252 }
265 253
254 DEFINE_LRECORD_IMPLEMENTATION ("window", window,
255 mark_window, print_window, finalize_window,
256 0, 0, struct window);
257
258
266 #define INIT_DISP_VARIABLE(field, initialization) \ 259 #define INIT_DISP_VARIABLE(field, initialization) \
267 p->field[CURRENT_DISP] = initialization; \ 260 p->field[CURRENT_DISP] = initialization; \
268 p->field[DESIRED_DISP] = initialization; \ 261 p->field[DESIRED_DISP] = initialization; \
269 p->field[CMOTION_DISP] = initialization; 262 p->field[CMOTION_DISP] = initialization;
270 263
278 here because the window must have its frame pointer set or 271 here because the window must have its frame pointer set or
279 reset_face_cachels will fail. */ 272 reset_face_cachels will fail. */
280 Lisp_Object 273 Lisp_Object
281 allocate_window (void) 274 allocate_window (void)
282 { 275 {
283 Lisp_Object val = Qnil; 276 Lisp_Object val;
284 struct window *p = alloc_lcrecord_type (struct window, lrecord_window); 277 struct window *p = alloc_lcrecord_type (struct window, lrecord_window);
285 278
286 zero_lcrecord (p); 279 zero_lcrecord (p);
287 XSETWINDOW (val, p); 280 XSETWINDOW (val, p);
288 281
324 #ifdef HAVE_TOOLBARS 317 #ifdef HAVE_TOOLBARS
325 p->toolbar_size[0] = Qnil; 318 p->toolbar_size[0] = Qnil;
326 p->toolbar_size[1] = Qnil; 319 p->toolbar_size[1] = Qnil;
327 p->toolbar_size[2] = Qnil; 320 p->toolbar_size[2] = Qnil;
328 p->toolbar_size[3] = Qnil; 321 p->toolbar_size[3] = Qnil;
322 p->toolbar_buttons_captioned_p = Qnil;
329 #endif 323 #endif
330 p->minimum_line_ascent = Qnil; 324 p->minimum_line_ascent = Qnil;
331 p->minimum_line_descent = Qnil; 325 p->minimum_line_descent = Qnil;
332 p->use_left_overflow = Qnil; 326 p->use_left_overflow = Qnil;
333 p->use_right_overflow = Qnil; 327 p->use_right_overflow = Qnil;
334 #ifdef HAVE_MENUBARS 328 #ifdef HAVE_MENUBARS
335 p->menubar_visible_p = Qnil; 329 p->menubar_visible_p = Qnil;
336 #endif
337 #ifdef HAVE_TOOLBARS
338 p->toolbar_buttons_captioned_p = Qnil;
339 #endif 330 #endif
340 p->text_cursor_visible_p = Qnil; 331 p->text_cursor_visible_p = Qnil;
341 /* end cached specifier values. */ 332 /* end cached specifier values. */
342 333
343 p->dedicated = Qnil; 334 p->dedicated = Qnil;
397 if (NILP (win)) 388 if (NILP (win))
398 { 389 {
399 if (mir) 390 if (mir)
400 { 391 {
401 free_window_mirror (mir); 392 free_window_mirror (mir);
402 mir = 0; 393 mir = NULL;
403 } 394 }
404 return mir; 395 return mir;
405 } 396 }
406 else 397 else
407 if (!mir) 398 if (!mir)
472 redisplay structures. */ 463 redisplay structures. */
473 static struct window_mirror * 464 static struct window_mirror *
474 find_window_mirror_internal (Lisp_Object win, struct window_mirror *rmir, 465 find_window_mirror_internal (Lisp_Object win, struct window_mirror *rmir,
475 struct window *w) 466 struct window *w)
476 { 467 {
477 struct window_mirror *retval;
478
479 for (; !NILP (win); win = XWINDOW (win)->next, rmir = rmir->next) 468 for (; !NILP (win); win = XWINDOW (win)->next, rmir = rmir->next)
480 { 469 {
481 if (w == XWINDOW (win)) 470 if (w == XWINDOW (win))
482 return rmir; 471 return rmir;
483 if (!NILP (XWINDOW (win)->vchild) && 472
484 (retval = find_window_mirror_internal (XWINDOW (win)->vchild, 473 if (!NILP (XWINDOW (win)->vchild))
485 rmir->vchild, w))) 474 {
486 return retval; 475 struct window_mirror *retval =
487 if (!NILP (XWINDOW (win)->hchild) && 476 find_window_mirror_internal (XWINDOW (win)->vchild,
488 (retval = find_window_mirror_internal (XWINDOW (win)->hchild, 477 rmir->vchild, w);
489 rmir->hchild, w))) 478 if (retval) return retval;
490 return retval; 479 }
480
481 if (!NILP (XWINDOW (win)->hchild))
482 {
483 struct window_mirror *retval =
484 find_window_mirror_internal (XWINDOW (win)->hchild,
485 rmir->hchild, w);
486 if (retval) return retval;
487 }
491 } 488 }
492 489
493 return 0; 490 return 0;
494 } 491 }
495 492
504 /* Free a given mirror structure along with all of its children as 501 /* Free a given mirror structure along with all of its children as
505 well as their associated display structures. */ 502 well as their associated display structures. */
506 void 503 void
507 free_window_mirror (struct window_mirror *mir) 504 free_window_mirror (struct window_mirror *mir)
508 { 505 {
509 struct window_mirror *p;
510
511 p = mir;
512 while (mir) 506 while (mir)
513 { 507 {
508 struct window_mirror *prev = mir;
514 if (mir->hchild) free_window_mirror (mir->hchild); 509 if (mir->hchild) free_window_mirror (mir->hchild);
515 if (mir->vchild) free_window_mirror (mir->vchild); 510 if (mir->vchild) free_window_mirror (mir->vchild);
516 #ifdef HAVE_SCROLLBARS 511 #ifdef HAVE_SCROLLBARS
517 release_window_mirror_scrollbars (mir); 512 release_window_mirror_scrollbars (mir);
518 #endif 513 #endif
519 free_display_structs (mir); 514 free_display_structs (mir);
520 mir = mir->next; 515 mir = mir->next;
521 xfree (p); 516 xfree (prev);
522 p = mir;
523 } 517 }
524 } 518 }
525 519
526 /* Given a mirror structure, return the window it mirrors. Calls 520 /* Given a mirror structure, return the window it mirrors. Calls
527 real_window_internal to do most of the work. */ 521 real_window_internal to do most of the work. */
528 Lisp_Object 522 Lisp_Object
529 real_window (struct window_mirror *mir, int no_abort) 523 real_window (struct window_mirror *mir, int no_abort)
530 { 524 {
531 Lisp_Object retval; 525 Lisp_Object retval = real_window_internal (mir->frame->root_window,
532 526 mir->frame->root_mirror, mir);
533 retval = real_window_internal (mir->frame->root_window,
534 mir->frame->root_mirror, mir);
535
536 if (NILP (retval) && !no_abort) 527 if (NILP (retval) && !no_abort)
537 abort (); 528 abort ();
538 529
539 return retval; 530 return retval;
540 } 531 }
555 546
556 Given a pixel position relative to a frame, find the window at that 547 Given a pixel position relative to a frame, find the window at that
557 position. 548 position.
558 ****************************************************************************/ 549 ****************************************************************************/
559 struct window * 550 struct window *
560 find_window_by_pixel_pos (unsigned int pix_x, unsigned int pix_y, 551 find_window_by_pixel_pos (int pix_x, int pix_y, Lisp_Object win)
561 Lisp_Object win) 552 {
562 {
563 struct window *w;
564
565 if (NILP (win)) 553 if (NILP (win))
566 return 0; 554 return 0;
567 555
568 for (; !NILP (win); win = XWINDOW (win)->next) 556 for (; !NILP (win); win = XWINDOW (win)->next)
569 { 557 {
570 if (!NILP (XWINDOW (win)->vchild) && 558 struct window *w;
571 (w = find_window_by_pixel_pos (pix_x, pix_y, XWINDOW (win)->vchild))) 559
572 return w; 560 if (!NILP (XWINDOW (win)->vchild))
573 if (!NILP (XWINDOW (win)->hchild) && 561 {
574 (w = find_window_by_pixel_pos (pix_x, pix_y, XWINDOW (win)->hchild))) 562 w = find_window_by_pixel_pos (pix_x, pix_y, XWINDOW (win)->vchild);
575 return w; 563 if (w) return w;
564 }
565 if (!NILP (XWINDOW (win)->hchild))
566 {
567 w = find_window_by_pixel_pos (pix_x, pix_y, XWINDOW (win)->hchild);
568 if (w) return w;
569 }
576 w = XWINDOW (win); 570 w = XWINDOW (win);
577 if (pix_x >= WINDOW_LEFT (w) 571 if (pix_x >= WINDOW_LEFT (w)
578 && pix_x <= WINDOW_RIGHT (w) 572 && pix_x <= WINDOW_RIGHT (w)
579 && pix_y >= WINDOW_TOP (w) 573 && pix_y >= WINDOW_TOP (w)
580 && pix_y <= WINDOW_BOTTOM (w)) 574 && pix_y <= WINDOW_BOTTOM (w))
581 return w; 575 return w;
582 } 576 }
583 return 0; 577 return NULL;
584 } 578 }
585 579
586 /* Return a pointer to the display structures for the given window. */ 580 /* Return a pointer to the display structures for the given window. */
587 display_line_dynarr * 581 display_line_dynarr *
588 window_display_lines (struct window *w, int which) 582 window_display_lines (struct window *w, int which)
902 { 896 {
903 struct buffer *b; 897 struct buffer *b;
904 int window_cwidth = window_char_width (w, 1); 898 int window_cwidth = window_char_width (w, 1);
905 int margin_cwidth; 899 int margin_cwidth;
906 int font_width; 900 int font_width;
907 Lisp_Object window = Qnil; 901 Lisp_Object window;
908 902
909 /* We might be getting called on a non-leaf. */ 903 /* We might be getting called on a non-leaf. */
910 if (NILP (w->buffer)) 904 if (NILP (w->buffer))
911 return 0; 905 return 0;
912 906
1123 is a console, the selected frame on that console's selected device will 1117 is a console, the selected frame on that console's selected device will
1124 be used. Otherwise, the selected frame is used. 1118 be used. Otherwise, the selected frame is used.
1125 */ 1119 */
1126 (con_dev_or_frame)) 1120 (con_dev_or_frame))
1127 { 1121 {
1128 struct frame *f;
1129
1130 if (NILP (con_dev_or_frame) && NILP (Fselected_device (Qnil))) 1122 if (NILP (con_dev_or_frame) && NILP (Fselected_device (Qnil)))
1131 return Qnil; /* happens at startup */ 1123 return Qnil; /* happens at startup */
1132 1124
1133 f = decode_frame_or_selected (con_dev_or_frame); 1125 {
1134 return FRAME_SELECTED_WINDOW (f); 1126 struct frame *f = decode_frame_or_selected (con_dev_or_frame);
1127 return FRAME_SELECTED_WINDOW (f);
1128 }
1135 } 1129 }
1136 1130
1137 DEFUN ("minibuffer-window", Fminibuffer_window, 0, 1, 0, /* 1131 DEFUN ("minibuffer-window", Fminibuffer_window, 0, 1, 0, /*
1138 Return the window used now for minibuffers. 1132 Return the window used now for minibuffers.
1139 If the optional argument CON-DEV-OR-FRAME is specified and is a frame, return 1133 If the optional argument CON-DEV-OR-FRAME is specified and is a frame, return
1142 is a console, the selected frame on that console's selected device will 1136 is a console, the selected frame on that console's selected device will
1143 be used. Otherwise, the selected frame is used. 1137 be used. Otherwise, the selected frame is used.
1144 */ 1138 */
1145 (con_dev_or_frame)) 1139 (con_dev_or_frame))
1146 { 1140 {
1147 struct frame *f = decode_frame_or_selected (con_dev_or_frame); 1141 return FRAME_MINIBUF_WINDOW (decode_frame_or_selected (con_dev_or_frame));
1148
1149 return FRAME_MINIBUF_WINDOW (f);
1150 } 1142 }
1151 1143
1152 DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, 1, 1, 0, /* 1144 DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, 1, 1, 0, /*
1153 Return non-nil if WINDOW is a minibuffer window. 1145 Return non-nil if WINDOW is a minibuffer window.
1154 */ 1146 */
1235 POS defaults to point in WINDOW's buffer; WINDOW, to the selected window. 1227 POS defaults to point in WINDOW's buffer; WINDOW, to the selected window.
1236 */ 1228 */
1237 (pos, window)) 1229 (pos, window))
1238 { 1230 {
1239 struct window *w = decode_window (window); 1231 struct window *w = decode_window (window);
1240 Bufpos top; 1232 Bufpos top = marker_position (w->start[CURRENT_DISP]);
1241 Bufpos posint; 1233 Bufpos posint;
1242 struct buffer *buf; 1234 struct buffer *buf = XBUFFER (w->buffer);
1243
1244 top = marker_position (w->start[CURRENT_DISP]);
1245
1246 buf = XBUFFER (w->buffer);
1247 1235
1248 if (NILP (pos)) 1236 if (NILP (pos))
1249 posint = BUF_PT (buf); 1237 posint = BUF_PT (buf);
1250 else 1238 else
1251 { 1239 {
1258 1246
1259 /* w->start can be out of range. If it is, do something reasonable. */ 1247 /* w->start can be out of range. If it is, do something reasonable. */
1260 if (top < BUF_BEGV (buf) || top > BUF_ZV (buf)) 1248 if (top < BUF_BEGV (buf) || top > BUF_ZV (buf))
1261 return Qnil; 1249 return Qnil;
1262 1250
1263 if (point_would_be_visible (w, top, posint)) 1251 return point_would_be_visible (w, top, posint) ? Qt : Qnil;
1264 return Qt;
1265 else
1266 return Qnil;
1267 } 1252 }
1268 1253
1269 1254
1270 struct window * 1255 struct window *
1271 decode_window (Lisp_Object window) 1256 decode_window (Lisp_Object window)
1309 } 1294 }
1310 1295
1311 DEFUN ("window-displayed-height", Fwindow_displayed_height, 0, 1, 0, /* 1296 DEFUN ("window-displayed-height", Fwindow_displayed_height, 0, 1, 0, /*
1312 Return the number of lines currently displayed in WINDOW. 1297 Return the number of lines currently displayed in WINDOW.
1313 This counts the actual number of lines displayed in WINDOW 1298 This counts the actual number of lines displayed in WINDOW
1314 (as opposed to `window-height'). The modeline and horizontal 1299 \(as opposed to `window-height'). The modeline and horizontal
1315 scrollbar do not count as lines. If there is some blank space 1300 scrollbar do not count as lines. If there is some blank space
1316 between the end of the buffer and the end of the window, this 1301 between the end of the buffer and the end of the window, this
1317 function pretends that there are lines of text in the default 1302 function pretends that there are lines of text in the default
1318 font there. 1303 font there.
1319 */ 1304 */
1332 } 1317 }
1333 1318
1334 DEFUN ("window-displayed-pixel-height", Fwindow_displayed_pixel_height, 0, 1, 0, /* 1319 DEFUN ("window-displayed-pixel-height", Fwindow_displayed_pixel_height, 0, 1, 0, /*
1335 Return the height in pixels of the buffer-displaying portion of WINDOW. 1320 Return the height in pixels of the buffer-displaying portion of WINDOW.
1336 Unlike `window-pixel-height', the space occupied by the gutters 1321 Unlike `window-pixel-height', the space occupied by the gutters
1337 (modeline, horizontal scrollbar, ...) is not counted. 1322 \(modeline, horizontal scrollbar, ...) is not counted.
1338 */ 1323 */
1339 (window)) 1324 (window))
1340 { 1325 {
1341 return make_int (window_displayed_pixel_height (decode_window (window))); 1326 return make_int (window_displayed_pixel_height (decode_window (window)));
1342 } 1327 }
1366 return make_int (decode_window (window)->hscroll); 1351 return make_int (decode_window (window)->hscroll);
1367 } 1352 }
1368 1353
1369 #ifdef MODELINE_IS_SCROLLABLE 1354 #ifdef MODELINE_IS_SCROLLABLE
1370 DEFUN ("modeline-hscroll", Fmodeline_hscroll, 0, 1, 0, /* 1355 DEFUN ("modeline-hscroll", Fmodeline_hscroll, 0, 1, 0, /*
1371 Return the number of columns by which WINDOW's modeline is scrolled from 1356 Return the number of columns by which WINDOW's modeline is scrolled from
1372 left margin. If the window has no modeline, return nil. 1357 left margin. If the window has no modeline, return nil.
1373 */ 1358 */
1374 (window)) 1359 (window))
1375 { 1360 {
1376 struct window *w; 1361 struct window *w;
1377 1362
1378 w = decode_window (window); 1363 w = decode_window (window);
1379 return (WINDOW_HAS_MODELINE_P (w)) ? make_int (w->modeline_hscroll) : Qnil; 1364 return (WINDOW_HAS_MODELINE_P (w)) ? make_int (w->modeline_hscroll) : Qnil;
1380 } 1365 }
1381 #endif 1366
1367 DEFUN ("set-modeline-hscroll", Fset_modeline_hscroll, 2, 2, 0, /*
1368 Set number of columns WINDOW's modeline is scrolled from left margin to NCOL.
1369 NCOL should be zero or positive. If NCOL is negative, it will be forced to 0.
1370 If the window has no modeline, do nothing and return nil.
1371 */
1372 (window, ncol))
1373 {
1374 struct window *w;
1375 int ncols;
1376
1377 w = decode_window (window);
1378 if (WINDOW_HAS_MODELINE_P (w))
1379 {
1380 CHECK_INT (ncol);
1381 ncols = XINT (ncol);
1382 if (ncols < 0) ncols = 0;
1383 if (w->modeline_hscroll != ncols)
1384 MARK_MODELINE_CHANGED;
1385 w->modeline_hscroll = ncols;
1386 return ncol;
1387 }
1388 return Qnil;
1389 }
1390 #endif /* MODELINE_IS_SCROLLABLE */
1382 1391
1383 DEFUN ("set-window-hscroll", Fset_window_hscroll, 2, 2, 0, /* 1392 DEFUN ("set-window-hscroll", Fset_window_hscroll, 2, 2, 0, /*
1384 Set number of columns WINDOW is scrolled from left margin to NCOL. 1393 Set number of columns WINDOW is scrolled from left margin to NCOL.
1385 NCOL should be zero or positive. 1394 NCOL should be zero or positive.
1386 */ 1395 */
1396 if (w->hscroll != ncols) 1405 if (w->hscroll != ncols)
1397 MARK_CLIP_CHANGED; /* FSF marks differently but we aren't FSF. */ 1406 MARK_CLIP_CHANGED; /* FSF marks differently but we aren't FSF. */
1398 w->hscroll = ncols; 1407 w->hscroll = ncols;
1399 return ncol; 1408 return ncol;
1400 } 1409 }
1401
1402 #ifdef MODELINE_IS_SCROLLABLE
1403 DEFUN ("set-modeline-hscroll", Fset_modeline_hscroll, 2, 2, 0, /*
1404 Set number of columns WINDOW's modeline is scrolled from left margin to NCOL.
1405 NCOL should be zero or positive. If NCOL is negative, it will be forced to 0.
1406 If the window has no modeline, do nothing and return nil.
1407 */
1408 (window, ncol))
1409 {
1410 struct window *w;
1411 int ncols;
1412
1413 w = decode_window (window);
1414 if (WINDOW_HAS_MODELINE_P (w))
1415 {
1416 CHECK_INT (ncol);
1417 ncols = XINT (ncol);
1418 if (ncols < 0) ncols = 0;
1419 if (w->modeline_hscroll != ncols)
1420 MARK_MODELINE_CHANGED;
1421 w->modeline_hscroll = ncols;
1422 return ncol;
1423 }
1424 return Qnil;
1425 }
1426 #endif
1427 1410
1428 #if 0 /* bogus crock */ 1411 #if 0 /* bogus crock */
1429 1412
1430 xxDEFUN ("window-redisplay-end-trigger", 1413 xxDEFUN ("window-redisplay-end-trigger",
1431 Fwindow_redisplay_end_trigger, 0, 1, 0, /* 1414 Fwindow_redisplay_end_trigger, 0, 1, 0, /*
1514 nothing else changes in the meantime. This function is potentially much 1497 nothing else changes in the meantime. This function is potentially much
1515 slower with this flag set. 1498 slower with this flag set.
1516 */ 1499 */
1517 (window, guarantee)) 1500 (window, guarantee))
1518 { 1501 {
1519 Lisp_Object value;
1520 struct window *w = decode_window (window); 1502 struct window *w = decode_window (window);
1521 Lisp_Object buf;
1522 1503
1523 if (NILP (guarantee)) 1504 if (NILP (guarantee))
1524 { 1505 {
1525 buf = w->buffer; 1506 Lisp_Object buf = w->buffer;
1526 CHECK_BUFFER (buf); 1507 CHECK_BUFFER (buf);
1527 1508 return make_int (BUF_Z (XBUFFER (buf)) - w->window_end_pos[CURRENT_DISP]);
1528 XSETINT (value, BUF_Z (XBUFFER (buf)) - w->window_end_pos[CURRENT_DISP]);
1529
1530 return value;
1531 } 1509 }
1532 else 1510 else
1533 { 1511 {
1534 Bufpos startp = marker_position (w->start[CURRENT_DISP]); 1512 Bufpos startp = marker_position (w->start[CURRENT_DISP]);
1535 return make_int (end_of_last_line (w, startp)); 1513 return make_int (end_of_last_line (w, startp));
1593 The second argument is the new value for the dedication flag; 1571 The second argument is the new value for the dedication flag;
1594 non-nil means yes. 1572 non-nil means yes.
1595 */ 1573 */
1596 (window, arg)) 1574 (window, arg))
1597 { 1575 {
1598 REGISTER struct window *w = decode_window (window); 1576 struct window *w = decode_window (window);
1599 1577
1600 w->dedicated = NILP (arg) ? Qnil : Qt; 1578 w->dedicated = NILP (arg) ? Qnil : Qt;
1601 1579
1602 return w->dedicated; 1580 return w->dedicated;
1603 } 1581 }
2354 frame_arg = frames; 2332 frame_arg = frames;
2355 2333
2356 DEVICE_LOOP_NO_BREAK (devcons, concons) 2334 DEVICE_LOOP_NO_BREAK (devcons, concons)
2357 { 2335 {
2358 Lisp_Object device = XCAR (devcons); 2336 Lisp_Object device = XCAR (devcons);
2359 Lisp_Object the_frame = Qnil; 2337 Lisp_Object the_frame;
2360 2338
2361 if (frame) 2339 if (frame)
2362 XSETFRAME (the_frame, frame); 2340 XSETFRAME (the_frame, frame);
2363 else 2341 else
2364 the_frame = DEVICE_SELECTED_FRAME (XDEVICE (device)); 2342 the_frame = DEVICE_SELECTED_FRAME (XDEVICE (device));
2919 /* #### This is very likely incorrect and instead the char_to_pixel_ 2897 /* #### This is very likely incorrect and instead the char_to_pixel_
2920 functions should be called. */ 2898 functions should be called. */
2921 default_face_height_and_width (window, &defheight, &defwidth); 2899 default_face_height_and_width (window, &defheight, &defwidth);
2922 line_size = (set_height ? defheight : defwidth); 2900 line_size = (set_height ? defheight : defwidth);
2923 2901
2902 check_min_window_sizes ();
2903
2924 minsize = (set_height ? window_min_height : window_min_width); 2904 minsize = (set_height ? window_min_height : window_min_width);
2925 minsize *= line_size; 2905 minsize *= line_size;
2926
2927 check_min_window_sizes ();
2928 2906
2929 if (!nodelete 2907 if (!nodelete
2930 && !TOP_LEVEL_WINDOW_P (w) 2908 && !TOP_LEVEL_WINDOW_P (w)
2931 && new_pixsize < minsize) 2909 && new_pixsize < minsize)
2932 { 2910 {
3188 3166
3189 BUF_SAVE_MODIFF (XBUFFER (buf)) = BUF_MODIFF (b); 3167 BUF_SAVE_MODIFF (XBUFFER (buf)) = BUF_MODIFF (b);
3190 widen_buffer (b, 0); 3168 widen_buffer (b, 0);
3191 BUF_SET_PT (b, BUF_BEG (b)); 3169 BUF_SET_PT (b, BUF_BEG (b));
3192 3170
3193 if (!EQ (Vtemp_buffer_show_function, Qnil)) 3171 if (!NILP (Vtemp_buffer_show_function))
3194 call1 (Vtemp_buffer_show_function, buf); 3172 call1 (Vtemp_buffer_show_function, buf);
3195 else 3173 else
3196 { 3174 {
3197 window = display_buffer (buf, Qnil, same_frame); 3175 window = display_buffer (buf, Qnil, same_frame);
3198 3176
3234 } 3212 }
3235 3213
3236 static void 3214 static void
3237 make_dummy_parent (Lisp_Object window) 3215 make_dummy_parent (Lisp_Object window)
3238 { 3216 {
3239 Lisp_Object new = Qnil; 3217 Lisp_Object new;
3240 struct window *o = XWINDOW (window); 3218 struct window *o = XWINDOW (window);
3241 struct window *p = alloc_lcrecord_type (struct window, lrecord_window); 3219 struct window *p = alloc_lcrecord_type (struct window, lrecord_window);
3242 3220
3243 XSETWINDOW (new, p); 3221 XSETWINDOW (new, p);
3244 copy_lcrecord (p, o); 3222 copy_lcrecord (p, o);
3491 /* It's the calling function's responsibility to check these values 3469 /* It's the calling function's responsibility to check these values
3492 and make sure they're not out of range. 3470 and make sure they're not out of range.
3493 3471
3494 #### We need to go through the calling functions and actually 3472 #### We need to go through the calling functions and actually
3495 do this. */ 3473 do this. */
3496 if (char_height < 0) 3474 return max (0, char_height);
3497 return 0;
3498 else
3499 return char_height;
3500 } 3475 }
3501 3476
3502 static int 3477 static int
3503 window_char_height_to_pixel_height (struct window *w, int char_height, 3478 window_char_height_to_pixel_height (struct window *w, int char_height,
3504 int include_gutters_p) 3479 int include_gutters_p)
3522 /* It's the calling function's responsibility to check these values 3497 /* It's the calling function's responsibility to check these values
3523 and make sure they're not out of range. 3498 and make sure they're not out of range.
3524 3499
3525 #### We need to go through the calling functions and actually 3500 #### We need to go through the calling functions and actually
3526 do this. */ 3501 do this. */
3527 if (pixel_height < 0) 3502 return max (0, pixel_height);
3528 return 0;
3529 else
3530 return pixel_height;
3531 } 3503 }
3532 3504
3533 /* Return number of default lines of text can fit in the window W. 3505 /* Return number of default lines of text can fit in the window W.
3534 If INCLUDE_GUTTERS_P is 1, include "gutter" space (modeline plus 3506 If INCLUDE_GUTTERS_P is 1, include "gutter" space (modeline plus
3535 horizontal scrollbar) in the space that is used for the calculation. 3507 horizontal scrollbar) in the space that is used for the calculation.
3610 3582
3611 return num_lines; 3583 return num_lines;
3612 } 3584 }
3613 3585
3614 /* 3586 /*
3615 * Return height in pixels of buffer-displaying portion of window w. 3587 * Return height in pixels of buffer-displaying portion of window w.
3616 * Does not include the gutters (modeline, scrollbars, ...) 3588 * Does not include the gutters (modeline, scrollbars, ...)
3617 */ 3589 */
3618 int 3590 int
3619 window_displayed_pixel_height (struct window *w) 3591 window_displayed_pixel_height (struct window *w)
3620 { 3592 {
3653 /* It's the calling function's responsibility to check these values 3625 /* It's the calling function's responsibility to check these values
3654 and make sure they're not out of range. 3626 and make sure they're not out of range.
3655 3627
3656 #### We need to go through the calling functions and actually 3628 #### We need to go through the calling functions and actually
3657 do this. */ 3629 do this. */
3658 if (char_width < 0) 3630 return max (0, char_width);
3659 return 0;
3660 else
3661 return char_width;
3662 } 3631 }
3663 3632
3664 static int 3633 static int
3665 window_char_width_to_pixel_width (struct window *w, int char_width, 3634 window_char_width_to_pixel_width (struct window *w, int char_width,
3666 int include_margins_p) 3635 int include_margins_p)
3684 /* It's the calling function's responsibility to check these values 3653 /* It's the calling function's responsibility to check these values
3685 and make sure they're not out of range. 3654 and make sure they're not out of range.
3686 3655
3687 #### We need to go through the calling functions and actually 3656 #### We need to go through the calling functions and actually
3688 do this. */ 3657 do this. */
3689 if (pixel_width < 0) 3658 return max (0, pixel_width);
3690 return 0;
3691 else
3692 return pixel_width;
3693 } 3659 }
3694 3660
3695 /* This returns the usable space which doesn't include space needed by 3661 /* This returns the usable space which doesn't include space needed by
3696 scrollbars or divider lines. */ 3662 scrollbars or divider lines. */
3697 int 3663 int
3726 static void 3692 static void
3727 change_window_height (struct window *win, int delta, int widthflag, 3693 change_window_height (struct window *win, int delta, int widthflag,
3728 int inpixels) 3694 int inpixels)
3729 { 3695 {
3730 Lisp_Object parent; 3696 Lisp_Object parent;
3731 Lisp_Object window = Qnil; 3697 Lisp_Object window;
3732 struct window *w; 3698 struct window *w;
3733 struct frame *f; 3699 struct frame *f;
3734 int *sizep; 3700 int *sizep;
3735 int (*sizefun) (Lisp_Object) = (widthflag 3701 int (*sizefun) (Lisp_Object) = (widthflag
3736 ? window_pixel_width 3702 ? window_pixel_width
4223 w = XWINDOW (window); 4189 w = XWINDOW (window);
4224 b = XBUFFER (w->buffer); 4190 b = XBUFFER (w->buffer);
4225 4191
4226 opoint = BUF_PT (b); 4192 opoint = BUF_PT (b);
4227 4193
4228 if (NILP (n) || CONSP (n)) 4194 if (LISTP (n))
4229 { 4195 {
4230 struct frame *f = XFRAME (w->frame); 4196 struct frame *f = XFRAME (w->frame);
4231 4197
4232 if (NILP (n)) 4198 if (NILP (n))
4233 { 4199 {
4372 static int 4338 static int
4373 map_windows_1 (Lisp_Object window, 4339 map_windows_1 (Lisp_Object window,
4374 int (*mapfun) (struct window *w, void *closure), 4340 int (*mapfun) (struct window *w, void *closure),
4375 void *closure) 4341 void *closure)
4376 { 4342 {
4377 int retval;
4378
4379 for (; !NILP (window); window = XWINDOW (window)->next) 4343 for (; !NILP (window); window = XWINDOW (window)->next)
4380 { 4344 {
4345 int retval;
4381 struct window *w = XWINDOW (window); 4346 struct window *w = XWINDOW (window);
4382 4347
4383 if (!NILP (w->vchild)) 4348 if (!NILP (w->vchild))
4384 retval = map_windows_1 (w->vchild, mapfun, closure); 4349 retval = map_windows_1 (w->vchild, mapfun, closure);
4385 else if (!NILP (w->hchild)) 4350 else if (!NILP (w->hchild))
4386 retval = map_windows_1 (w->hchild, mapfun, closure); 4351 retval = map_windows_1 (w->hchild, mapfun, closure);
4387 else 4352 else
4388 retval = (mapfun) (w, closure); 4353 retval = (mapfun) (w, closure);
4354
4389 if (retval) 4355 if (retval)
4390 return retval; 4356 return retval;
4391 } 4357 }
4392 4358
4393 return retval; 4359 return 0;
4394 } 4360 }
4395 4361
4396 /* Map MAPFUN over the windows in F. CLOSURE is passed to each 4362 /* Map MAPFUN over the windows in F. CLOSURE is passed to each
4397 invocation of MAPFUN. If any invocation of MAPFUN returns 4363 invocation of MAPFUN. If any invocation of MAPFUN returns
4398 non-zero, the mapping is halted. Otherwise, map_windows() maps 4364 non-zero, the mapping is halted. Otherwise, map_windows() maps
4479 4445
4480 static void 4446 static void
4481 compute_window_usage (struct window *w, struct window_stats *stats, 4447 compute_window_usage (struct window *w, struct window_stats *stats,
4482 struct overhead_stats *ovstats) 4448 struct overhead_stats *ovstats)
4483 { 4449 {
4484 memset (stats, 0, sizeof (*stats)); 4450 xzero (*stats);
4485 stats->other += malloced_storage_size (w, sizeof (struct window), ovstats); 4451 stats->other += malloced_storage_size (w, sizeof (struct window), ovstats);
4486 stats->face += compute_face_cachel_usage (w->face_cachels, ovstats); 4452 stats->face += compute_face_cachel_usage (w->face_cachels, ovstats);
4487 stats->glyph += compute_glyph_cachel_usage (w->glyph_cachels, ovstats); 4453 stats->glyph += compute_glyph_cachel_usage (w->glyph_cachels, ovstats);
4488 stats->line_start += 4454 stats->line_start +=
4489 compute_line_start_cache_dynarr_usage (w->line_start_cache, ovstats); 4455 compute_line_start_cache_dynarr_usage (w->line_start_cache, ovstats);
4490 compute_window_mirror_usage (find_window_mirror (w), stats, ovstats); 4456 compute_window_mirror_usage (find_window_mirror (w), stats, ovstats);
4491 } 4457 }
4492 4458
4493 DEFUN ("window-memory-usage", Fwindow_memory_usage, 1, 1, 0, /* 4459 DEFUN ("window-memory-usage", Fwindow_memory_usage, 1, 1, 0, /*
4494 Return stats about the memory usage of window WINDOW. 4460 Return stats about the memory usage of window WINDOW.
4495 The values returned are in the form an alist of usage types and byte 4461 The values returned are in the form of an alist of usage types and byte
4496 counts. The byte counts attempt to encompass all the memory used 4462 counts. The byte counts attempt to encompass all the memory used
4497 by the window (separate from the memory logically associated with a 4463 by the window (separate from the memory logically associated with a
4498 buffer or frame), including internal structures and any malloc() 4464 buffer or frame), including internal structures and any malloc()
4499 overhead associated with them. In practice, the byte counts are 4465 overhead associated with them. In practice, the byte counts are
4500 underestimated because certain memory usage is very hard to determine 4466 underestimated because certain memory usage is very hard to determine
4501 (e.g. the amount of memory used inside the Xt library or inside the 4467 \(e.g. the amount of memory used inside the Xt library or inside the
4502 X server) and because there is other stuff that might logically 4468 X server) and because there is other stuff that might logically
4503 be associated with a window, buffer, or frame (e.g. window configurations, 4469 be associated with a window, buffer, or frame (e.g. window configurations,
4504 glyphs) but should not obviously be included in the usage counts. 4470 glyphs) but should not obviously be included in the usage counts.
4505 4471
4506 Multiple slices of the total memory usage may be returned, separated 4472 Multiple slices of the total memory usage may be returned, separated
4511 */ 4477 */
4512 (window)) 4478 (window))
4513 { 4479 {
4514 struct window_stats stats; 4480 struct window_stats stats;
4515 struct overhead_stats ovstats; 4481 struct overhead_stats ovstats;
4482 Lisp_Object val = Qnil;
4516 4483
4517 CHECK_WINDOW (window); /* dead windows should be allowed, no? */ 4484 CHECK_WINDOW (window); /* dead windows should be allowed, no? */
4518 memset (&ovstats, 0, sizeof (ovstats)); 4485 xzero (ovstats);
4519 compute_window_usage (XWINDOW (window), &stats, &ovstats); 4486 compute_window_usage (XWINDOW (window), &stats, &ovstats);
4520 4487
4521 return nconc2 ( 4488 val = acons (Qface_cache, make_int (stats.face), val);
4489 val = acons (Qglyph_cache, make_int (stats.glyph), val);
4522 #ifdef HAVE_SCROLLBARS 4490 #ifdef HAVE_SCROLLBARS
4523 list6 4491 val = acons (Qscrollbar_instances, make_int (stats.scrollbar), val);
4524 #else
4525 list5
4526 #endif 4492 #endif
4527 (Fcons (Qface_cache, make_int (stats.face)), 4493 val = acons (Qline_start_cache, make_int (stats.line_start), val);
4528 Fcons (Qglyph_cache, make_int (stats.glyph)), 4494 val = acons (Qother_redisplay, make_int (stats.other_redisplay), val);
4529 #ifdef HAVE_SCROLLBARS 4495 val = acons (Qother, make_int (stats.other), val);
4530 Fcons (Qscrollbar_instances, make_int (stats.scrollbar)), 4496 val = Fcons (Qnil, val);
4531 #endif 4497 val = acons (Qactually_requested, make_int (ovstats.was_requested), val);
4532 Fcons (Qline_start_cache, make_int (stats.line_start)), 4498 val = acons (Qmalloc_overhead, make_int (ovstats.malloc_overhead), val);
4533 Fcons (Qother_redisplay, make_int (stats.other_redisplay)), 4499 val = acons (Qdynarr_overhead, make_int (ovstats.dynarr_overhead), val);
4534 Fcons (Qother, make_int (stats.other))), 4500
4535 list4 (Qnil, 4501 return Fnreverse (val);
4536 Fcons (Qactually_requested,
4537 make_int (ovstats.was_requested)),
4538 Fcons (Qmalloc_overhead,
4539 make_int (ovstats.malloc_overhead)),
4540 Fcons (Qdynarr_overhead,
4541 make_int (ovstats.dynarr_overhead))));
4542 } 4502 }
4543 4503
4544 #endif /* MEMORY_USAGE_STATS */ 4504 #endif /* MEMORY_USAGE_STATS */
4545 4505
4546 4506
4619 int min_width, min_height; 4579 int min_width, min_height;
4620 int saved_windows_count; 4580 int saved_windows_count;
4621 /* Zero-sized arrays aren't ANSI C */ 4581 /* Zero-sized arrays aren't ANSI C */
4622 struct saved_window saved_windows[1]; 4582 struct saved_window saved_windows[1];
4623 }; 4583 };
4584
4624 #define SAVED_WINDOW_N(conf, n) (&((conf)->saved_windows[(n)])) 4585 #define SAVED_WINDOW_N(conf, n) (&((conf)->saved_windows[(n)]))
4625
4626 static Lisp_Object mark_window_config (Lisp_Object, void (*) (Lisp_Object));
4627 static void print_window_config (Lisp_Object, Lisp_Object, int);
4628 static unsigned int sizeof_window_config (CONST void *);
4629
4630 #define XWINDOW_CONFIGURATION(x) XRECORD (x, window_configuration, struct window_config) 4586 #define XWINDOW_CONFIGURATION(x) XRECORD (x, window_configuration, struct window_config)
4631 #define XSETWINDOW_CONFIGURATION(x, p) XSETRECORD (x, p, window_configuration) 4587 #define XSETWINDOW_CONFIGURATION(x, p) XSETRECORD (x, p, window_configuration)
4632 #define WINDOW_CONFIGURATIONP(x) RECORDP (x, window_configuration) 4588 #define WINDOW_CONFIGURATIONP(x) RECORDP (x, window_configuration)
4633 #define GC_WINDOW_CONFIGURATIONP(x) GC_RECORDP (x, window_configuration) 4589 #define GC_WINDOW_CONFIGURATIONP(x) GC_RECORDP (x, window_configuration)
4634 #define CHECK_WINDOW_CONFIGURATION(x) CHECK_RECORD (x, window_configuration) 4590 #define CHECK_WINDOW_CONFIGURATION(x) CHECK_RECORD (x, window_configuration)
4635
4636 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("window-configuration",
4637 window_configuration,
4638 mark_window_config,
4639 print_window_config,
4640 0, 0, 0, sizeof_window_config,
4641 struct window_config);
4642 4591
4643 static Lisp_Object 4592 static Lisp_Object
4644 mark_window_config (Lisp_Object obj, void (*markobj) (Lisp_Object)) 4593 mark_window_config (Lisp_Object obj, void (*markobj) (Lisp_Object))
4645 { 4594 {
4646 struct window_config *config = XWINDOW_CONFIGURATION (obj); 4595 struct window_config *config = XWINDOW_CONFIGURATION (obj);
4662 ((markobj) (s->dedicated)); 4611 ((markobj) (s->dedicated));
4663 } 4612 }
4664 return Qnil; 4613 return Qnil;
4665 } 4614 }
4666 4615
4667 static int 4616 static size_t
4668 sizeof_window_config_for_n_windows (int n) 4617 sizeof_window_config_for_n_windows (int n)
4669 { 4618 {
4670 return (sizeof (struct window_config) + 4619 return (sizeof (struct window_config) +
4671 /* n - 1 because zero-sized arrays aren't ANSI C */ 4620 /* n - 1 because zero-sized arrays aren't ANSI C */
4672 (n - 1) *sizeof (struct saved_window)); 4621 (n - 1) *sizeof (struct saved_window));
4673 } 4622 }
4674 4623
4675 static unsigned int 4624 static size_t
4676 sizeof_window_config (CONST void *h) 4625 sizeof_window_config (CONST void *h)
4677 { 4626 {
4678 CONST struct window_config *c = (CONST struct window_config *) h; 4627 CONST struct window_config *c = (CONST struct window_config *) h;
4679 return sizeof_window_config_for_n_windows (c->saved_windows_count); 4628 return sizeof_window_config_for_n_windows (c->saved_windows_count);
4680 } 4629 }
4689 config->header.uid); 4638 config->header.uid);
4690 write_c_string ("#<window-configuration ", printcharfun); 4639 write_c_string ("#<window-configuration ", printcharfun);
4691 sprintf (buf, "0x%x>", config->header.uid); 4640 sprintf (buf, "0x%x>", config->header.uid);
4692 write_c_string (buf, printcharfun); 4641 write_c_string (buf, printcharfun);
4693 } 4642 }
4643
4644 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("window-configuration",
4645 window_configuration,
4646 mark_window_config,
4647 print_window_config,
4648 0, 0, 0, sizeof_window_config,
4649 struct window_config);
4650
4694 4651
4695 /* Returns a boolean indicating whether the two saved windows are 4652 /* Returns a boolean indicating whether the two saved windows are
4696 identical. */ 4653 identical. */
4697 static int 4654 static int
4698 saved_window_equal (struct saved_window *win1, struct saved_window *win2) 4655 saved_window_equal (struct saved_window *win1, struct saved_window *win2)
4791 4748
4792 return 1; 4749 return 1;
4793 } 4750 }
4794 4751
4795 DEFUN ("window-configuration-p", Fwindow_configuration_p, 1, 1, 0, /* 4752 DEFUN ("window-configuration-p", Fwindow_configuration_p, 1, 1, 0, /*
4796 T if OBJECT is a window-configuration object. 4753 Return t if OBJECT is a window-configuration object.
4797 */ 4754 */
4798 (obj)) 4755 (obj))
4799 { 4756 {
4800 return WINDOW_CONFIGURATIONP (obj) ? Qt : Qnil; 4757 return WINDOW_CONFIGURATIONP (obj) ? Qt : Qnil;
4801 } 4758 }
5243 W is actually the subwindow tree of the window in question. */ 5200 W is actually the subwindow tree of the window in question. */
5244 5201
5245 void 5202 void
5246 delete_all_subwindows (struct window *w) 5203 delete_all_subwindows (struct window *w)
5247 { 5204 {
5248 if (!NILP (w->next)) 5205 if (!NILP (w->next)) delete_all_subwindows (XWINDOW (w->next));
5249 delete_all_subwindows (XWINDOW (w->next)); 5206 if (!NILP (w->vchild)) delete_all_subwindows (XWINDOW (w->vchild));
5250 if (!NILP (w->vchild)) 5207 if (!NILP (w->hchild)) delete_all_subwindows (XWINDOW (w->hchild));
5251 delete_all_subwindows (XWINDOW (w->vchild));
5252 if (!NILP (w->hchild))
5253 delete_all_subwindows (XWINDOW (w->hchild));
5254 5208
5255 mark_window_as_deleted (w); 5209 mark_window_as_deleted (w);
5256 } 5210 }
5257 5211
5258 5212
5259 static int 5213 static int
5260 count_windows (struct window *window) 5214 count_windows (struct window *window)
5261 { 5215 {
5262 int count = 1; 5216 return 1 +
5263 if (!NILP (window->next)) 5217 (!NILP (window->next) ? count_windows (XWINDOW (window->next)) : 0) +
5264 count += count_windows (XWINDOW (window->next)); 5218 (!NILP (window->vchild) ? count_windows (XWINDOW (window->vchild)) : 0) +
5265 if (!NILP (window->vchild)) 5219 (!NILP (window->hchild) ? count_windows (XWINDOW (window->hchild)) : 0);
5266 count += count_windows (XWINDOW (window->vchild));
5267 if (!NILP (window->hchild))
5268 count += count_windows (XWINDOW (window->hchild));
5269 return count;
5270 } 5220 }
5271 5221
5272 static int 5222 static int
5273 saved_window_index (Lisp_Object window, struct window_config *config, int lim) 5223 saved_window_index (Lisp_Object window, struct window_config *config, int lim)
5274 { 5224 {
5275 int j; 5225 int j;
5276 for (j = 0; j < lim; j++) 5226 for (j = 0; j < lim; j++)
5277 { 5227 {
5278 if (EQ (SAVED_WINDOW_N (config, j)->window, window)) 5228 if (EQ (SAVED_WINDOW_N (config, j)->window, window))
5279 return j; 5229 return j;
5280 } 5230 }
5281 abort (); 5231 abort ();
5282 return 0; /* suppress compiler warning */ 5232 return 0; /* suppress compiler warning */
5283 } 5233 }
5284 5234
5285 static int 5235 static int
5286 save_window_save (Lisp_Object window, struct window_config *config, int i) 5236 save_window_save (Lisp_Object window, struct window_config *config, int i)
5287 { 5237 {
5288 struct saved_window *p;
5289 struct window *w; 5238 struct window *w;
5290 5239
5291 for (; !NILP (window); window = w->next) 5240 for (; !NILP (window); window = w->next)
5292 { 5241 {
5293 p = SAVED_WINDOW_N (config, i); 5242 struct saved_window *p = SAVED_WINDOW_N (config, i);
5243
5294 w = XWINDOW (window); 5244 w = XWINDOW (window);
5295
5296 i++; 5245 i++;
5297 p->window = window; 5246 p->window = window;
5298 p->buffer = w->buffer; 5247 p->buffer = w->buffer;
5299 WINDOW_LEFT (p) = WINDOW_LEFT (w); 5248 WINDOW_LEFT (p) = WINDOW_LEFT (w);
5300 WINDOW_TOP (p) = WINDOW_TOP (w); 5249 WINDOW_TOP (p) = WINDOW_TOP (w);
5404 point and mark. An exception is made for point in the current buffer: 5353 point and mark. An exception is made for point in the current buffer:
5405 its value is -not- saved. 5354 its value is -not- saved.
5406 */ 5355 */
5407 (frame)) 5356 (frame))
5408 { 5357 {
5409 Lisp_Object result = Qnil; 5358 Lisp_Object result;
5410 struct frame *f; 5359 struct frame *f = decode_frame (frame);
5411 int n_windows;
5412
5413 struct window_config *config; 5360 struct window_config *config;
5414 5361 int n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
5415 f = decode_frame (frame); 5362
5416
5417 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
5418 if (n_windows <= countof (Vwindow_configuration_free_list)) 5363 if (n_windows <= countof (Vwindow_configuration_free_list))
5419 config = 5364 config = XWINDOW_CONFIGURATION (allocate_managed_lcrecord
5420 XWINDOW_CONFIGURATION (allocate_managed_lcrecord 5365 (Vwindow_configuration_free_list
5421 (Vwindow_configuration_free_list 5366 [n_windows - 1]));
5422 [n_windows - 1]));
5423 else 5367 else
5424 /* More than ten windows; just allocate directly */ 5368 /* More than ten windows; just allocate directly */
5425 config = (struct window_config *) 5369 config = (struct window_config *)
5426 alloc_lcrecord (sizeof_window_config_for_n_windows (n_windows), 5370 alloc_lcrecord (sizeof_window_config_for_n_windows (n_windows),
5427 lrecord_window_configuration); 5371 lrecord_window_configuration);
5472 problems purely on the C side. That is where we need to call it so 5416 problems purely on the C side. That is where we need to call it so
5473 here it is. */ 5417 here it is. */
5474 static void 5418 static void
5475 debug_print_window (Lisp_Object window, int level) 5419 debug_print_window (Lisp_Object window, int level)
5476 { 5420 {
5477 Lisp_Object child; 5421 int i;
5478 int i = level; 5422 Lisp_Object child = Fwindow_first_vchild (window);
5479 5423
5480 child = Fwindow_first_vchild (window);
5481 if (NILP (child)) 5424 if (NILP (child))
5482 child = Fwindow_first_hchild (window); 5425 child = Fwindow_first_hchild (window);
5483 5426
5484 while (i > 0) 5427 for (i = level; i > 0; i--)
5485 { 5428 putc ('\t', stderr);
5486 fprintf (stderr, "\t"); 5429
5487 i--; 5430 fputs ("#<window", stderr);
5488 } 5431 {
5489 5432 Lisp_Object buffer = XWINDOW (window)->buffer;
5490 fprintf (stderr, "#<window"); 5433 if (!NILP (buffer) && BUFFERP (buffer))
5491 if (!NILP (XWINDOW (window)->buffer) && BUFFERP (XWINDOW (window)->buffer)) 5434 fprintf (stderr, " on %s", XSTRING_DATA (XBUFFER (buffer)->name));
5492 { 5435 }
5493 struct buffer *b = XBUFFER (XWINDOW (window)->buffer);
5494 fprintf (stderr, " on %s", XSTRING_DATA (b->name));
5495 }
5496 fprintf (stderr, " 0x%x>", XWINDOW (window)->header.uid); 5436 fprintf (stderr, " 0x%x>", XWINDOW (window)->header.uid);
5497 5437
5498 while (!NILP (child)) 5438 while (!NILP (child))
5499 { 5439 {
5500 debug_print_window (child, level + 1); 5440 debug_print_window (child, level + 1);
5505 void debug_print_windows (struct frame *f); 5445 void debug_print_windows (struct frame *f);
5506 void 5446 void
5507 debug_print_windows (struct frame *f) 5447 debug_print_windows (struct frame *f)
5508 { 5448 {
5509 debug_print_window (f->root_window, 0); 5449 debug_print_window (f->root_window, 0);
5510 fprintf (stderr, "\n"); 5450 putc ('\n', stderr);
5511 } 5451 }
5512 #endif /* DEBUG_XEMACS */ 5452 #endif /* DEBUG_XEMACS */
5513 5453
5514 5454
5515 /************************************************************************/ 5455 /************************************************************************/
5562 DEFSUBR (Fwindow_pixel_height); 5502 DEFSUBR (Fwindow_pixel_height);
5563 DEFSUBR (Fwindow_pixel_width); 5503 DEFSUBR (Fwindow_pixel_width);
5564 DEFSUBR (Fwindow_hscroll); 5504 DEFSUBR (Fwindow_hscroll);
5565 #ifdef MODELINE_IS_SCROLLABLE 5505 #ifdef MODELINE_IS_SCROLLABLE
5566 DEFSUBR (Fmodeline_hscroll); 5506 DEFSUBR (Fmodeline_hscroll);
5507 DEFSUBR (Fset_modeline_hscroll);
5567 #endif /* MODELINE_IS_SCROLLABLE */ 5508 #endif /* MODELINE_IS_SCROLLABLE */
5568 #if 0 /* bogus crock */ 5509 #if 0 /* bogus crock */
5569 DEFSUBR (Fwindow_redisplay_end_trigger); 5510 DEFSUBR (Fwindow_redisplay_end_trigger);
5570 DEFSUBR (Fset_window_redisplay_end_trigger); 5511 DEFSUBR (Fset_window_redisplay_end_trigger);
5571 #endif 5512 #endif
5572 DEFSUBR (Fset_window_hscroll); 5513 DEFSUBR (Fset_window_hscroll);
5573 #ifdef MODELINE_IS_SCROLLABLE
5574 DEFSUBR (Fset_modeline_hscroll);
5575 #endif /* MODELINE_IS_SCROLLABLE */
5576 DEFSUBR (Fwindow_pixel_edges); 5514 DEFSUBR (Fwindow_pixel_edges);
5577 DEFSUBR (Fwindow_point); 5515 DEFSUBR (Fwindow_point);
5578 DEFSUBR (Fwindow_start); 5516 DEFSUBR (Fwindow_start);
5579 DEFSUBR (Fwindow_end); 5517 DEFSUBR (Fwindow_end);
5580 DEFSUBR (Fset_window_point); 5518 DEFSUBR (Fset_window_point);