comparison src/redisplay-output.c @ 384:bbff43aa5eb7 r21-2-7

Import from CVS: tag r21-2-7
author cvs
date Mon, 13 Aug 2007 11:08:24 +0200
parents 8626e4521993
children aabb7f5b1c81
comparison
equal deleted inserted replaced
383:6a50c6a581a5 384:bbff43aa5eb7
430 ****************************************************************************/ 430 ****************************************************************************/
431 static void 431 static void
432 clear_left_border (struct window *w, int y, int height) 432 clear_left_border (struct window *w, int y, int height)
433 { 433 {
434 struct frame *f = XFRAME (w->frame); 434 struct frame *f = XFRAME (w->frame);
435 struct device *d = XDEVICE (f->device);
436 Lisp_Object window; 435 Lisp_Object window;
437 436
438 XSETWINDOW (window, w); 437 XSETWINDOW (window, w);
439 DEVMETH (d, clear_region, (window, DEFAULT_INDEX, 438 redisplay_clear_region (window, DEFAULT_INDEX,
440 FRAME_LEFT_BORDER_START (f), y, 439 FRAME_LEFT_BORDER_START (f), y,
441 FRAME_BORDER_WIDTH (f), height)); 440 FRAME_BORDER_WIDTH (f), height);
442 } 441 }
443 442
444 /***************************************************************************** 443 /*****************************************************************************
445 clear_right_border 444 clear_right_border
446 445
448 ****************************************************************************/ 447 ****************************************************************************/
449 static void 448 static void
450 clear_right_border (struct window *w, int y, int height) 449 clear_right_border (struct window *w, int y, int height)
451 { 450 {
452 struct frame *f = XFRAME (w->frame); 451 struct frame *f = XFRAME (w->frame);
453 struct device *d = XDEVICE (f->device);
454 Lisp_Object window; 452 Lisp_Object window;
455 453
456 XSETWINDOW (window, w); 454 XSETWINDOW (window, w);
457 DEVMETH (d, clear_region, (window, DEFAULT_INDEX, 455 redisplay_clear_region (window, DEFAULT_INDEX,
458 FRAME_RIGHT_BORDER_START (f), 456 FRAME_RIGHT_BORDER_START (f),
459 y, FRAME_BORDER_WIDTH (f), height)); 457 y, FRAME_BORDER_WIDTH (f), height);
460 } 458 }
461 459
462 /***************************************************************************** 460 /*****************************************************************************
463 output_display_line 461 output_display_line
464 462
615 Lisp_Object window; 613 Lisp_Object window;
616 614
617 XSETWINDOW (window, w); 615 XSETWINDOW (window, w);
618 616
619 /* Clear the empty area. */ 617 /* Clear the empty area. */
620 DEVMETH (d, clear_region, 618 redisplay_clear_region (window, get_builtin_face_cache_index (w, face),
621 (window, get_builtin_face_cache_index (w, 619 x, y, width, height);
622 face),
623 x, y, width, height));
624 620
625 /* Mark that we should clear the border. This is 621 /* Mark that we should clear the border. This is
626 necessary because italic fonts may leave 622 necessary because italic fonts may leave
627 droppings in the border. */ 623 droppings in the border. */
628 clear_border = 1; 624 clear_border = 1;
983 return; 979 return;
984 980
985 redraw_cursor_in_window (XWINDOW (window), run_end_begin_meths); 981 redraw_cursor_in_window (XWINDOW (window), run_end_begin_meths);
986 } 982 }
987 983
984 /****************************************************************************
985 redisplay_unmap_subwindows
986
987 Remove subwindows from the area in the box defined by the given
988 parameters.
989 ****************************************************************************/
990 static void redisplay_unmap_subwindows (struct frame* f, int x, int y, int width, int height)
991 {
992 int elt;
993
994 for (elt = 0; elt < Dynarr_length (f->subwindow_cachels); elt++)
995 {
996 struct subwindow_cachel *cachel =
997 Dynarr_atp (f->subwindow_cachels, elt);
998
999 if (cachel->being_displayed
1000 &&
1001 cachel->x + cachel->width > x && cachel->x < x + width
1002 &&
1003 cachel->y + cachel->height > y && cachel->y < y + height)
1004 {
1005 unmap_subwindow (cachel->subwindow);
1006 }
1007 }
1008 }
1009
1010 /****************************************************************************
1011 redisplay_output_subwindow
1012
1013
1014 output a subwindow. This code borrows heavily from the pixmap stuff,
1015 although is much simpler not needing to account for partial
1016 pixmaps, backgrounds etc.
1017 ****************************************************************************/
1018 void
1019 redisplay_output_subwindow (struct window *w, struct display_line *dl,
1020 Lisp_Object image_instance, int xpos, int xoffset,
1021 int start_pixpos, int width, face_index findex,
1022 int cursor_start, int cursor_width, int cursor_height)
1023 {
1024 struct Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
1025 Lisp_Object window;
1026
1027 int lheight = dl->ascent + dl->descent - dl->clip;
1028 int pheight = ((int) IMAGE_INSTANCE_SUBWINDOW_HEIGHT (p) > lheight ? lheight :
1029 IMAGE_INSTANCE_SUBWINDOW_HEIGHT (p));
1030
1031 XSETWINDOW (window, w);
1032
1033 /* Clear the area the subwindow is going into. The subwindow itself
1034 will always take care of the full width. We don't want to clear
1035 where it is going to go in order to avoid flicker. So, all we
1036 have to take care of is any area above or below the subwindow. Of
1037 course this is rubbish if the subwindow has transparent areas
1038 (for instance with frames). */
1039 /* #### We take a shortcut for now. We know that since we have
1040 subwindow_offset hardwired to 0 that the subwindow is against the top
1041 edge so all we have to worry about is below it. */
1042 if ((int) (dl->ypos - dl->ascent + pheight) <
1043 (int) (dl->ypos + dl->descent - dl->clip))
1044 {
1045 int clear_x, clear_width;
1046
1047 int clear_y = dl->ypos - dl->ascent + pheight;
1048 int clear_height = lheight - pheight;
1049
1050 if (start_pixpos >= 0 && start_pixpos > xpos)
1051 {
1052 clear_x = start_pixpos;
1053 clear_width = xpos + width - start_pixpos;
1054 }
1055 else
1056 {
1057 clear_x = xpos;
1058 clear_width = width;
1059 }
1060
1061 redisplay_clear_region (window, findex, clear_x, clear_y,
1062 clear_width, clear_height);
1063 }
1064 #if 0
1065 redisplay_clear_region (window, findex, xpos - xoffset, dl->ypos - dl->ascent,
1066 width, lheight);
1067 #endif
1068 /* if we can't view the whole window we can't view any of it */
1069 if (IMAGE_INSTANCE_SUBWINDOW_HEIGHT (p) > lheight
1070 ||
1071 IMAGE_INSTANCE_SUBWINDOW_WIDTH (p) > width)
1072 {
1073 redisplay_clear_region (window, findex, xpos - xoffset, dl->ypos - dl->ascent,
1074 width, lheight);
1075 unmap_subwindow (image_instance);
1076 }
1077 else
1078 map_subwindow (image_instance, xpos - xoffset, dl->ypos - dl->ascent);
1079 }
1080
1081 /****************************************************************************
1082 redisplay_clear_region
1083
1084 Clear the area in the box defined by the given parameters using the
1085 given face. This has been generalised so that subwindows can be
1086 coped with effectively.
1087 ****************************************************************************/
1088 void
1089 redisplay_clear_region (Lisp_Object locale, face_index findex, int x, int y,
1090 int width, int height)
1091 {
1092 struct window *w = NULL;
1093 struct frame *f = NULL;
1094 struct device *d;
1095 Lisp_Object background_pixmap = Qunbound;
1096 Lisp_Object fcolor = Qnil, bcolor = Qnil;
1097
1098 if (!width || !height)
1099 return;
1100
1101 if (WINDOWP (locale))
1102 {
1103 w = XWINDOW (locale);
1104 f = XFRAME (w->frame);
1105 }
1106 else if (FRAMEP (locale))
1107 {
1108 w = NULL;
1109 f = XFRAME (locale);
1110 }
1111 else
1112 abort ();
1113
1114 d = XDEVICE (f->device);
1115
1116 /* if we have subwindows in the region we have to unmap them */
1117 if (Dynarr_length (FRAME_SUBWINDOW_CACHE (f)))
1118 {
1119 redisplay_unmap_subwindows (f, x, y, width, height);
1120 }
1121
1122 /* #### This isn't quite right for when this function is called
1123 from the toolbar code. */
1124
1125 /* Don't use a backing pixmap in the border area */
1126 if (x >= FRAME_LEFT_BORDER_END (f)
1127 && x < FRAME_RIGHT_BORDER_START (f)
1128 && y >= FRAME_TOP_BORDER_END (f)
1129 && y < FRAME_BOTTOM_BORDER_START (f))
1130 {
1131 Lisp_Object temp;
1132
1133 if (w)
1134 {
1135 temp = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, findex);
1136
1137 if (IMAGE_INSTANCEP (temp)
1138 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
1139 {
1140 /* #### maybe we could implement such that a string
1141 can be a background pixmap? */
1142 background_pixmap = temp;
1143 }
1144 }
1145 else
1146 {
1147 temp = FACE_BACKGROUND_PIXMAP (Vdefault_face, locale);
1148
1149 if (IMAGE_INSTANCEP (temp)
1150 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
1151 {
1152 background_pixmap = temp;
1153 }
1154 }
1155 }
1156
1157 if (!UNBOUNDP (background_pixmap) &&
1158 XIMAGE_INSTANCE_PIXMAP_DEPTH (background_pixmap) == 0)
1159 {
1160 if (w)
1161 {
1162 fcolor = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
1163 bcolor = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
1164 }
1165 else
1166 {
1167 fcolor = FACE_FOREGROUND (Vdefault_face, locale);
1168 bcolor = FACE_BACKGROUND (Vdefault_face, locale);
1169 }
1170 }
1171 else
1172 {
1173 fcolor = (w ?
1174 WINDOW_FACE_CACHEL_BACKGROUND (w, findex) :
1175 FACE_BACKGROUND (Vdefault_face, locale));
1176
1177 }
1178
1179 if (UNBOUNDP (background_pixmap))
1180 background_pixmap = Qnil;
1181
1182 DEVMETH (d, clear_region,
1183 (locale, d, f, findex, x, y, width, height, fcolor, bcolor, background_pixmap));
1184 }
1185
988 /***************************************************************************** 1186 /*****************************************************************************
989 redisplay_clear_top_of_window 1187 redisplay_clear_top_of_window
990 1188
991 If window is topmost, clear the internal border above it. 1189 If window is topmost, clear the internal border above it.
992 ****************************************************************************/ 1190 ****************************************************************************/
997 XSETWINDOW (window, w); 1195 XSETWINDOW (window, w);
998 1196
999 if (!NILP (Fwindow_highest_p (window))) 1197 if (!NILP (Fwindow_highest_p (window)))
1000 { 1198 {
1001 struct frame *f = XFRAME (w->frame); 1199 struct frame *f = XFRAME (w->frame);
1002 struct device *d = XDEVICE (f->device);
1003 int x, y, width, height; 1200 int x, y, width, height;
1004 1201
1005 x = w->pixel_left; 1202 x = w->pixel_left;
1006 width = w->pixel_width; 1203 width = w->pixel_width;
1007 1204
1014 width += FRAME_BORDER_WIDTH (f); 1211 width += FRAME_BORDER_WIDTH (f);
1015 1212
1016 y = FRAME_TOP_BORDER_START (f) - 1; 1213 y = FRAME_TOP_BORDER_START (f) - 1;
1017 height = FRAME_BORDER_HEIGHT (f) + 1; 1214 height = FRAME_BORDER_HEIGHT (f) + 1;
1018 1215
1019 DEVMETH (d, clear_region, (window, DEFAULT_INDEX, x, y, width, height)); 1216 redisplay_clear_region (window, DEFAULT_INDEX, x, y, width, height);
1020 } 1217 }
1021 } 1218 }
1022 1219
1023 /***************************************************************************** 1220 /*****************************************************************************
1024 redisplay_clear_bottom_of_window 1221 redisplay_clear_bottom_of_window