comparison src/redisplay-msw.c @ 1318:b531bf8658e9

[xemacs-hg @ 2003-02-21 06:56:46 by ben] redisplay fixes et al. PROBLEMS: Add comment about Cygwin, unexec and sysmalloc. Move some non-general stuff out of general. Make a section for x86. configure.in: Add check for broken alloca in funcalls. mule/mule-cmds.el: Alias file-name to native not vice-versa. Do set EOL of native but not of process output to fix various problems and be consistent with code-init.el. code-cmds.el: Return a name not a coding system. code-init.el: Reindent. Remove `file-name' since it should always be the same as native. unicode.el: Rename to load-unicode-mapping-table as suggested by the anonymous (but rather Turnbullian) comment in unicode.c. xemacs.dsp: Add /k to default build. alloc.c: Make gc_currently_forbidden static. config.h.in, lisp.h: Move some stuff to lisp.h. console-gtk.h, console-impl.h, console-msw.h, console-x.h, event-Xt.c, event-msw.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-x.c, gtk-xemacs.c: Remove duplicated code to redraw exposed area. Add deadbox method needed by the generalized redraw code. Defer redrawing if already in redisplay. frame-msw.c, event-stream.c, frame.c: Add comments about calling Lisp. debug.c, general-slots.h: Move generalish symbols to general-slots.h. doprnt.c: reindent. lisp.h, dynarr.c: Add debug code for locking a dynarr to catch invalid mods. Use in redisplay.c. eval.c: file-coding.c: Define file-name as alias for native not vice-versa. frame-gtk.c, frame-x.c: Move Qwindow_id to general-slots. dialog-msw.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, gui.c, gui.h, menubar-msw.c, menubar.c: Ensure that various glyph functions that eval within redisplay protect the evals. Same for calls to internal_equal(). Modify various functions, e.g. gui_item_*(), to protect evals within redisplay, taking an in_redisplay parameter if it's possible for them to be called both inside and outside of redisplay. gutter.c: Defer specifier-changed updating till after redisplay, if necessary, since we need to enter redisplay to do it. gutter.c: Do nothing if in redisplay. lisp.h: Add version of alloca() for use in function calls. lisp.h: Add XCAD[D+]R up to 6 D's, and aliases X1ST, X2ND, etc. frame.c, frame.h, redisplay.c, redisplay.h, signal.c, toolbar.c: Redo critical-section code and move from frame.c to redisplay.c. Require that every place inside of redisplay catch errors itself, not at the edge of the critical section (thereby bypassing the rest of redisplay and leaving things in an inconsistent state). Introduce separate means of holding frame-size changes without entering a complete critical section. Introduce "post-redisplay" methods for deferring things till after redisplay. Abort if we enter redisplay reentrantly. Disable all quit checking in redisplay since it's too dangerous. Ensure that all calls to QUIT trigger an abort if unprotected. redisplay.c, scrollbar-gtk.c, scrollbar-x.c, scrollbar.c: Create enter/exit_redisplay_critical_section_maybe() for code that needs to ensure it's in a critical section but doesn't interfere with an existing critical section. sysdep.c: Use _wexecve() when under Windows NT for Unicode correctness. text.c, text.h: Add new_dfc() functions, which return an alloca()ed value rather than requiring an lvalue. (Not really used yet; used in another workspace, to come.) Add some macros for SIZED_EXTERNAL. Update the encoding aliases after involved scrutinization of the X manual. unicode.c: Answer the anonymous but suspiciously Turnbullian questions. Rename parse-unicode-translation-table to load-unicode-mapping-table, as suggested.
author ben
date Fri, 21 Feb 2003 06:57:21 +0000
parents 79c6ff3eef26
children 04bc9d2f42c7
comparison
equal deleted inserted replaced
1317:d9d08dc5e617 1318:b531bf8658e9
1 /* mswindows output and frame manipulation routines. 1 /* mswindows output and frame manipulation routines.
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. 2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
3 Copyright (C) 1994 Lucid, Inc. 3 Copyright (C) 1994 Lucid, Inc.
4 Copyright (C) 1995 Sun Microsystems, Inc. 4 Copyright (C) 1995 Sun Microsystems, Inc.
5 Copyright (C) 2001, 2002 Ben Wing. 5 Copyright (C) 2001, 2002, 2003 Ben Wing.
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
61 static void mswindows_update_dc (HDC hdc, Lisp_Object fg, Lisp_Object bg, 61 static void mswindows_update_dc (HDC hdc, Lisp_Object fg, Lisp_Object bg,
62 Lisp_Object bg_pmap); 62 Lisp_Object bg_pmap);
63 static void mswindows_set_dc_font (HDC hdc, Lisp_Object font, 63 static void mswindows_set_dc_font (HDC hdc, Lisp_Object font,
64 int under, int strike); 64 int under, int strike);
65 static void mswindows_output_vertical_divider (struct window *w, int clear); 65 static void mswindows_output_vertical_divider (struct window *w, int clear);
66 static void mswindows_redraw_exposed_windows (Lisp_Object window, int x,
67 int y, int width, int height);
68 static void mswindows_output_dibitmap (struct frame *f, 66 static void mswindows_output_dibitmap (struct frame *f,
69 Lisp_Image_Instance *p, 67 Lisp_Image_Instance *p,
70 struct display_box *db, 68 struct display_box *db,
71 struct display_glyph_area *dga); 69 struct display_glyph_area *dga);
72 70
712 * 710 *
713 * Function checks whether deadbox intersects with the rectangle pointed 711 * Function checks whether deadbox intersects with the rectangle pointed
714 * to by PRC, and paints only the intersection 712 * to by PRC, and paints only the intersection
715 */ 713 */
716 static void 714 static void
717 mswindows_redisplay_deadbox_maybe (struct window *w, const RECT *prc) 715 mswindows_redisplay_deadbox (struct window *w, int x, int y, int width,
718 { 716 int height)
717 {
718 RECT rc = { x, y, x + width, y + height };
719 int sbh = window_scrollbar_height (w); 719 int sbh = window_scrollbar_height (w);
720 int sbw = window_scrollbar_width (w); 720 int sbw = window_scrollbar_width (w);
721 RECT rect_dead, rect_paint; 721 RECT rect_dead, rect_paint;
722 if (sbh == 0 || sbw == 0) 722 if (sbh == 0 || sbw == 0)
723 return; 723 return;
732 rect_dead.top = WINDOW_TOP (w); 732 rect_dead.top = WINDOW_TOP (w);
733 else 733 else
734 rect_dead.top = WINDOW_TEXT_BOTTOM (w); 734 rect_dead.top = WINDOW_TEXT_BOTTOM (w);
735 rect_dead.bottom = rect_dead.top + sbh; 735 rect_dead.bottom = rect_dead.top + sbh;
736 736
737 if (IntersectRect (&rect_paint, &rect_dead, prc)) 737 if (IntersectRect (&rect_paint, &rect_dead, &rc))
738 { 738 {
739 struct frame *f = XFRAME (WINDOW_FRAME (w)); 739 struct frame *f = XFRAME (WINDOW_FRAME (w));
740 FillRect (get_frame_dc (f, 1), &rect_paint, 740 FillRect (get_frame_dc (f, 1), &rect_paint,
741 (HBRUSH) (COLOR_BTNFACE+1)); 741 (HBRUSH) (COLOR_BTNFACE+1));
742 } 742 }
743 } 743 }
744 744
745 #endif /* HAVE_SCROLLBARS */ 745 #endif /* HAVE_SCROLLBARS */
746
747 /*****************************************************************************
748 mswindows_redraw_exposed_window
749
750 Given a bounding box for an area that needs to be redrawn, determine
751 what parts of what lines are contained within and re-output their
752 contents.
753 Copied from redisplay-x.c
754 ****************************************************************************/
755 static void
756 mswindows_redraw_exposed_window (struct window *w, int x, int y, int width,
757 int height)
758 {
759 struct frame *f = XFRAME (w->frame);
760 int line;
761 int orig_windows_structure_changed;
762 RECT rect_window = { WINDOW_LEFT (w), WINDOW_TOP (w),
763 WINDOW_RIGHT (w), WINDOW_BOTTOM (w) };
764 RECT rect_expose = { x, y, x + width, y + height };
765 RECT rect_draw;
766
767 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
768
769 if (!NILP (w->vchild))
770 {
771 mswindows_redraw_exposed_windows (w->vchild, x, y, width, height);
772 return;
773 }
774 else if (!NILP (w->hchild))
775 {
776 mswindows_redraw_exposed_windows (w->hchild, x, y, width, height);
777 return;
778 }
779
780 /* If the window doesn't intersect the exposed region, we're done here. */
781 if (!IntersectRect (&rect_draw, &rect_window, &rect_expose))
782 return;
783
784 /* We do this to make sure that the 3D modelines get redrawn if
785 they are in the exposed region. */
786 orig_windows_structure_changed = f->windows_structure_changed;
787 f->windows_structure_changed = 1;
788
789 if (window_needs_vertical_divider (w))
790 {
791 mswindows_output_vertical_divider (w, 0);
792 }
793
794 for (line = 0; line < Dynarr_length (cdla); line++)
795 {
796 struct display_line *cdl = Dynarr_atp (cdla, line);
797
798 if (DISPLAY_LINE_YPOS (cdl) + DISPLAY_LINE_HEIGHT (cdl)
799 >= rect_draw.top)
800 {
801 if (DISPLAY_LINE_YPOS (cdl) > rect_draw.bottom)
802 {
803 if (line == 0)
804 continue;
805 else
806 break;
807 }
808 else
809 {
810 output_display_line (w, 0, cdla, line,
811 rect_draw.left, rect_draw.right);
812 }
813 }
814 }
815
816 f->windows_structure_changed = orig_windows_structure_changed;
817
818 /* If there have never been any face cache_elements created, then this
819 expose event doesn't actually have anything to do. */
820 if (Dynarr_largest (w->face_cachels))
821 redisplay_clear_bottom_of_window (w, cdla, rect_draw.top, rect_draw.bottom);
822
823 #ifdef HAVE_SCROLLBARS
824 mswindows_redisplay_deadbox_maybe (w, &rect_expose);
825 #endif
826 }
827
828 /*****************************************************************************
829 mswindows_redraw_exposed_windows
830
831 For each window beneath the given window in the window hierarchy,
832 ensure that it is redrawn if necessary after an Expose event.
833 ****************************************************************************/
834 static void
835 mswindows_redraw_exposed_windows (Lisp_Object window, int x, int y, int width,
836 int height)
837 {
838 for (; !NILP (window); window = XWINDOW (window)->next)
839 mswindows_redraw_exposed_window (XWINDOW (window), x, y, width, height);
840 }
841
842 /*****************************************************************************
843 mswindows_redraw_exposed_area
844
845 For each window on the given frame, ensure that any area in the
846 Exposed area is redrawn.
847 ****************************************************************************/
848 void
849 mswindows_redraw_exposed_area (struct frame *f, int x, int y, int width, int height)
850 {
851 /* If any window on the frame has had its face cache reset then the
852 redisplay structures are effectively invalid. If we attempt to
853 use them we'll blow up. We mark the frame as changed to ensure
854 that redisplay will do a full update. This probably isn't
855 necessary but it can't hurt. */
856 #ifdef HAVE_TOOLBARS
857 /* #### We would rather put these off as well but there is currently
858 no combination of flags which will force an unchanged toolbar to
859 redraw anyhow. */
860 MAYBE_FRAMEMETH (f, redraw_exposed_toolbars, (f, x, y, width, height));
861 #endif
862 redraw_exposed_gutters (f, x, y, width, height);
863
864 if (!f->window_face_cache_reset)
865 {
866 mswindows_redraw_exposed_windows (f->root_window, x, y, width, height);
867 GdiFlush();
868 }
869 else
870 MARK_FRAME_CHANGED (f);
871 }
872
873 746
874 /***************************************************************************** 747 /*****************************************************************************
875 mswindows_bevel_area 748 mswindows_bevel_area
876 749
877 Draw a 3d border around the specified area on window W. 750 Draw a 3d border around the specified area on window W.
1336 ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL); 1209 ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
1337 } 1210 }
1338 1211
1339 #ifdef HAVE_SCROLLBARS 1212 #ifdef HAVE_SCROLLBARS
1340 if (WINDOWP (locale)) 1213 if (WINDOWP (locale))
1341 mswindows_redisplay_deadbox_maybe (XWINDOW (locale), &rect); 1214 mswindows_redisplay_deadbox (XWINDOW (locale), x, y, width, height);
1342 #endif 1215 #endif
1343 } 1216 }
1344 1217
1345 /* XXX Implement me! */ 1218 /* #### Implement me! */
1346 static void 1219 static void
1347 mswindows_clear_frame (struct frame *f) 1220 mswindows_clear_frame (struct frame *f)
1348 { 1221 {
1349 GdiFlush(); 1222 GdiFlush ();
1350 } 1223 }
1351 1224
1352 1225
1353 /************************************************************************/ 1226 /************************************************************************/
1354 /* initialization */ 1227 /* initialization */
1370 CONSOLE_HAS_METHOD (mswindows, flash); 1243 CONSOLE_HAS_METHOD (mswindows, flash);
1371 CONSOLE_HAS_METHOD (mswindows, ring_bell); 1244 CONSOLE_HAS_METHOD (mswindows, ring_bell);
1372 CONSOLE_HAS_METHOD (mswindows, bevel_area); 1245 CONSOLE_HAS_METHOD (mswindows, bevel_area);
1373 CONSOLE_HAS_METHOD (mswindows, output_string); 1246 CONSOLE_HAS_METHOD (mswindows, output_string);
1374 CONSOLE_HAS_METHOD (mswindows, output_pixmap); 1247 CONSOLE_HAS_METHOD (mswindows, output_pixmap);
1248 #ifdef HAVE_SCROLLBARS
1249 CONSOLE_HAS_METHOD (mswindows, redisplay_deadbox);
1250 #endif
1375 1251
1376 /* redisplay methods - printer */ 1252 /* redisplay methods - printer */
1377 CONSOLE_HAS_METHOD (msprinter, frame_output_end); 1253 CONSOLE_HAS_METHOD (msprinter, frame_output_end);
1378 CONSOLE_INHERITS_METHOD (msprinter, mswindows, text_width); 1254 CONSOLE_INHERITS_METHOD (msprinter, mswindows, text_width);
1379 CONSOLE_INHERITS_METHOD (msprinter, mswindows, output_display_block); 1255 CONSOLE_INHERITS_METHOD (msprinter, mswindows, output_display_block);