diff src/redisplay-msw.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents 74fd4e045ea6
children b8cc9ab3f761
line wrap: on
line diff
--- a/src/redisplay-msw.c	Mon Aug 13 11:15:00 2007 +0200
+++ b/src/redisplay-msw.c	Mon Aug 13 11:16:07 2007 +0200
@@ -202,16 +202,17 @@
 
 /*
  * Given F, retrieve device context. F can be a display frame, or
- * a print job.
+ * a print job. For a print job, page is also started when printer's
+ * device context is first time requested. 
  */
-INLINE HDC
-get_frame_dc (struct frame *f)
+static HDC
+get_frame_dc (struct frame *f, int start_page_p)
 {
   if (FRAME_MSWINDOWS_P (f))
     return FRAME_MSWINDOWS_DC (f);
   else
     {
-      if (!FRAME_MSPRINTER_PAGE_STARTED (f))
+      if (start_page_p && !FRAME_MSPRINTER_PAGE_STARTED (f))
 	msprinter_start_page (f);
       return DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)));
     }
@@ -221,13 +222,14 @@
  * Given F, retrieve compatible device context. F can be a display
  * frame, or a print job.
  */
-INLINE HDC
+static HDC
 get_frame_compdc (struct frame *f)
 {
-  if (FRAME_MSWINDOWS_P (f))
-    return FRAME_MSWINDOWS_CDC (f);
+  struct device *d = XDEVICE (FRAME_DEVICE (f));
+  if (DEVICE_MSWINDOWS_P (d))
+    return DEVICE_MSWINDOWS_HCDC (d);
   else
-    return FRAME_MSPRINTER_CDC (f);
+    return DEVICE_MSPRINTER_HCDC (d);
 }
 
 /*****************************************************************************
@@ -285,7 +287,7 @@
 			struct rune *rb, int start_pixpos)
 {
   struct frame *f = XFRAME (w->frame);
-  HDC hdc = get_frame_dc (f);
+  HDC hdc = get_frame_dc (f, 1);
   RECT rect = { rb->xpos, DISPLAY_LINE_YPOS (dl),
 		rb->xpos+rb->width, 
 		DISPLAY_LINE_YEND (dl) };
@@ -338,7 +340,7 @@
   struct face_cachel *cachel=0;
   Lisp_Object font = Qnil;
   int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
-  HDC hdc = get_frame_dc (f);
+  HDC hdc = get_frame_dc (f, 1);
   unsigned int local_face_index=0;
   char *p_char = NULL;
   int n_char = 0;
@@ -458,7 +460,7 @@
   struct frame *f = XFRAME (w->frame);
   /* struct device *d = XDEVICE (f->device);*/
   Lisp_Object window;
-  HDC hdc = get_frame_dc (f);
+  HDC hdc = get_frame_dc (f, 1);
   int clip_end;
   Lisp_Object bg_pmap;
   int len = Dynarr_length (buf);
@@ -571,7 +573,7 @@
 			   struct display_box* db,
 			   struct display_glyph_area* dga)
 {
-  HDC hdc = get_frame_dc (f);
+  HDC hdc = get_frame_dc (f, 1);
   HDC hcompdc = get_frame_compdc (f);
   HGDIOBJ old=NULL;
   COLORREF bgcolor = GetBkColor (hdc);
@@ -680,7 +682,7 @@
 			 int cursor_height, int bg_pixmap)
 {
   struct frame *f = XFRAME (w->frame);
-  HDC hdc = get_frame_dc (f);
+  HDC hdc = get_frame_dc (f, 1);
 
   Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
   Lisp_Object window;
@@ -731,7 +733,7 @@
   if (IntersectRect (&rect_paint, &rect_dead, prc))
     {
       struct frame *f = XFRAME (WINDOW_FRAME (w));
-      FillRect (get_frame_dc (f), &rect_paint,
+      FillRect (get_frame_dc (f, 1), &rect_paint,
 		(HBRUSH) (COLOR_BTNFACE+1));
     }
 }
@@ -910,7 +912,7 @@
   {
     RECT rect = { x, y, x + width, y + height };
     Lisp_Object color = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
-    HDC hdc = get_frame_dc (f);
+    HDC hdc = get_frame_dc (f, 1);
 
     mswindows_update_dc (hdc, Qnil, color, Qnil);
     DrawEdge (hdc, &rect, edge, border);
@@ -969,7 +971,7 @@
 mswindows_flash (struct device *d)
 {
   struct frame *f = device_selected_frame (d);
-  HDC hdc = get_frame_dc (f);
+  HDC hdc = get_frame_dc (f, 1);
   RECT rc;
 
   GetClientRect (FRAME_MSWINDOWS_HANDLE (f), &rc);
@@ -1121,6 +1123,7 @@
 	      Lisp_Object instance;
 	      struct display_box dbox;
 	      struct display_glyph_area dga;
+
 	      redisplay_calculate_display_boxes (dl, rb->xpos, rb->object.dglyph.xoffset,
 						 start_pixpos, rb->width,
 						 &dbox, &dga);
@@ -1131,69 +1134,72 @@
 	      findex = rb->findex;
 
 	      if (IMAGE_INSTANCEP (instance))
-		switch (XIMAGE_INSTANCE_TYPE (instance))
-		  {
-		  case IMAGE_TEXT:
+		{
+		  switch (XIMAGE_INSTANCE_TYPE (instance))
 		    {
-		      /* #### This is way losing.  See the comment in
-			 add_glyph_rune(). */
-		      Lisp_Object string =
-			XIMAGE_INSTANCE_TEXT_STRING (instance);
-		      convert_bufbyte_string_into_emchar_dynarr
-			(XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
-
+		    case IMAGE_TEXT:
+		      {
+			/* #### This is way losing.  See the comment in
+			   add_glyph_rune(). */
+			Lisp_Object string =
+			  XIMAGE_INSTANCE_TEXT_STRING (instance);
+			convert_bufbyte_string_into_emchar_dynarr
+			  (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
+			
+			if (rb->cursor_type == CURSOR_ON)
+			  mswindows_output_cursor (w, dl, xpos, cursor_width,
+						   findex, Dynarr_at (buf, 0), 0);
+			else /* #### redisplay-x passes -1 as the width: why ? */
+			  mswindows_output_string (w, dl, buf, xpos,
+						   rb->object.dglyph.xoffset,
+						   start_pixpos, rb->width, findex,
+						   0, 0, 0, 0);
+			Dynarr_reset (buf);
+		      }
+		      break;
+		      
+		    case IMAGE_MONO_PIXMAP:
+		    case IMAGE_COLOR_PIXMAP:
+		      redisplay_output_pixmap (w, instance, &dbox, &dga, findex,
+					       cursor_start, cursor_width,
+					       cursor_height, 0);
 		      if (rb->cursor_type == CURSOR_ON)
 			mswindows_output_cursor (w, dl, xpos, cursor_width,
-						 findex, Dynarr_at (buf, 0), 0);
-		      else /* #### redisplay-x passes -1 as the width: why ? */
-			mswindows_output_string (w, dl, buf, xpos,
-					   rb->object.dglyph.xoffset,
-					   start_pixpos, rb->width, findex,
-						 0, 0, 0, 0);
-		      Dynarr_reset (buf);
+						 findex, 0, 1);
+		      break;
+		      
+		    case IMAGE_POINTER:
+		      abort ();
+		      
+		    case IMAGE_SUBWINDOW:
+		    case IMAGE_WIDGET:
+		      redisplay_output_subwindow (w, instance, &dbox, &dga, findex,
+						  cursor_start, cursor_width,
+						  cursor_height);
+		      if (rb->cursor_type == CURSOR_ON)
+			mswindows_output_cursor (w, dl, xpos, cursor_width,
+						 findex, 0, 1);
+		      break;
+		      
+		    case IMAGE_LAYOUT:
+		      redisplay_output_layout (w, instance, &dbox, &dga, findex,
+					       cursor_start, cursor_width,
+					       cursor_height);
+		      if (rb->cursor_type == CURSOR_ON)
+			mswindows_output_cursor (w, dl, xpos, cursor_width,
+						 findex, 0, 1);
+		      break;
+		      
+		    case IMAGE_NOTHING:
+		      /* nothing is as nothing does */
+		      break;
+		      
+		    default:
+		      abort ();
 		    }
-		    break;
-
-		  case IMAGE_MONO_PIXMAP:
-		  case IMAGE_COLOR_PIXMAP:
-		    redisplay_output_pixmap (w, instance, &dbox, &dga, findex,
-					     cursor_start, cursor_width,
-					     cursor_height, 0);
-		    if (rb->cursor_type == CURSOR_ON)
-		      mswindows_output_cursor (w, dl, xpos, cursor_width,
-					       findex, 0, 1);
-		    break;
-
-		  case IMAGE_POINTER:
-		    abort ();
-
-		  case IMAGE_SUBWINDOW:
-		  case IMAGE_WIDGET:
-		    redisplay_output_subwindow (w, instance, &dbox, &dga, findex,
-						cursor_start, cursor_width,
-						cursor_height);
-		    if (rb->cursor_type == CURSOR_ON)
-		      mswindows_output_cursor (w, dl, xpos, cursor_width,
-					       findex, 0, 1);
-		    break;
-
-		  case IMAGE_LAYOUT:
-		    redisplay_output_layout (w, instance, &dbox, &dga, findex,
-					     cursor_start, cursor_width,
-					     cursor_height);
-		    if (rb->cursor_type == CURSOR_ON)
-		      mswindows_output_cursor (w, dl, xpos, cursor_width,
-					       findex, 0, 1);
-		    break;
-
-		  case IMAGE_NOTHING:
-		    /* nothing is as nothing does */
-		    break;
-
-		  default:
-		    abort ();
-		  }
-
+		  IMAGE_INSTANCE_OPTIMIZE_OUTPUT 
+		    (XIMAGE_INSTANCE (instance)) = 0;
+		}
 	      xpos += rb->width;
 	      elt++;
 	    }
@@ -1226,15 +1232,15 @@
 mswindows_output_vertical_divider (struct window *w, int clear_unused)
 {
   struct frame *f = XFRAME (w->frame);
-  HDC hdc = get_frame_dc (f);
+  HDC hdc = get_frame_dc (f, 1);
   RECT rect;
   int spacing = XINT (w->vertical_divider_spacing);
   int shadow = XINT (w->vertical_divider_shadow_thickness);
   int abs_shadow = abs (shadow);
   int line_width = XINT (w->vertical_divider_line_width);
   int div_left = WINDOW_RIGHT (w) - window_divider_width (w);
-  int y1 = WINDOW_TOP (w) + FRAME_TOP_GUTTER_BOUNDS (f);
-  int y2 = WINDOW_BOTTOM (w) + FRAME_BOTTOM_GUTTER_BOUNDS (f);
+  int y1 = WINDOW_TOP (w);
+  int y2 = WINDOW_BOTTOM (w);
 
   /* Clear left and right spacing areas */
   if (spacing)
@@ -1287,7 +1293,7 @@
 mswindows_text_width (struct frame *f, struct face_cachel *cachel,
 		      const Emchar *str, Charcount len)
 {
-  HDC hdc = get_frame_dc (f);
+  HDC hdc = get_frame_dc (f, 0);
   int width_so_far = 0;
   unsigned char *text_storage = (unsigned char *) alloca (2 * len);
   textual_run *runs = alloca_array (textual_run, len);
@@ -1317,7 +1323,7 @@
 			Lisp_Object background_pixmap)
 {
   RECT rect = { x, y, x+width, y+height };
-  HDC hdc = get_frame_dc (f);
+  HDC hdc = get_frame_dc (f, 1);
 
   if (!NILP (background_pixmap))
     {