Mercurial > hg > xemacs-beta
comparison src/window.c @ 5495:1f0b15040456
Merge.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 01 May 2011 18:44:03 +0100 |
parents | 4dee0387b9de |
children | 56144c8593a8 |
comparison
equal
deleted
inserted
replaced
5494:861f2601a38b | 5495:1f0b15040456 |
---|---|
1 /* Window creation, deletion and examination for XEmacs. | 1 /* Window creation, deletion and examination for XEmacs. |
2 Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc. | 2 Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc. |
3 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | 3 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. |
4 Copyright (C) 1995, 1996, 2002 Ben Wing. | 4 Copyright (C) 1995, 1996, 2002, 2010 Ben Wing. |
5 Copyright (C) 1996 Chuck Thompson. | 5 Copyright (C) 1996 Chuck Thompson. |
6 | 6 |
7 This file is part of XEmacs. | 7 This file is part of XEmacs. |
8 | 8 |
9 XEmacs is free software; you can redistribute it and/or modify it | 9 XEmacs is free software: you can redistribute it and/or modify it |
10 under the terms of the GNU General Public License as published by the | 10 under the terms of the GNU General Public License as published by the |
11 Free Software Foundation; either version 2, or (at your option) any | 11 Free Software Foundation, either version 3 of the License, or (at your |
12 later version. | 12 option) any later version. |
13 | 13 |
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT | 14 XEmacs is distributed in the hope that it will be useful, but WITHOUT |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | 16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
17 for more details. | 17 for more details. |
18 | 18 |
19 You should have received a copy of the GNU General Public License | 19 You should have received a copy of the GNU General Public License |
20 along with XEmacs; see the file COPYING. If not, write to | 20 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 Boston, MA 02111-1307, USA. */ | |
23 | 21 |
24 /* Synched up with: FSF 19.30. */ | 22 /* Synched up with: FSF 19.30. */ |
25 /* Beginning to diverge significantly. */ | 23 /* Beginning to diverge significantly. */ |
26 | 24 |
27 /* Authorship: | 25 /* Authorship: |
45 #include "elhash.h" | 43 #include "elhash.h" |
46 #include "faces.h" | 44 #include "faces.h" |
47 #include "frame-impl.h" | 45 #include "frame-impl.h" |
48 #include "glyphs.h" | 46 #include "glyphs.h" |
49 #include "gutter.h" | 47 #include "gutter.h" |
50 #include "objects.h" | 48 #include "fontcolor.h" |
51 #include "redisplay.h" | 49 #include "redisplay.h" |
52 #include "window-impl.h" | 50 #include "window-impl.h" |
53 | 51 |
54 Lisp_Object Qwindowp, Qwindow_live_p; | 52 Lisp_Object Qwindowp, Qwindow_live_p; |
55 Lisp_Object Qdisplay_buffer; | 53 Lisp_Object Qdisplay_buffer; |
56 | 54 |
57 #ifdef MEMORY_USAGE_STATS | 55 #ifdef MEMORY_USAGE_STATS |
58 Lisp_Object Qface_cache, Qglyph_cache, Qline_start_cache, Qother_redisplay; | 56 Lisp_Object Qface_cache, Qglyph_cache, Qline_start_cache, Qredisplay_structs; |
59 #ifdef HAVE_SCROLLBARS | 57 #ifdef HAVE_SCROLLBARS |
60 Lisp_Object Qscrollbar_instances; | 58 Lisp_Object Qscrollbar_instances; |
61 #endif | 59 #endif |
62 #endif | 60 #endif |
63 | 61 |
180 { XD_LISP_OBJECT, offsetof (face_cachel, background_pixmap) }, | 178 { XD_LISP_OBJECT, offsetof (face_cachel, background_pixmap) }, |
181 { XD_END } | 179 { XD_END } |
182 }; | 180 }; |
183 | 181 |
184 #ifdef NEW_GC | 182 #ifdef NEW_GC |
185 DEFINE_LRECORD_IMPLEMENTATION ("face-cachel", face_cachel, | 183 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("face-cachel", face_cachel, |
186 1, /*dumpable-flag*/ | 184 0, face_cachel_description_1, |
187 0, 0, 0, 0, 0, | 185 Lisp_Face_Cachel); |
188 face_cachel_description_1, | |
189 Lisp_Face_Cachel); | |
190 #endif /* NEW_GC */ | 186 #endif /* NEW_GC */ |
191 | 187 |
192 static const struct sized_memory_description face_cachel_description = { | 188 static const struct sized_memory_description face_cachel_description = { |
193 sizeof (face_cachel), | 189 sizeof (face_cachel), |
194 face_cachel_description_1 | 190 face_cachel_description_1 |
202 #endif /* not NEW_GC */ | 198 #endif /* not NEW_GC */ |
203 { XD_END } | 199 { XD_END } |
204 }; | 200 }; |
205 | 201 |
206 #ifdef NEW_GC | 202 #ifdef NEW_GC |
207 DEFINE_LRECORD_IMPLEMENTATION ("face-cachel-dynarr", face_cachel_dynarr, | 203 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("face-cachel-dynarr", face_cachel_dynarr, |
208 1, /*dumpable-flag*/ | 204 0, face_cachel_dynarr_description_1, |
209 0, 0, 0, 0, 0, | 205 face_cachel_dynarr); |
210 face_cachel_dynarr_description_1, | |
211 face_cachel_dynarr); | |
212 #else /* not NEW_GC */ | 206 #else /* not NEW_GC */ |
213 static const struct sized_memory_description face_cachel_dynarr_description = { | 207 static const struct sized_memory_description face_cachel_dynarr_description = { |
214 sizeof (face_cachel_dynarr), | 208 sizeof (face_cachel_dynarr), |
215 face_cachel_dynarr_description_1 | 209 face_cachel_dynarr_description_1 |
216 }; | 210 }; |
220 { XD_LISP_OBJECT, offsetof (glyph_cachel, glyph) }, | 214 { XD_LISP_OBJECT, offsetof (glyph_cachel, glyph) }, |
221 { XD_END } | 215 { XD_END } |
222 }; | 216 }; |
223 | 217 |
224 #ifdef NEW_GC | 218 #ifdef NEW_GC |
225 DEFINE_LRECORD_IMPLEMENTATION ("glyph-cachel", glyph_cachel, | 219 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("glyph-cachel", glyph_cachel, |
226 1, /*dumpable-flag*/ | 220 0, glyph_cachel_description_1, |
227 0, 0, 0, 0, 0, | 221 Lisp_Glyph_Cachel); |
228 glyph_cachel_description_1, | |
229 Lisp_Glyph_Cachel); | |
230 #endif /* NEW_GC */ | 222 #endif /* NEW_GC */ |
231 | 223 |
232 static const struct sized_memory_description glyph_cachel_description = { | 224 static const struct sized_memory_description glyph_cachel_description = { |
233 sizeof (glyph_cachel), | 225 sizeof (glyph_cachel), |
234 glyph_cachel_description_1 | 226 glyph_cachel_description_1 |
242 #endif /* not NEW_GC */ | 234 #endif /* not NEW_GC */ |
243 { XD_END } | 235 { XD_END } |
244 }; | 236 }; |
245 | 237 |
246 #ifdef NEW_GC | 238 #ifdef NEW_GC |
247 DEFINE_LRECORD_IMPLEMENTATION ("glyph-cachel-dynarr", glyph_cachel_dynarr, | 239 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("glyph-cachel-dynarr", |
248 1, /*dumpable-flag*/ | 240 glyph_cachel_dynarr, 0, |
249 0, 0, 0, 0, 0, | 241 glyph_cachel_dynarr_description_1, |
250 glyph_cachel_dynarr_description_1, | 242 glyph_cachel_dynarr); |
251 glyph_cachel_dynarr); | |
252 #else /* not NEW_GC */ | 243 #else /* not NEW_GC */ |
253 static const struct sized_memory_description glyph_cachel_dynarr_description = { | 244 static const struct sized_memory_description glyph_cachel_dynarr_description = { |
254 sizeof (glyph_cachel_dynarr), | 245 sizeof (glyph_cachel_dynarr), |
255 glyph_cachel_dynarr_description_1 | 246 glyph_cachel_dynarr_description_1 |
256 }; | 247 }; |
314 int UNUSED (escapeflag)) | 305 int UNUSED (escapeflag)) |
315 { | 306 { |
316 Lisp_Object buf; | 307 Lisp_Object buf; |
317 | 308 |
318 if (print_readably) | 309 if (print_readably) |
319 printing_unreadable_lcrecord (obj, 0); | 310 printing_unreadable_lisp_object (obj, 0); |
320 | 311 |
321 write_ascstring (printcharfun, "#<window"); | 312 write_ascstring (printcharfun, "#<window"); |
322 buf = XWINDOW_BUFFER (obj); | 313 buf = XWINDOW_BUFFER (obj); |
323 if (EQ (buf, Qt)) | 314 if (EQ (buf, Qt)) |
324 write_ascstring (printcharfun, " during creation"); | 315 write_ascstring (printcharfun, " during creation"); |
326 { | 317 { |
327 | 318 |
328 Lisp_Object name = XBUFFER (buf)->name; | 319 Lisp_Object name = XBUFFER (buf)->name; |
329 write_fmt_string_lisp (printcharfun, " on %S", 1, name); | 320 write_fmt_string_lisp (printcharfun, " on %S", 1, name); |
330 } | 321 } |
331 write_fmt_string (printcharfun, " 0x%x>", XWINDOW (obj)->header.uid); | 322 write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj)); |
332 } | 323 } |
333 | 324 |
334 static void | 325 static void |
335 finalize_window (void *header, int UNUSED (for_disksave)) | 326 finalize_window (Lisp_Object obj) |
336 { | 327 { |
337 struct window *w = (struct window *) header; | 328 struct window *w = XWINDOW (obj); |
338 | 329 |
339 if (w->line_start_cache) | 330 if (w->line_start_cache) |
340 { | 331 { |
341 Dynarr_free (w->line_start_cache); | 332 Dynarr_free (w->line_start_cache); |
342 w->line_start_cache = 0; | 333 w->line_start_cache = 0; |
370 remain around as long as the buffers do. */ | 361 remain around as long as the buffers do. */ |
371 | 362 |
372 static Lisp_Object | 363 static Lisp_Object |
373 make_saved_buffer_point_cache (void) | 364 make_saved_buffer_point_cache (void) |
374 { | 365 { |
375 return make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK, HASH_TABLE_EQ); | 366 return make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK, Qeq); |
376 } | 367 } |
377 | 368 |
378 DEFINE_LRECORD_IMPLEMENTATION ("window", window, | 369 DEFINE_NODUMP_LISP_OBJECT ("window", window, |
379 0, /*dumpable-flag*/ | 370 mark_window, print_window, finalize_window, |
380 mark_window, print_window, finalize_window, | 371 0, 0, window_description, struct window); |
381 0, 0, window_description, struct window); | |
382 | 372 |
383 #define INIT_DISP_VARIABLE(field, initialization) \ | 373 #define INIT_DISP_VARIABLE(field, initialization) \ |
384 p->field[CURRENT_DISP] = initialization; \ | 374 p->field[CURRENT_DISP] = initialization; \ |
385 p->field[DESIRED_DISP] = initialization; \ | 375 p->field[DESIRED_DISP] = initialization; \ |
386 p->field[CMOTION_DISP] = initialization; | 376 p->field[CMOTION_DISP] = initialization; |
395 here because the window must have its frame pointer set or | 385 here because the window must have its frame pointer set or |
396 reset_face_cachels will fail. */ | 386 reset_face_cachels will fail. */ |
397 Lisp_Object | 387 Lisp_Object |
398 allocate_window (void) | 388 allocate_window (void) |
399 { | 389 { |
400 struct window *p = ALLOC_LCRECORD_TYPE (struct window, &lrecord_window); | 390 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (window); |
401 Lisp_Object val = wrap_window (p); | 391 struct window *p = XWINDOW (obj); |
402 | 392 |
403 #define WINDOW_SLOT(slot) p->slot = Qnil; | 393 #define WINDOW_SLOT(slot) p->slot = Qnil; |
404 #include "winslots.h" | 394 #include "winslots.h" |
405 | 395 |
406 INIT_DISP_VARIABLE (start, Fmake_marker ()); | 396 INIT_DISP_VARIABLE (start, Fmake_marker ()); |
430 p->line_cache_last_updated = Qzero; | 420 p->line_cache_last_updated = Qzero; |
431 | 421 |
432 p->windows_changed = 1; | 422 p->windows_changed = 1; |
433 p->shadow_thickness_changed = 1; | 423 p->shadow_thickness_changed = 1; |
434 | 424 |
435 return val; | 425 return obj; |
436 } | 426 } |
437 #undef INIT_DISP_VARIABLE | 427 #undef INIT_DISP_VARIABLE |
438 | 428 |
439 /************************************************************************/ | 429 /************************************************************************/ |
440 /* Window mirror structure */ | 430 /* Window mirror structure */ |
529 return wrap_window_mirror (mir->next); | 519 return wrap_window_mirror (mir->next); |
530 else | 520 else |
531 return Qnil; | 521 return Qnil; |
532 } | 522 } |
533 | 523 |
534 DEFINE_LRECORD_IMPLEMENTATION ("window-mirror", window_mirror, | 524 DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("window-mirror", window_mirror, |
535 0, /*dumpable-flag*/ | 525 mark_window_mirror, |
536 mark_window_mirror, internal_object_printer, | 526 window_mirror_description, |
537 0, 0, 0, window_mirror_description, | 527 struct window_mirror); |
538 struct window_mirror); | |
539 | 528 |
540 /* Create a new window mirror structure and associated redisplay | 529 /* Create a new window mirror structure and associated redisplay |
541 structs. */ | 530 structs. */ |
542 static struct window_mirror * | 531 static struct window_mirror * |
543 new_window_mirror (struct frame *f) | 532 new_window_mirror (struct frame *f) |
544 { | 533 { |
545 struct window_mirror *t = | 534 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (window_mirror); |
546 ALLOC_LCRECORD_TYPE (struct window_mirror, &lrecord_window_mirror); | 535 struct window_mirror *t = XWINDOW_MIRROR (obj); |
547 | 536 |
548 t->frame = f; | 537 t->frame = f; |
549 t->current_display_lines = Dynarr_new (display_line); | 538 t->current_display_lines = Dynarr_new (display_line); |
550 t->desired_display_lines = Dynarr_new (display_line); | 539 t->desired_display_lines = Dynarr_new (display_line); |
551 | 540 |
634 redisplay structures. */ | 623 redisplay structures. */ |
635 static struct window_mirror * | 624 static struct window_mirror * |
636 find_window_mirror_internal (Lisp_Object win, struct window_mirror *rmir, | 625 find_window_mirror_internal (Lisp_Object win, struct window_mirror *rmir, |
637 struct window *w) | 626 struct window *w) |
638 { | 627 { |
639 for (; !NILP (win); win = XWINDOW (win)->next, rmir = rmir->next) | 628 for (; !NILP (win) && rmir; win = XWINDOW (win)->next, rmir = rmir->next) |
640 { | 629 { |
641 if (w == XWINDOW (win)) | 630 if (w == XWINDOW (win)) |
642 return rmir; | 631 return rmir; |
643 | 632 |
644 if (!NILP (XWINDOW (win)->vchild)) | 633 if (!NILP (XWINDOW (win)->vchild)) |
685 #ifdef HAVE_SCROLLBARS | 674 #ifdef HAVE_SCROLLBARS |
686 release_window_mirror_scrollbars (mir); | 675 release_window_mirror_scrollbars (mir); |
687 #endif | 676 #endif |
688 free_display_structs (mir); | 677 free_display_structs (mir); |
689 mir = mir->next; | 678 mir = mir->next; |
690 /* not worth calling free_managed_lcrecord() -- window mirrors | 679 /* not worth calling free_normal_lisp_object() -- window mirrors |
691 are not created that frequently and it's dangerous. we don't | 680 are not created that frequently and it's dangerous. we don't |
692 know for sure that there aren't other pointers around -- e.g. | 681 know for sure that there aren't other pointers around -- e.g. |
693 in a scrollbar instance. */ | 682 in a scrollbar instance. */ |
694 } | 683 } |
695 } | 684 } |
700 real_window (struct window_mirror *mir, int no_abort) | 689 real_window (struct window_mirror *mir, int no_abort) |
701 { | 690 { |
702 Lisp_Object retval = | 691 Lisp_Object retval = |
703 real_window_internal (mir->frame->root_window, | 692 real_window_internal (mir->frame->root_window, |
704 XWINDOW_MIRROR (mir->frame->root_mirror), mir); | 693 XWINDOW_MIRROR (mir->frame->root_mirror), mir); |
705 if (NILP (retval) && !no_abort) | 694 assert (!NILP (retval) || no_abort); |
706 ABORT (); | |
707 | 695 |
708 return retval; | 696 return retval; |
709 } | 697 } |
710 | 698 |
711 /* Given a real window, return its mirror structure. Calls | 699 /* Given a real window, return its mirror structure. Calls |
714 find_window_mirror (struct window *w) | 702 find_window_mirror (struct window *w) |
715 { | 703 { |
716 struct frame *f = XFRAME (w->frame); | 704 struct frame *f = XFRAME (w->frame); |
717 if (f->mirror_dirty) | 705 if (f->mirror_dirty) |
718 update_frame_window_mirror (f); | 706 update_frame_window_mirror (f); |
707 return find_window_mirror_internal (f->root_window, | |
708 XWINDOW_MIRROR (f->root_mirror), w); | |
709 } | |
710 | |
711 /* Given a real window, return its mirror structure, if it exists. | |
712 Don't do any updating. */ | |
713 static struct window_mirror * | |
714 find_window_mirror_maybe (struct window *w) | |
715 { | |
716 struct frame *f = XFRAME (w->frame); | |
717 if (!WINDOW_MIRRORP (f->root_mirror)) | |
718 return 0; | |
719 return find_window_mirror_internal (f->root_window, | 719 return find_window_mirror_internal (f->root_window, |
720 XWINDOW_MIRROR (f->root_mirror), w); | 720 XWINDOW_MIRROR (f->root_mirror), w); |
721 } | 721 } |
722 | 722 |
723 /***************************************************************************** | 723 /***************************************************************************** |
760 display_line_dynarr * | 760 display_line_dynarr * |
761 window_display_lines (struct window *w, int which) | 761 window_display_lines (struct window *w, int which) |
762 { | 762 { |
763 struct window_mirror *t; | 763 struct window_mirror *t; |
764 | 764 |
765 if (XFRAME (w->frame)->mirror_dirty) | |
766 update_frame_window_mirror (XFRAME (w->frame)); | |
767 t = find_window_mirror (w); | 765 t = find_window_mirror (w); |
768 if (!t) | 766 assert (t); |
769 ABORT (); | |
770 | 767 |
771 if (which == CURRENT_DISP) | 768 if (which == CURRENT_DISP) |
772 return t->current_display_lines; | 769 return t->current_display_lines; |
773 else if (which == DESIRED_DISP) | 770 else if (which == DESIRED_DISP) |
774 return t->desired_display_lines; | 771 return t->desired_display_lines; |
784 struct buffer * | 781 struct buffer * |
785 window_display_buffer (struct window *w) | 782 window_display_buffer (struct window *w) |
786 { | 783 { |
787 struct window_mirror *t; | 784 struct window_mirror *t; |
788 | 785 |
789 if (XFRAME (w->frame)->mirror_dirty) | |
790 update_frame_window_mirror (XFRAME (w->frame)); | |
791 t = find_window_mirror (w); | 786 t = find_window_mirror (w); |
792 if (!t) | 787 assert (t); |
793 ABORT (); | |
794 | 788 |
795 return t->buffer; | 789 return t->buffer; |
796 } | 790 } |
797 | 791 |
798 void | 792 void |
799 set_window_display_buffer (struct window *w, struct buffer *b) | 793 set_window_display_buffer (struct window *w, struct buffer *b) |
800 { | 794 { |
801 struct window_mirror *t; | 795 struct window_mirror *t; |
802 | 796 |
803 if (XFRAME (w->frame)->mirror_dirty) | |
804 update_frame_window_mirror (XFRAME (w->frame)); | |
805 t = find_window_mirror (w); | 797 t = find_window_mirror (w); |
806 if (!t) | 798 assert (t); |
807 ABORT (); | |
808 | 799 |
809 t->buffer = b; | 800 t->buffer = b; |
810 } | 801 } |
811 | 802 |
812 | 803 |
1177 | 1168 |
1178 window = wrap_window (w); | 1169 window = wrap_window (w); |
1179 margin_cwidth = (left_margin ? XINT (w->left_margin_width) : | 1170 margin_cwidth = (left_margin ? XINT (w->left_margin_width) : |
1180 XINT (w->right_margin_width)); | 1171 XINT (w->right_margin_width)); |
1181 | 1172 |
1182 default_face_height_and_width (window, 0, &font_width); | 1173 default_face_width_and_height (window, &font_width, 0); |
1183 | 1174 |
1184 /* The left margin takes precedence over the right margin so we | 1175 /* The left margin takes precedence over the right margin so we |
1185 subtract its width from the space available for the right | 1176 subtract its width from the space available for the right |
1186 margin. */ | 1177 margin. */ |
1187 if (!left_margin) | 1178 if (!left_margin) |
1660 | 1651 |
1661 start = marker_position (w->start[CURRENT_DISP]); | 1652 start = marker_position (w->start[CURRENT_DISP]); |
1662 hlimit = WINDOW_TEXT_HEIGHT (w); | 1653 hlimit = WINDOW_TEXT_HEIGHT (w); |
1663 eobuf = BUF_ZV (XBUFFER (w->buffer)); | 1654 eobuf = BUF_ZV (XBUFFER (w->buffer)); |
1664 | 1655 |
1665 default_face_height_and_width (window, &defheight, NULL); | 1656 default_face_width_and_height (window, NULL, &defheight); |
1666 | 1657 |
1667 /* guess lines needed in line start cache + a few extra */ | 1658 /* guess lines needed in line start cache + a few extra */ |
1668 needed = (hlimit + defheight-1) / defheight + 3; | 1659 needed = (hlimit + defheight-1) / defheight + 3; |
1669 | 1660 |
1670 while (1) { | 1661 while (1) { |
1815 (window)) | 1806 (window)) |
1816 { | 1807 { |
1817 struct window *w = decode_window (window); | 1808 struct window *w = decode_window (window); |
1818 struct frame *f = XFRAME (w->frame); | 1809 struct frame *f = XFRAME (w->frame); |
1819 | 1810 |
1820 int left = | 1811 int left = w->pixel_left - FRAME_PANED_LEFT_EDGE (f); |
1821 w->pixel_left - FRAME_LEFT_BORDER_END (f) - FRAME_LEFT_GUTTER_BOUNDS (f); | 1812 int top = w->pixel_top - FRAME_PANED_TOP_EDGE (f); |
1822 int top = | |
1823 w->pixel_top - FRAME_TOP_BORDER_END (f) - FRAME_TOP_GUTTER_BOUNDS (f); | |
1824 | 1813 |
1825 return list4 (make_int (left), | 1814 return list4 (make_int (left), |
1826 make_int (top), | 1815 make_int (top), |
1827 make_int (left + w->pixel_width), | 1816 make_int (left + w->pixel_width), |
1828 make_int (top + w->pixel_height)); | 1817 make_int (top + w->pixel_height)); |
2022 unshow_buffer (struct window *w) | 2011 unshow_buffer (struct window *w) |
2023 { | 2012 { |
2024 Lisp_Object buf = w->buffer; | 2013 Lisp_Object buf = w->buffer; |
2025 struct buffer *b = XBUFFER (buf); | 2014 struct buffer *b = XBUFFER (buf); |
2026 | 2015 |
2027 if (b != XMARKER (w->pointm[CURRENT_DISP])->buffer) | 2016 assert (b == XMARKER (w->pointm[CURRENT_DISP])->buffer); |
2028 ABORT (); | |
2029 | 2017 |
2030 /* FSF disables this check, so I'll do it too. I hope it won't | 2018 /* FSF disables this check, so I'll do it too. I hope it won't |
2031 break things. --ben */ | 2019 break things. --ben */ |
2032 #if 0 | 2020 #if 0 |
2033 if (w == XWINDOW (Fselected_window (Qnil)) | 2021 if (w == XWINDOW (Fselected_window (Qnil)) |
2149 window_unmap_subwindows (w); | 2137 window_unmap_subwindows (w); |
2150 | 2138 |
2151 /* Free the extra data structures attached to windows immediately so | 2139 /* Free the extra data structures attached to windows immediately so |
2152 they don't sit around consuming excess space. They will be | 2140 they don't sit around consuming excess space. They will be |
2153 reinitialized by the window-configuration code as necessary. */ | 2141 reinitialized by the window-configuration code as necessary. */ |
2154 finalize_window ((void *) w, 0); | 2142 finalize_window (wrap_window (w)); |
2155 | 2143 |
2156 /* Nobody should be accessing anything in this object any more, | 2144 /* Nobody should be accessing anything in this object any more, |
2157 and making them Qnil allows for better GC'ing in case a pointer | 2145 and making them Qnil allows for better GC'ing in case a pointer |
2158 to the dead window continues to hang around. Zero all other | 2146 to the dead window continues to hang around. Zero all other |
2159 structs in case someone tries to access something through them. | 2147 structs in case someone tries to access something through them. |
3136 | 3124 |
3137 /* If none of them, then all windows, dedicated or not. */ | 3125 /* If none of them, then all windows, dedicated or not. */ |
3138 w = window_loop (GET_LRU_WINDOW, Qnil, 0, which_frames, 1, which_devices); | 3126 w = window_loop (GET_LRU_WINDOW, Qnil, 0, which_frames, 1, which_devices); |
3139 | 3127 |
3140 /* At this point we damn well better have found something. */ | 3128 /* At this point we damn well better have found something. */ |
3141 if (NILP (w)) ABORT (); | 3129 assert (!NILP (w)); |
3142 #endif | 3130 #endif |
3143 | 3131 |
3144 return w; | 3132 return w; |
3145 } | 3133 } |
3146 | 3134 |
3480 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1); | 3468 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1); |
3481 } | 3469 } |
3482 | 3470 |
3483 /* Return non-zero if both frame sizes are less than or equal to | 3471 /* Return non-zero if both frame sizes are less than or equal to |
3484 minimal allowed values. ROWS and COLS are in characters */ | 3472 minimal allowed values. ROWS and COLS are in characters */ |
3485 int | 3473 static int |
3486 frame_size_valid_p (struct frame *frame, int rows, int cols) | 3474 frame_size_valid_p (struct frame *frame, int cols, int rows) |
3487 { | 3475 { |
3488 return (rows >= frame_min_height (frame) | 3476 return (rows >= frame_min_height (frame) |
3489 && cols >= MIN_SAFE_WINDOW_WIDTH); | 3477 && cols >= MIN_SAFE_WINDOW_WIDTH); |
3490 } | 3478 } |
3491 | 3479 |
3493 minimal allowed values. WIDTH and HEIGHT are in pixels */ | 3481 minimal allowed values. WIDTH and HEIGHT are in pixels */ |
3494 int | 3482 int |
3495 frame_pixsize_valid_p (struct frame *frame, int width, int height) | 3483 frame_pixsize_valid_p (struct frame *frame, int width, int height) |
3496 { | 3484 { |
3497 int rows, cols; | 3485 int rows, cols; |
3498 pixel_to_real_char_size (frame, width, height, &cols, &rows); | 3486 pixel_to_char_size (frame, width, height, &cols, &rows); |
3499 return frame_size_valid_p (frame, rows, cols); | 3487 return frame_size_valid_p (frame, cols, rows); |
3500 } | 3488 } |
3501 | 3489 |
3502 /* If *ROWS or *COLS are too small a size for FRAME, set them to the | 3490 /* If *ROWS or *COLS are too small a size for FRAME, set them to the |
3503 minimum allowable size. */ | 3491 minimum allowable size. */ |
3504 void | 3492 void |
3505 check_frame_size (struct frame *frame, int *rows, int *cols) | 3493 check_frame_size (struct frame *frame, int *cols, int *rows) |
3506 { | 3494 { |
3507 int min_height = frame_min_height (frame); | 3495 int min_height = frame_min_height (frame); |
3508 | 3496 int min_pixwidth, min_pixheight; |
3509 if (*rows < min_height) | 3497 int min_geomwidth, min_geomheight; |
3510 *rows = min_height; | 3498 |
3511 if (*cols < MIN_SAFE_WINDOW_WIDTH) | 3499 /* There is no char_to_frame_unit_size(). This can be done with |
3512 *cols = MIN_SAFE_WINDOW_WIDTH; | 3500 frame_conversion_internal(), but that's currently static, and we can |
3501 do it fine with two steps, as follows. */ | |
3502 char_to_pixel_size (frame, MIN_SAFE_WINDOW_WIDTH, min_height, | |
3503 &min_pixwidth, &min_pixheight); | |
3504 pixel_to_frame_unit_size (frame, min_pixwidth, min_pixheight, | |
3505 &min_geomwidth, &min_geomheight); | |
3506 if (*rows < min_geomheight) | |
3507 *rows = min_geomheight; | |
3508 if (*cols < min_geomwidth) | |
3509 *cols = min_geomwidth; | |
3513 } | 3510 } |
3514 | 3511 |
3515 /* Normally the window is deleted if it gets too small. | 3512 /* Normally the window is deleted if it gets too small. |
3516 nodelete nonzero means do not do this. | 3513 nodelete nonzero means do not do this. |
3517 (The caller should check later and do so if appropriate) */ | 3514 (The caller should check later and do so if appropriate) */ |
3526 Lisp_Object child, minor_kid, major_kid; | 3523 Lisp_Object child, minor_kid, major_kid; |
3527 int minsize; | 3524 int minsize; |
3528 int line_size; | 3525 int line_size; |
3529 int defheight, defwidth; | 3526 int defheight, defwidth; |
3530 | 3527 |
3531 default_face_height_and_width (window, &defheight, &defwidth); | 3528 default_face_width_and_height (window, &defwidth, &defheight); |
3532 line_size = (set_height ? defheight : defwidth); | 3529 line_size = (set_height ? defheight : defwidth); |
3533 | 3530 |
3534 check_min_window_sizes (); | 3531 check_min_window_sizes (); |
3535 | 3532 |
3536 minsize = (set_height ? window_min_height : window_min_width); | 3533 minsize = (set_height ? window_min_height : window_min_width); |
3756 if (NILP (norecord)) | 3753 if (NILP (norecord)) |
3757 Frecord_buffer (buffer); | 3754 Frecord_buffer (buffer); |
3758 | 3755 |
3759 Fset_buffer (buffer); | 3756 Fset_buffer (buffer); |
3760 } | 3757 } |
3758 if (NILP (XBUFFER (buffer)->display_count)) | |
3759 XBUFFER (buffer)->display_count = make_int (1); | |
3760 else | |
3761 XBUFFER (buffer)->display_count = make_int (1 + XINT (XBUFFER (buffer)->display_count)); | |
3762 XBUFFER (buffer)->display_time = Fcurrent_time(); | |
3761 return Qnil; | 3763 return Qnil; |
3762 } | 3764 } |
3763 | 3765 |
3764 DEFUN ("select-window", Fselect_window, 1, 2, 0, /* | 3766 DEFUN ("select-window", Fselect_window, 1, 2, 0, /* |
3765 Select WINDOW. Most editing will apply to WINDOW's buffer. | 3767 Select WINDOW. Most editing will apply to WINDOW's buffer. |
3868 } | 3870 } |
3869 | 3871 |
3870 static void | 3872 static void |
3871 make_dummy_parent (Lisp_Object window) | 3873 make_dummy_parent (Lisp_Object window) |
3872 { | 3874 { |
3873 Lisp_Object new_; | |
3874 struct window *o = XWINDOW (window); | 3875 struct window *o = XWINDOW (window); |
3875 struct window *p = ALLOC_LCRECORD_TYPE (struct window, &lrecord_window); | 3876 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (window); |
3876 | 3877 struct window *p = XWINDOW (obj); |
3877 new_ = wrap_window (p); | 3878 |
3878 COPY_LCRECORD (p, o); | 3879 copy_lisp_object (obj, window); |
3879 | 3880 |
3880 /* Don't copy the pointers to the line start cache or the face | 3881 /* Don't copy the pointers to the line start cache or the face |
3881 instances. */ | 3882 instances. */ |
3882 p->line_start_cache = Dynarr_new (line_start_cache); | 3883 p->line_start_cache = Dynarr_new (line_start_cache); |
3883 #ifdef NEW_GC | 3884 #ifdef NEW_GC |
3893 #endif /* not NEW_GC */ | 3894 #endif /* not NEW_GC */ |
3894 p->subwindow_instance_cache = | 3895 p->subwindow_instance_cache = |
3895 make_image_instance_cache_hash_table (); | 3896 make_image_instance_cache_hash_table (); |
3896 | 3897 |
3897 /* Put new into window structure in place of window */ | 3898 /* Put new into window structure in place of window */ |
3898 replace_window (window, new_); | 3899 replace_window (window, obj); |
3899 | 3900 |
3900 o->next = Qnil; | 3901 o->next = Qnil; |
3901 o->prev = Qnil; | 3902 o->prev = Qnil; |
3902 o->vchild = Qnil; | 3903 o->vchild = Qnil; |
3903 o->hchild = Qnil; | 3904 o->hchild = Qnil; |
3904 o->parent = new_; | 3905 o->parent = obj; |
3905 | 3906 |
3906 p->start[CURRENT_DISP] = Qnil; | 3907 p->start[CURRENT_DISP] = Qnil; |
3907 p->start[DESIRED_DISP] = Qnil; | 3908 p->start[DESIRED_DISP] = Qnil; |
3908 p->start[CMOTION_DISP] = Qnil; | 3909 p->start[CMOTION_DISP] = Qnil; |
3909 p->pointm[CURRENT_DISP] = Qnil; | 3910 p->pointm[CURRENT_DISP] = Qnil; |
4130 avail_height = (pixel_height - | 4131 avail_height = (pixel_height - |
4131 (include_gutters_p ? 0 : | 4132 (include_gutters_p ? 0 : |
4132 window_top_window_gutter_height (w) + | 4133 window_top_window_gutter_height (w) + |
4133 window_bottom_window_gutter_height (w))); | 4134 window_bottom_window_gutter_height (w))); |
4134 | 4135 |
4135 default_face_height_and_width (window, &defheight, &defwidth); | 4136 default_face_width_and_height (window, &defwidth, &defheight); |
4136 | 4137 |
4137 if (defheight) | 4138 if (defheight) |
4138 char_height = avail_height / defheight; | 4139 char_height = avail_height / defheight; |
4139 | 4140 |
4140 /* It's the calling function's responsibility to check these values | 4141 /* It's the calling function's responsibility to check these values |
4154 int pixel_height; | 4155 int pixel_height; |
4155 | 4156 |
4156 Lisp_Object window = wrap_window (w); | 4157 Lisp_Object window = wrap_window (w); |
4157 | 4158 |
4158 | 4159 |
4159 default_face_height_and_width (window, &defheight, &defwidth); | 4160 default_face_width_and_height (window, &defwidth, &defheight); |
4160 | 4161 |
4161 avail_height = char_height * defheight; | 4162 avail_height = char_height * defheight; |
4162 pixel_height = (avail_height + | 4163 pixel_height = (avail_height + |
4163 (include_gutters_p ? 0 : | 4164 (include_gutters_p ? 0 : |
4164 window_top_window_gutter_height (w) + | 4165 window_top_window_gutter_height (w) + |
4234 return num_lines - 1; | 4235 return num_lines - 1; |
4235 ypos1 = dl->ypos + dl->descent - dl->clip; | 4236 ypos1 = dl->ypos + dl->descent - dl->clip; |
4236 } | 4237 } |
4237 } | 4238 } |
4238 | 4239 |
4239 default_face_height_and_width (window, &defheight, &defwidth); | 4240 default_face_width_and_height (window, &defwidth, &defheight); |
4240 /* #### This probably needs to know about the clipping area once a | 4241 /* #### This probably needs to know about the clipping area once a |
4241 final definition is decided on. */ | 4242 final definition is decided on. */ |
4242 if (defheight) | 4243 if (defheight) |
4243 num_lines += ((ypos2 - ypos1) / defheight); | 4244 num_lines += ((ypos2 - ypos1) / defheight); |
4244 } | 4245 } |
4277 window_left_gutter_width (w, 0) - | 4278 window_left_gutter_width (w, 0) - |
4278 window_right_gutter_width (w, 0) - | 4279 window_right_gutter_width (w, 0) - |
4279 (include_margins_p ? 0 : window_left_margin_width (w)) - | 4280 (include_margins_p ? 0 : window_left_margin_width (w)) - |
4280 (include_margins_p ? 0 : window_right_margin_width (w))); | 4281 (include_margins_p ? 0 : window_right_margin_width (w))); |
4281 | 4282 |
4282 default_face_height_and_width (window, &defheight, &defwidth); | 4283 default_face_width_and_height (window, &defwidth, &defheight); |
4283 | 4284 |
4284 if (defwidth) | 4285 if (defwidth) |
4285 char_width = (avail_width / defwidth); | 4286 char_width = (avail_width / defwidth); |
4286 | 4287 |
4287 /* It's the calling function's responsibility to check these values | 4288 /* It's the calling function's responsibility to check these values |
4300 int pixel_width; | 4301 int pixel_width; |
4301 int defheight, defwidth; | 4302 int defheight, defwidth; |
4302 Lisp_Object window = wrap_window (w); | 4303 Lisp_Object window = wrap_window (w); |
4303 | 4304 |
4304 | 4305 |
4305 default_face_height_and_width (window, &defheight, &defwidth); | 4306 default_face_width_and_height (window, &defwidth, &defheight); |
4306 | 4307 |
4307 avail_width = char_width * defwidth; | 4308 avail_width = char_width * defwidth; |
4308 pixel_width = (avail_width + | 4309 pixel_width = (avail_width + |
4309 window_left_window_gutter_width (w, 0) + | 4310 window_left_window_gutter_width (w, 0) + |
4310 window_right_window_gutter_width (w, 0) + | 4311 window_right_window_gutter_width (w, 0) + |
4383 window = wrap_window (win); | 4384 window = wrap_window (win); |
4384 f = XFRAME (win->frame); | 4385 f = XFRAME (win->frame); |
4385 if (EQ (window, FRAME_ROOT_WINDOW (f))) | 4386 if (EQ (window, FRAME_ROOT_WINDOW (f))) |
4386 invalid_operation ("Won't change only window", Qunbound); | 4387 invalid_operation ("Won't change only window", Qunbound); |
4387 | 4388 |
4388 default_face_height_and_width (window, &defheight, &defwidth); | 4389 default_face_width_and_height (window, &defwidth, &defheight); |
4389 | 4390 |
4390 while (1) | 4391 while (1) |
4391 { | 4392 { |
4392 w = XWINDOW (window); | 4393 w = XWINDOW (window); |
4393 parent = w->parent; | 4394 parent = w->parent; |
4612 dla = window_display_lines (w, CURRENT_DISP); | 4613 dla = window_display_lines (w, CURRENT_DISP); |
4613 | 4614 |
4614 if (INTP (Vwindow_pixel_scroll_increment)) | 4615 if (INTP (Vwindow_pixel_scroll_increment)) |
4615 fheight = XINT (Vwindow_pixel_scroll_increment); | 4616 fheight = XINT (Vwindow_pixel_scroll_increment); |
4616 else if (!NILP (Vwindow_pixel_scroll_increment)) | 4617 else if (!NILP (Vwindow_pixel_scroll_increment)) |
4617 default_face_height_and_width (window, &fheight, &fwidth); | 4618 default_face_width_and_height (window, &fwidth, &fheight); |
4618 | 4619 |
4619 if (Dynarr_length (dla) >= 1) | 4620 if (Dynarr_length (dla) >= 1) |
4620 modeline = Dynarr_begin (dla)->modeline; | 4621 modeline = Dynarr_begin (dla)->modeline; |
4621 | 4622 |
4622 dl = Dynarr_atp (dla, modeline); | 4623 dl = Dynarr_atp (dla, modeline); |
5162 MARK_WINDOWS_CHANGED (w); | 5163 MARK_WINDOWS_CHANGED (w); |
5163 } | 5164 } |
5164 | 5165 |
5165 #ifdef MEMORY_USAGE_STATS | 5166 #ifdef MEMORY_USAGE_STATS |
5166 | 5167 |
5168 struct window_mirror_stats | |
5169 { | |
5170 struct usage_stats u; | |
5171 /* Ancillary non-lisp */ | |
5172 Bytecount redisplay_structs; | |
5173 #ifdef HAVE_SCROLLBARS | |
5174 /* Ancillary Lisp */ | |
5175 Bytecount scrollbar; | |
5176 #endif | |
5177 }; | |
5178 | |
5167 struct window_stats | 5179 struct window_stats |
5168 { | 5180 { |
5169 int face; | 5181 struct usage_stats u; |
5170 int glyph; | 5182 /* Ancillary non-Lisp */ |
5183 Bytecount line_start; | |
5184 /* The next two: ancillary non-Lisp under old-GC, ancillary Lisp under | |
5185 NEW_GC */ | |
5186 Bytecount face; | |
5187 Bytecount glyph; | |
5188 /* The next two are copied out of the window mirror, which is an ancillary | |
5189 Lisp structure; the first is non-Lisp, the second Lisp, but from our | |
5190 perspective, they are both counted as Lisp */ | |
5191 Bytecount redisplay_structs; | |
5171 #ifdef HAVE_SCROLLBARS | 5192 #ifdef HAVE_SCROLLBARS |
5172 int scrollbar; | 5193 Bytecount scrollbar; |
5173 #endif | 5194 #endif |
5174 int line_start; | 5195 /* Remaining memory associated with window mirror (ancillary Lisp) */ |
5175 int other_redisplay; | 5196 Bytecount window_mirror; |
5176 int other; | |
5177 }; | 5197 }; |
5178 | 5198 |
5179 static void | 5199 static void |
5180 compute_window_mirror_usage (struct window_mirror *mir, | 5200 compute_window_mirror_usage (struct window_mirror *mir, |
5181 struct window_stats *stats, | 5201 struct window_mirror_stats *stats) |
5182 struct overhead_stats *ovstats) | 5202 { |
5183 { | 5203 stats->redisplay_structs = |
5184 if (!mir) | 5204 compute_display_line_dynarr_usage (mir->current_display_lines, &stats->u) |
5185 return; | 5205 + |
5186 stats->other += LISPOBJ_STORAGE_SIZE (mir, sizeof (*mir), ovstats); | 5206 compute_display_line_dynarr_usage (mir->desired_display_lines, &stats->u); |
5187 #ifdef HAVE_SCROLLBARS | 5207 #ifdef HAVE_SCROLLBARS |
5188 { | 5208 stats->scrollbar = |
5189 struct device *d = XDEVICE (FRAME_DEVICE (mir->frame)); | 5209 compute_all_scrollbar_instance_usage (mir->scrollbar_vertical_instance) + |
5190 | 5210 compute_all_scrollbar_instance_usage (mir->scrollbar_horizontal_instance); |
5191 stats->scrollbar += | |
5192 compute_scrollbar_instance_usage (d, mir->scrollbar_vertical_instance, | |
5193 ovstats); | |
5194 stats->scrollbar += | |
5195 compute_scrollbar_instance_usage (d, mir->scrollbar_horizontal_instance, | |
5196 ovstats); | |
5197 } | |
5198 #endif /* HAVE_SCROLLBARS */ | 5211 #endif /* HAVE_SCROLLBARS */ |
5199 stats->other_redisplay += | 5212 } |
5200 compute_display_line_dynarr_usage (mir->current_display_lines, ovstats); | 5213 |
5201 stats->other_redisplay += | 5214 |
5202 compute_display_line_dynarr_usage (mir->desired_display_lines, ovstats); | 5215 static void |
5216 window_mirror_memory_usage (Lisp_Object window_mirror, | |
5217 struct generic_usage_stats *gustats) | |
5218 { | |
5219 struct window_mirror_stats *stats = (struct window_mirror_stats *) gustats; | |
5220 | |
5221 compute_window_mirror_usage (XWINDOW_MIRROR (window_mirror), stats); | |
5203 } | 5222 } |
5204 | 5223 |
5205 static void | 5224 static void |
5206 compute_window_usage (struct window *w, struct window_stats *stats, | 5225 compute_window_usage (struct window *w, struct window_stats *stats, |
5207 struct overhead_stats *ovstats) | 5226 struct usage_stats *ustats) |
5208 { | 5227 { |
5209 xzero (*stats); | 5228 stats->line_start = |
5210 stats->other += LISPOBJ_STORAGE_SIZE (w, sizeof (*w), ovstats); | 5229 compute_line_start_cache_dynarr_usage (w->line_start_cache, ustats); |
5211 stats->face += compute_face_cachel_usage (w->face_cachels, ovstats); | 5230 stats->face = compute_face_cachel_usage (w->face_cachels, |
5212 stats->glyph += compute_glyph_cachel_usage (w->glyph_cachels, ovstats); | 5231 ustats); |
5213 stats->line_start += | 5232 stats->glyph = compute_glyph_cachel_usage (w->glyph_cachels, |
5214 compute_line_start_cache_dynarr_usage (w->line_start_cache, ovstats); | 5233 ustats); |
5215 compute_window_mirror_usage (find_window_mirror (w), stats, ovstats); | 5234 { |
5216 } | 5235 struct window_mirror *wm; |
5217 | 5236 |
5218 DEFUN ("window-memory-usage", Fwindow_memory_usage, 1, 1, 0, /* | 5237 wm = find_window_mirror_maybe (w); |
5219 Return stats about the memory usage of window WINDOW. | 5238 if (wm) |
5220 The values returned are in the form of an alist of usage types and byte | 5239 { |
5221 counts. The byte counts attempt to encompass all the memory used | 5240 struct generic_usage_stats gustats; |
5222 by the window (separate from the memory logically associated with a | 5241 struct window_mirror_stats *wmstats; |
5223 buffer or frame), including internal structures and any malloc() | 5242 Bytecount total; |
5224 overhead associated with them. In practice, the byte counts are | 5243 total = lisp_object_memory_usage_full (wrap_window_mirror (wm), |
5225 underestimated because certain memory usage is very hard to determine | 5244 NULL, NULL, NULL, &gustats); |
5226 \(e.g. the amount of memory used inside the Xt library or inside the | 5245 wmstats = (struct window_mirror_stats *) &gustats; |
5227 X server) and because there is other stuff that might logically | 5246 stats->redisplay_structs = wmstats->redisplay_structs; |
5228 be associated with a window, buffer, or frame (e.g. window configurations, | 5247 total -= stats->redisplay_structs; |
5229 glyphs) but should not obviously be included in the usage counts. | |
5230 | |
5231 Multiple slices of the total memory usage may be returned, separated | |
5232 by a nil. Each slice represents a particular view of the memory, a | |
5233 particular way of partitioning it into groups. Within a slice, there | |
5234 is no overlap between the groups of memory, and each slice collectively | |
5235 represents all the memory concerned. | |
5236 */ | |
5237 (window)) | |
5238 { | |
5239 struct window_stats stats; | |
5240 struct overhead_stats ovstats; | |
5241 Lisp_Object val = Qnil; | |
5242 | |
5243 CHECK_WINDOW (window); /* dead windows should be allowed, no? */ | |
5244 xzero (ovstats); | |
5245 compute_window_usage (XWINDOW (window), &stats, &ovstats); | |
5246 | |
5247 val = acons (Qface_cache, make_int (stats.face), val); | |
5248 val = acons (Qglyph_cache, make_int (stats.glyph), val); | |
5249 #ifdef HAVE_SCROLLBARS | 5248 #ifdef HAVE_SCROLLBARS |
5250 val = acons (Qscrollbar_instances, make_int (stats.scrollbar), val); | 5249 stats->scrollbar = wmstats->scrollbar; |
5250 total -= stats->scrollbar; | |
5251 #endif | 5251 #endif |
5252 val = acons (Qline_start_cache, make_int (stats.line_start), val); | 5252 stats->window_mirror = total; |
5253 val = acons (Qother_redisplay, make_int (stats.other_redisplay), val); | 5253 } |
5254 val = acons (Qother, make_int (stats.other), val); | 5254 } |
5255 val = Fcons (Qnil, val); | 5255 } |
5256 val = acons (Qactually_requested, make_int (ovstats.was_requested), val); | 5256 |
5257 val = acons (Qmalloc_overhead, make_int (ovstats.malloc_overhead), val); | 5257 static void |
5258 val = acons (Qdynarr_overhead, make_int (ovstats.dynarr_overhead), val); | 5258 window_memory_usage (Lisp_Object window, struct generic_usage_stats *gustats) |
5259 | 5259 { |
5260 return Fnreverse (val); | 5260 struct window_stats *stats = (struct window_stats *) gustats; |
5261 | |
5262 compute_window_usage (XWINDOW (window), stats, &stats->u); | |
5261 } | 5263 } |
5262 | 5264 |
5263 #endif /* MEMORY_USAGE_STATS */ | 5265 #endif /* MEMORY_USAGE_STATS */ |
5266 | |
5267 | |
5264 | 5268 |
5265 /* Mark all subwindows of a window as deleted. The argument | 5269 /* Mark all subwindows of a window as deleted. The argument |
5266 W is actually the subwindow tree of the window in question. */ | 5270 W is actually the subwindow tree of the window in question. */ |
5267 | 5271 |
5268 void | 5272 void |
5412 { | 5416 { |
5413 Lisp_Object buffer = XWINDOW (window)->buffer; | 5417 Lisp_Object buffer = XWINDOW (window)->buffer; |
5414 if (!NILP (buffer) && BUFFERP (buffer)) | 5418 if (!NILP (buffer) && BUFFERP (buffer)) |
5415 stderr_out (" on %s", XSTRING_DATA (XBUFFER (buffer)->name)); | 5419 stderr_out (" on %s", XSTRING_DATA (XBUFFER (buffer)->name)); |
5416 } | 5420 } |
5417 stderr_out (" 0x%x>", XWINDOW (window)->header.uid); | 5421 stderr_out (" 0x%x>", LISP_OBJECT_UID (window)); |
5418 | 5422 |
5419 while (!NILP (child)) | 5423 while (!NILP (child)) |
5420 { | 5424 { |
5421 debug_print_window (child, level + 1); | 5425 debug_print_window (child, level + 1); |
5422 child = Fwindow_next_child (child); | 5426 child = Fwindow_next_child (child); |
5436 /************************************************************************/ | 5440 /************************************************************************/ |
5437 /* initialization */ | 5441 /* initialization */ |
5438 /************************************************************************/ | 5442 /************************************************************************/ |
5439 | 5443 |
5440 void | 5444 void |
5445 window_objects_create (void) | |
5446 { | |
5447 #ifdef MEMORY_USAGE_STATS | |
5448 OBJECT_HAS_METHOD (window, memory_usage); | |
5449 OBJECT_HAS_METHOD (window_mirror, memory_usage); | |
5450 #endif | |
5451 } | |
5452 | |
5453 void | |
5441 syms_of_window (void) | 5454 syms_of_window (void) |
5442 { | 5455 { |
5443 INIT_LRECORD_IMPLEMENTATION (window); | 5456 INIT_LISP_OBJECT (window); |
5444 INIT_LRECORD_IMPLEMENTATION (window_mirror); | 5457 INIT_LISP_OBJECT (window_mirror); |
5445 #ifdef NEW_GC | 5458 #ifdef NEW_GC |
5446 INIT_LRECORD_IMPLEMENTATION (face_cachel); | 5459 INIT_LISP_OBJECT (face_cachel); |
5447 INIT_LRECORD_IMPLEMENTATION (face_cachel_dynarr); | 5460 INIT_LISP_OBJECT (face_cachel_dynarr); |
5448 INIT_LRECORD_IMPLEMENTATION (glyph_cachel); | 5461 INIT_LISP_OBJECT (glyph_cachel); |
5449 INIT_LRECORD_IMPLEMENTATION (glyph_cachel_dynarr); | 5462 INIT_LISP_OBJECT (glyph_cachel_dynarr); |
5450 #endif /* NEW_GC */ | 5463 #endif /* NEW_GC */ |
5451 | 5464 |
5452 DEFSYMBOL (Qwindowp); | 5465 DEFSYMBOL (Qwindowp); |
5453 DEFSYMBOL (Qwindow_live_p); | 5466 DEFSYMBOL (Qwindow_live_p); |
5454 DEFSYMBOL (Qdisplay_buffer); | 5467 DEFSYMBOL (Qdisplay_buffer); |
5458 DEFSYMBOL (Qglyph_cache); | 5471 DEFSYMBOL (Qglyph_cache); |
5459 DEFSYMBOL (Qline_start_cache); | 5472 DEFSYMBOL (Qline_start_cache); |
5460 #ifdef HAVE_SCROLLBARS | 5473 #ifdef HAVE_SCROLLBARS |
5461 DEFSYMBOL (Qscrollbar_instances); | 5474 DEFSYMBOL (Qscrollbar_instances); |
5462 #endif | 5475 #endif |
5463 DEFSYMBOL (Qother_redisplay); | 5476 DEFSYMBOL (Qredisplay_structs); |
5464 /* Qother in general.c */ | |
5465 #endif | 5477 #endif |
5466 | 5478 |
5467 DEFSYMBOL (Qtruncate_partial_width_windows); | 5479 DEFSYMBOL (Qtruncate_partial_width_windows); |
5468 DEFSYMBOL (Qcurrent_window_configuration); | 5480 DEFSYMBOL (Qcurrent_window_configuration); |
5469 DEFSYMBOL (Qset_window_configuration); | 5481 DEFSYMBOL (Qset_window_configuration); |
5537 DEFSUBR (Fscroll_right); | 5549 DEFSUBR (Fscroll_right); |
5538 DEFSUBR (Fother_window_for_scrolling); | 5550 DEFSUBR (Fother_window_for_scrolling); |
5539 DEFSUBR (Fscroll_other_window); | 5551 DEFSUBR (Fscroll_other_window); |
5540 DEFSUBR (Fcenter_to_window_line); | 5552 DEFSUBR (Fcenter_to_window_line); |
5541 DEFSUBR (Fmove_to_window_line); | 5553 DEFSUBR (Fmove_to_window_line); |
5542 #ifdef MEMORY_USAGE_STATS | |
5543 DEFSUBR (Fwindow_memory_usage); | |
5544 #endif | |
5545 DEFSUBR (Fcurrent_pixel_column); | 5554 DEFSUBR (Fcurrent_pixel_column); |
5546 DEFSUBR (Fcurrent_pixel_row); | 5555 DEFSUBR (Fcurrent_pixel_row); |
5547 } | 5556 } |
5548 | 5557 |
5549 void | 5558 void |
5555 } | 5564 } |
5556 | 5565 |
5557 void | 5566 void |
5558 vars_of_window (void) | 5567 vars_of_window (void) |
5559 { | 5568 { |
5569 #ifdef MEMORY_USAGE_STATS | |
5570 Lisp_Object l; | |
5571 | |
5572 l = listu (Qline_start_cache, | |
5573 #ifdef NEW_GC | |
5574 Qt, | |
5575 #endif | |
5576 Qface_cache, Qglyph_cache, | |
5577 #ifndef NEW_GC | |
5578 Qt, | |
5579 #endif | |
5580 Qredisplay_structs, | |
5581 #ifdef HAVE_SCROLLBARS | |
5582 Qscrollbar_instances, | |
5583 #endif | |
5584 intern ("window-mirror"), | |
5585 Qunbound); | |
5586 | |
5587 OBJECT_HAS_PROPERTY (window, memusage_stats_list, l); | |
5588 | |
5589 l = listu (Qredisplay_structs, | |
5590 #ifdef HAVE_SCROLLBARS | |
5591 Qt, Qscrollbar_instances, | |
5592 #endif | |
5593 Qunbound); | |
5594 OBJECT_HAS_PROPERTY (window_mirror, memusage_stats_list, l); | |
5595 #endif /* MEMORY_USAGE_STATS */ | |
5596 | |
5560 DEFVAR_BOOL ("scroll-on-clipped-lines", &scroll_on_clipped_lines /* | 5597 DEFVAR_BOOL ("scroll-on-clipped-lines", &scroll_on_clipped_lines /* |
5561 *Non-nil means to scroll if point lands on a line which is clipped. | 5598 *Non-nil means to scroll if point lands on a line which is clipped. |
5562 */ ); | 5599 */ ); |
5563 scroll_on_clipped_lines = 1; | 5600 scroll_on_clipped_lines = 1; |
5564 | 5601 |