Mercurial > hg > xemacs-beta
comparison src/glyphs.c @ 5125:b5df3737028a ben-lisp-object
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 24 Feb 2010 01:58:04 -0600 |
parents | 623d57b7fbe8 ae48681c47fa |
children | 2a462149bd6a |
comparison
equal
deleted
inserted
replaced
5124:623d57b7fbe8 | 5125:b5df3737028a |
---|---|
590 struct gcpro gcpro1; | 590 struct gcpro gcpro1; |
591 Lisp_Object data; | 591 Lisp_Object data; |
592 | 592 |
593 specbind (Qinhibit_quit, Qt); | 593 specbind (Qinhibit_quit, Qt); |
594 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 594 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
595 temp_buffer = Fget_buffer_create (build_string (" *pixmap conversion*")); | 595 temp_buffer = Fget_buffer_create (build_ascstring (" *pixmap conversion*")); |
596 GCPRO1 (temp_buffer); | 596 GCPRO1 (temp_buffer); |
597 set_buffer_internal (XBUFFER (temp_buffer)); | 597 set_buffer_internal (XBUFFER (temp_buffer)); |
598 Ferase_buffer (Qnil); | 598 Ferase_buffer (Qnil); |
599 specbind (intern ("format-alist"), Qnil); | 599 specbind (intern ("format-alist"), Qnil); |
600 Finsert_file_contents_internal (file, Qnil, Qnil, Qnil, Qnil, Qnil, Qnil); | 600 Finsert_file_contents_internal (file, Qnil, Qnil, Qnil, Qnil, Qnil, Qnil); |
658 /* This function can GC */ | 658 /* This function can GC */ |
659 /* value can be nil; we cache failures as well as successes */ | 659 /* value can be nil; we cache failures as well as successes */ |
660 if (!NILP (value)) | 660 if (!NILP (value)) |
661 { | 661 { |
662 Lisp_Object window; | 662 Lisp_Object window; |
663 window = VOID_TO_LISP (flag_closure); | 663 window = GET_LISP_FROM_VOID (flag_closure); |
664 assert (EQ (XIMAGE_INSTANCE_DOMAIN (value), window)); | 664 assert (EQ (XIMAGE_INSTANCE_DOMAIN (value), window)); |
665 } | 665 } |
666 | 666 |
667 return 0; | 667 return 0; |
668 } | 668 } |
674 | 674 |
675 | 675 |
676 assert (!NILP (w->subwindow_instance_cache)); | 676 assert (!NILP (w->subwindow_instance_cache)); |
677 elisp_maphash (check_instance_cache_mapper, | 677 elisp_maphash (check_instance_cache_mapper, |
678 w->subwindow_instance_cache, | 678 w->subwindow_instance_cache, |
679 LISP_TO_VOID (window)); | 679 STORE_LISP_IN_VOID (window)); |
680 } | 680 } |
681 | 681 |
682 void | 682 void |
683 check_image_instance_structure (Lisp_Object instance) | 683 check_image_instance_structure (Lisp_Object instance) |
684 { | 684 { |
990 int escapeflag) | 990 int escapeflag) |
991 { | 991 { |
992 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (obj); | 992 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (obj); |
993 | 993 |
994 if (print_readably) | 994 if (print_readably) |
995 printing_unreadable_object ("#<image-instance 0x%x>", | 995 printing_unreadable_lcrecord (obj, 0); |
996 ii->header.uid); | |
997 write_fmt_string_lisp (printcharfun, "#<image-instance (%s) ", 1, | 996 write_fmt_string_lisp (printcharfun, "#<image-instance (%s) ", 1, |
998 Fimage_instance_type (obj)); | 997 Fimage_instance_type (obj)); |
999 if (!NILP (ii->name)) | 998 if (!NILP (ii->name)) |
1000 write_fmt_string_lisp (printcharfun, "%S ", 1, ii->name); | 999 write_fmt_string_lisp (printcharfun, "%S ", 1, ii->name); |
1001 write_fmt_string_lisp (printcharfun, "on %s ", 1, ii->domain); | 1000 write_fmt_string_lisp (printcharfun, "on %s ", 1, ii->domain); |
1015 { | 1014 { |
1016 Ibyte *s; | 1015 Ibyte *s; |
1017 Lisp_Object filename = IMAGE_INSTANCE_PIXMAP_FILENAME (ii); | 1016 Lisp_Object filename = IMAGE_INSTANCE_PIXMAP_FILENAME (ii); |
1018 s = qxestrrchr (XSTRING_DATA (filename), '/'); | 1017 s = qxestrrchr (XSTRING_DATA (filename), '/'); |
1019 if (s) | 1018 if (s) |
1020 print_internal (build_intstring (s + 1), printcharfun, 1); | 1019 print_internal (build_istring (s + 1), printcharfun, 1); |
1021 else | 1020 else |
1022 print_internal (filename, printcharfun, 1); | 1021 print_internal (filename, printcharfun, 1); |
1023 } | 1022 } |
1024 if (IMAGE_INSTANCE_PIXMAP_DEPTH (ii) > 1) | 1023 if (IMAGE_INSTANCE_PIXMAP_DEPTH (ii) > 1) |
1025 write_fmt_string (printcharfun, " %dx%dx%d", | 1024 write_fmt_string (printcharfun, " %dx%dx%d", |
1031 IMAGE_INSTANCE_PIXMAP_WIDTH (ii), | 1030 IMAGE_INSTANCE_PIXMAP_WIDTH (ii), |
1032 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii)); | 1031 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii)); |
1033 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii)) || | 1032 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii)) || |
1034 !NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii))) | 1033 !NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii))) |
1035 { | 1034 { |
1036 write_c_string (printcharfun, " @"); | 1035 write_ascstring (printcharfun, " @"); |
1037 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii))) | 1036 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii))) |
1038 write_fmt_string (printcharfun, "%ld", | 1037 write_fmt_string (printcharfun, "%ld", |
1039 XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii))); | 1038 XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii))); |
1040 else | 1039 else |
1041 write_c_string (printcharfun, "??"); | 1040 write_ascstring (printcharfun, "??"); |
1042 write_c_string (printcharfun, ","); | 1041 write_ascstring (printcharfun, ","); |
1043 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii))) | 1042 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii))) |
1044 write_fmt_string (printcharfun, "%ld", | 1043 write_fmt_string (printcharfun, "%ld", |
1045 XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii))); | 1044 XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii))); |
1046 else | 1045 else |
1047 write_c_string (printcharfun, "??"); | 1046 write_ascstring (printcharfun, "??"); |
1048 } | 1047 } |
1049 if (!NILP (IMAGE_INSTANCE_PIXMAP_FG (ii)) || | 1048 if (!NILP (IMAGE_INSTANCE_PIXMAP_FG (ii)) || |
1050 !NILP (IMAGE_INSTANCE_PIXMAP_BG (ii))) | 1049 !NILP (IMAGE_INSTANCE_PIXMAP_BG (ii))) |
1051 { | 1050 { |
1052 write_c_string (printcharfun, " ("); | 1051 write_ascstring (printcharfun, " ("); |
1053 if (!NILP (IMAGE_INSTANCE_PIXMAP_FG (ii))) | 1052 if (!NILP (IMAGE_INSTANCE_PIXMAP_FG (ii))) |
1054 { | 1053 { |
1055 print_internal | 1054 print_internal |
1056 (XCOLOR_INSTANCE | 1055 (XCOLOR_INSTANCE |
1057 (IMAGE_INSTANCE_PIXMAP_FG (ii))->name, printcharfun, 0); | 1056 (IMAGE_INSTANCE_PIXMAP_FG (ii))->name, printcharfun, 0); |
1058 } | 1057 } |
1059 write_c_string (printcharfun, "/"); | 1058 write_ascstring (printcharfun, "/"); |
1060 if (!NILP (IMAGE_INSTANCE_PIXMAP_BG (ii))) | 1059 if (!NILP (IMAGE_INSTANCE_PIXMAP_BG (ii))) |
1061 { | 1060 { |
1062 print_internal | 1061 print_internal |
1063 (XCOLOR_INSTANCE | 1062 (XCOLOR_INSTANCE |
1064 (IMAGE_INSTANCE_PIXMAP_BG (ii))->name, printcharfun, 0); | 1063 (IMAGE_INSTANCE_PIXMAP_BG (ii))->name, printcharfun, 0); |
1065 } | 1064 } |
1066 write_c_string (printcharfun, ")"); | 1065 write_ascstring (printcharfun, ")"); |
1067 } | 1066 } |
1068 break; | 1067 break; |
1069 | 1068 |
1070 case IMAGE_WIDGET: | 1069 case IMAGE_WIDGET: |
1071 print_internal (IMAGE_INSTANCE_WIDGET_TYPE (ii), printcharfun, 0); | 1070 print_internal (IMAGE_INSTANCE_WIDGET_TYPE (ii), printcharfun, 0); |
1085 | 1084 |
1086 /* This is stolen from frame.c. Subwindows are strange in that they | 1085 /* This is stolen from frame.c. Subwindows are strange in that they |
1087 are specific to a particular frame so we want to print in their | 1086 are specific to a particular frame so we want to print in their |
1088 description what that frame is. */ | 1087 description what that frame is. */ |
1089 | 1088 |
1090 write_c_string (printcharfun, " on #<"); | 1089 write_ascstring (printcharfun, " on #<"); |
1091 { | 1090 { |
1092 struct frame* f = XFRAME (IMAGE_INSTANCE_FRAME (ii)); | 1091 struct frame* f = XFRAME (IMAGE_INSTANCE_FRAME (ii)); |
1093 | 1092 |
1094 if (!FRAME_LIVE_P (f)) | 1093 if (!FRAME_LIVE_P (f)) |
1095 write_c_string (printcharfun, "dead"); | 1094 write_ascstring (printcharfun, "dead"); |
1096 else | 1095 else |
1097 write_c_string (printcharfun, | 1096 write_ascstring (printcharfun, |
1098 DEVICE_TYPE_NAME (XDEVICE (FRAME_DEVICE (f)))); | 1097 DEVICE_TYPE_NAME (XDEVICE (FRAME_DEVICE (f)))); |
1099 } | 1098 } |
1100 write_c_string (printcharfun, "-frame>"); | 1099 write_ascstring (printcharfun, "-frame>"); |
1101 write_fmt_string (printcharfun, " 0x%p", | 1100 write_fmt_string (printcharfun, " 0x%p", |
1102 IMAGE_INSTANCE_SUBWINDOW_ID (ii)); | 1101 IMAGE_INSTANCE_SUBWINDOW_ID (ii)); |
1103 | 1102 |
1104 break; | 1103 break; |
1105 | 1104 |
1131 /* Make sure we don't try this twice. */ | 1130 /* Make sure we don't try this twice. */ |
1132 IMAGE_INSTANCE_DEVICE (i) = Qnil; | 1131 IMAGE_INSTANCE_DEVICE (i) = Qnil; |
1133 } | 1132 } |
1134 | 1133 |
1135 static int | 1134 static int |
1136 image_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) | 1135 image_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth, |
1136 int UNUSED (foldcase)) | |
1137 { | 1137 { |
1138 Lisp_Image_Instance *i1 = XIMAGE_INSTANCE (obj1); | 1138 Lisp_Image_Instance *i1 = XIMAGE_INSTANCE (obj1); |
1139 Lisp_Image_Instance *i2 = XIMAGE_INSTANCE (obj2); | 1139 Lisp_Image_Instance *i2 = XIMAGE_INSTANCE (obj2); |
1140 | 1140 |
1141 ERROR_CHECK_IMAGE_INSTANCE (obj1); | 1141 ERROR_CHECK_IMAGE_INSTANCE (obj1); |
2214 | 2214 |
2215 /************************************************************************/ | 2215 /************************************************************************/ |
2216 /* error helpers */ | 2216 /* error helpers */ |
2217 /************************************************************************/ | 2217 /************************************************************************/ |
2218 DOESNT_RETURN | 2218 DOESNT_RETURN |
2219 signal_image_error (const CIbyte *reason, Lisp_Object frob) | 2219 signal_image_error (const Ascbyte *reason, Lisp_Object frob) |
2220 { | 2220 { |
2221 signal_error (Qimage_conversion_error, reason, frob); | 2221 signal_error (Qimage_conversion_error, reason, frob); |
2222 } | 2222 } |
2223 | 2223 |
2224 DOESNT_RETURN | 2224 DOESNT_RETURN |
2225 signal_image_error_2 (const CIbyte *reason, Lisp_Object frob0, Lisp_Object frob1) | 2225 signal_image_error_2 (const Ascbyte *reason, Lisp_Object frob0, |
2226 Lisp_Object frob1) | |
2226 { | 2227 { |
2227 signal_error_2 (Qimage_conversion_error, reason, frob0, frob1); | 2228 signal_error_2 (Qimage_conversion_error, reason, frob0, frob1); |
2228 } | 2229 } |
2229 | 2230 |
2230 DOESNT_RETURN | 2231 DOESNT_RETURN |
2231 signal_double_image_error (const CIbyte *string1, const CIbyte *string2, | 2232 signal_double_image_error (const Ascbyte *reason1, const Ascbyte *reason2, |
2232 Lisp_Object data) | 2233 Lisp_Object data) |
2233 { | 2234 { |
2234 signal_error_1 (Qimage_conversion_error, | 2235 signal_error_1 (Qimage_conversion_error, |
2235 list3 (build_msg_string (string1), | 2236 list3 (build_msg_string (reason1), |
2236 build_msg_string (string2), | 2237 build_msg_string (reason2), |
2237 data)); | 2238 data)); |
2238 } | 2239 } |
2239 | 2240 |
2240 DOESNT_RETURN | 2241 DOESNT_RETURN |
2241 signal_double_image_error_2 (const CIbyte *string1, const CIbyte *string2, | 2242 signal_double_image_error_2 (const Ascbyte *reason1, const Ascbyte *reason2, |
2242 Lisp_Object data1, Lisp_Object data2) | 2243 Lisp_Object data1, Lisp_Object data2) |
2243 { | 2244 { |
2244 signal_error_1 (Qimage_conversion_error, | 2245 signal_error_1 (Qimage_conversion_error, |
2245 list4 (build_msg_string (string1), | 2246 list4 (build_msg_string (reason1), |
2246 build_msg_string (string2), | 2247 build_msg_string (reason2), |
2247 data1, data2)); | 2248 data1, data2)); |
2248 } | 2249 } |
2249 | 2250 |
2250 /**************************************************************************** | 2251 /**************************************************************************** |
2251 * nothing * | 2252 * nothing * |
2373 query_string_geometry (Lisp_Object string, Lisp_Object face, | 2374 query_string_geometry (Lisp_Object string, Lisp_Object face, |
2374 int* width, int* height, int* descent, Lisp_Object domain) | 2375 int* width, int* height, int* descent, Lisp_Object domain) |
2375 { | 2376 { |
2376 struct font_metric_info fm; | 2377 struct font_metric_info fm; |
2377 unsigned char charsets[NUM_LEADING_BYTES]; | 2378 unsigned char charsets[NUM_LEADING_BYTES]; |
2378 struct face_cachel frame_cachel; | 2379 struct face_cachel cachel; |
2379 struct face_cachel *cachel; | 2380 struct face_cachel *the_cachel; |
2380 Lisp_Object frame = DOMAIN_FRAME (domain); | 2381 Lisp_Object window = DOMAIN_WINDOW (domain); |
2382 Lisp_Object frame = DOMAIN_FRAME (domain); | |
2381 | 2383 |
2382 CHECK_STRING (string); | 2384 CHECK_STRING (string); |
2383 | 2385 |
2384 /* Compute height */ | 2386 /* Compute height */ |
2385 if (height) | 2387 if (height) |
2390 XSTRING_LENGTH (string)); | 2392 XSTRING_LENGTH (string)); |
2391 | 2393 |
2392 /* Fallback to the default face if none was provided. */ | 2394 /* Fallback to the default face if none was provided. */ |
2393 if (!NILP (face)) | 2395 if (!NILP (face)) |
2394 { | 2396 { |
2395 reset_face_cachel (&frame_cachel); | 2397 reset_face_cachel (&cachel); |
2396 update_face_cachel_data (&frame_cachel, frame, face); | 2398 update_face_cachel_data (&cachel, |
2397 cachel = &frame_cachel; | 2399 /* #### NOTE: in fact, I'm not sure if it's |
2400 #### possible to *not* get a window | |
2401 #### here, but you never know... | |
2402 #### -- dvl */ | |
2403 NILP (window) ? frame : window, | |
2404 face); | |
2405 the_cachel = &cachel; | |
2398 } | 2406 } |
2399 else | 2407 else |
2400 { | 2408 the_cachel = WINDOW_FACE_CACHEL (DOMAIN_XWINDOW (domain), |
2401 cachel = WINDOW_FACE_CACHEL (DOMAIN_XWINDOW (domain), | 2409 DEFAULT_INDEX); |
2402 DEFAULT_INDEX); | 2410 |
2403 } | 2411 ensure_face_cachel_complete (the_cachel, domain, charsets); |
2404 | 2412 face_cachel_charset_font_metric_info (the_cachel, charsets, &fm); |
2405 ensure_face_cachel_complete (cachel, domain, charsets); | |
2406 face_cachel_charset_font_metric_info (cachel, charsets, &fm); | |
2407 | 2413 |
2408 *height = fm.ascent + fm.descent; | 2414 *height = fm.ascent + fm.descent; |
2409 /* #### descent only gets set if we query the height as well. */ | 2415 /* #### descent only gets set if we query the height as well. */ |
2410 if (descent) | 2416 if (descent) |
2411 *descent = fm.descent; | 2417 *descent = fm.descent; |
2412 } | 2418 } |
2413 | 2419 |
2414 /* Compute width */ | 2420 /* Compute width */ |
2415 if (width) | 2421 if (width) |
2416 { | 2422 *width = redisplay_text_width_string (domain, |
2417 if (!NILP (face)) | 2423 NILP (face) ? Vdefault_face : face, |
2418 *width = redisplay_frame_text_width_string (XFRAME (frame), | 2424 0, string, 0, -1); |
2419 face, | |
2420 0, string, 0, -1); | |
2421 else | |
2422 *width = redisplay_frame_text_width_string (XFRAME (frame), | |
2423 Vdefault_face, | |
2424 0, string, 0, -1); | |
2425 } | |
2426 } | 2425 } |
2427 | 2426 |
2428 Lisp_Object | 2427 Lisp_Object |
2429 query_string_font (Lisp_Object string, Lisp_Object face, Lisp_Object domain) | 2428 query_string_font (Lisp_Object string, Lisp_Object face, Lisp_Object domain) |
2430 { | 2429 { |
2431 unsigned char charsets[NUM_LEADING_BYTES]; | 2430 unsigned char charsets[NUM_LEADING_BYTES]; |
2432 struct face_cachel frame_cachel; | 2431 struct face_cachel cachel; |
2433 struct face_cachel *cachel; | |
2434 int i; | 2432 int i; |
2435 Lisp_Object frame = DOMAIN_FRAME (domain); | 2433 Lisp_Object window = DOMAIN_WINDOW (domain); |
2434 Lisp_Object frame = DOMAIN_FRAME (domain); | |
2436 | 2435 |
2437 /* Compute string font info */ | 2436 /* Compute string font info */ |
2438 find_charsets_in_ibyte_string (charsets, | 2437 find_charsets_in_ibyte_string (charsets, |
2439 XSTRING_DATA (string), | 2438 XSTRING_DATA (string), |
2440 XSTRING_LENGTH (string)); | 2439 XSTRING_LENGTH (string)); |
2441 | 2440 |
2442 reset_face_cachel (&frame_cachel); | 2441 reset_face_cachel (&cachel); |
2443 update_face_cachel_data (&frame_cachel, frame, face); | 2442 update_face_cachel_data (&cachel, NILP (window) ? frame : window, face); |
2444 cachel = &frame_cachel; | 2443 ensure_face_cachel_complete (&cachel, domain, charsets); |
2445 | |
2446 ensure_face_cachel_complete (cachel, domain, charsets); | |
2447 | 2444 |
2448 for (i = 0; i < NUM_LEADING_BYTES; i++) | 2445 for (i = 0; i < NUM_LEADING_BYTES; i++) |
2449 { | 2446 if (charsets[i]) |
2450 if (charsets[i]) | 2447 return FACE_CACHEL_FONT |
2451 { | 2448 ((&cachel), charset_by_leading_byte (i + MIN_LEADING_BYTE)); |
2452 return FACE_CACHEL_FONT (cachel, | |
2453 charset_by_leading_byte (i + | |
2454 MIN_LEADING_BYTE)); | |
2455 | |
2456 } | |
2457 } | |
2458 | 2449 |
2459 return Qnil; /* NOT REACHED */ | 2450 return Qnil; /* NOT REACHED */ |
2460 } | 2451 } |
2461 | 2452 |
2462 static void | 2453 static void |
2700 { | 2691 { |
2701 Lisp_Object retval; | 2692 Lisp_Object retval; |
2702 int len = (w + 7) / 8 * h; | 2693 int len = (w + 7) / 8 * h; |
2703 | 2694 |
2704 retval = list3 (make_int (w), make_int (h), | 2695 retval = list3 (make_int (w), make_int (h), |
2705 make_ext_string ((Extbyte *) data, len, Qbinary)); | 2696 make_extstring ((Extbyte *) data, len, Qbinary)); |
2706 XFree (data); | 2697 XFree (data); |
2707 return retval; | 2698 return retval; |
2708 } | 2699 } |
2709 | 2700 |
2710 switch (result) | 2701 switch (result) |
2753 && NILP (assq_no_quit (Q_mask_data, alist)) | 2744 && NILP (assq_no_quit (Q_mask_data, alist)) |
2754 && !EQ (file, Qt)) | 2745 && !EQ (file, Qt)) |
2755 { | 2746 { |
2756 mask_file = MAYBE_LISP_CONTYPE_METH | 2747 mask_file = MAYBE_LISP_CONTYPE_METH |
2757 (decode_console_type(console_type, ERROR_ME), | 2748 (decode_console_type(console_type, ERROR_ME), |
2758 locate_pixmap_file, (concat2 (file, build_string ("Mask")))); | 2749 locate_pixmap_file, (concat2 (file, build_ascstring ("Mask")))); |
2759 if (NILP (mask_file)) | 2750 if (NILP (mask_file)) |
2760 mask_file = MAYBE_LISP_CONTYPE_METH | 2751 mask_file = MAYBE_LISP_CONTYPE_METH |
2761 (decode_console_type(console_type, ERROR_ME), | 2752 (decode_console_type(console_type, ERROR_ME), |
2762 locate_pixmap_file, (concat2 (file, build_string ("msk")))); | 2753 locate_pixmap_file, (concat2 (file, build_ascstring ("msk")))); |
2763 } | 2754 } |
2764 | 2755 |
2765 if (!NILP (mask_file)) | 2756 if (!NILP (mask_file)) |
2766 { | 2757 { |
2767 Lisp_Object mask_data = | 2758 Lisp_Object mask_data = |
2940 **********************************************************************/ | 2931 **********************************************************************/ |
2941 | 2932 |
2942 #ifdef HAVE_GTK | 2933 #ifdef HAVE_GTK |
2943 /* Gtk has to be gratuitously different, eh? */ | 2934 /* Gtk has to be gratuitously different, eh? */ |
2944 Lisp_Object | 2935 Lisp_Object |
2945 pixmap_to_lisp_data (Lisp_Object name, int ok_if_data_invalid) | 2936 pixmap_to_lisp_data (Lisp_Object name, int UNUSED (ok_if_data_invalid)) |
2946 { | 2937 { |
2947 return (make_string_from_file (name)); | 2938 return (make_string_from_file (name)); |
2948 } | 2939 } |
2949 #else | 2940 #else |
2950 Lisp_Object | 2941 Lisp_Object |
2954 int result; | 2945 int result; |
2955 Extbyte *fname = 0; | 2946 Extbyte *fname = 0; |
2956 Ibyte *resolved; | 2947 Ibyte *resolved; |
2957 | 2948 |
2958 LISP_PATHNAME_RESOLVE_LINKS (name, resolved); | 2949 LISP_PATHNAME_RESOLVE_LINKS (name, resolved); |
2959 C_STRING_TO_EXTERNAL (resolved, fname, Qfile_name); | 2950 fname = ITEXT_TO_EXTERNAL (resolved, Qfile_name); |
2960 result = XpmReadFileToData (fname, &data); | 2951 result = XpmReadFileToData (fname, &data); |
2961 | 2952 |
2962 if (result == XpmSuccess) | 2953 if (result == XpmSuccess) |
2963 { | 2954 { |
2964 Lisp_Object retval = Qnil; | 2955 Lisp_Object retval = Qnil; |
2965 struct buffer *old_buffer = current_buffer; | 2956 struct buffer *old_buffer = current_buffer; |
2966 Lisp_Object temp_buffer = | 2957 Lisp_Object temp_buffer = |
2967 Fget_buffer_create (build_string (" *pixmap conversion*")); | 2958 Fget_buffer_create (build_ascstring (" *pixmap conversion*")); |
2968 int elt; | 2959 int elt; |
2969 int height, width, ncolors; | 2960 int height, width, ncolors; |
2970 struct gcpro gcpro1, gcpro2, gcpro3; | 2961 struct gcpro gcpro1, gcpro2, gcpro3; |
2971 int speccount = specpdl_depth (); | 2962 int speccount = specpdl_depth (); |
2972 | 2963 |
2974 | 2965 |
2975 specbind (Qinhibit_quit, Qt); | 2966 specbind (Qinhibit_quit, Qt); |
2976 set_buffer_internal (XBUFFER (temp_buffer)); | 2967 set_buffer_internal (XBUFFER (temp_buffer)); |
2977 Ferase_buffer (Qnil); | 2968 Ferase_buffer (Qnil); |
2978 | 2969 |
2979 buffer_insert_c_string (current_buffer, "/* XPM */\r"); | 2970 buffer_insert_ascstring (current_buffer, "/* XPM */\r"); |
2980 buffer_insert_c_string (current_buffer, "static char *pixmap[] = {\r"); | 2971 buffer_insert_ascstring (current_buffer, "static char *pixmap[] = {\r"); |
2981 | 2972 |
2982 sscanf (data[0], "%d %d %d", &height, &width, &ncolors); | 2973 sscanf (data[0], "%d %d %d", &height, &width, &ncolors); |
2983 for (elt = 0; elt <= width + ncolors; elt++) | 2974 for (elt = 0; elt <= width + ncolors; elt++) |
2984 { | 2975 { |
2985 buffer_insert_c_string (current_buffer, "\""); | 2976 buffer_insert_ascstring (current_buffer, "\""); |
2986 buffer_insert_c_string (current_buffer, data[elt]); | 2977 buffer_insert_ascstring (current_buffer, data[elt]); |
2987 | 2978 |
2988 if (elt < width + ncolors) | 2979 if (elt < width + ncolors) |
2989 buffer_insert_c_string (current_buffer, "\",\r"); | 2980 buffer_insert_ascstring (current_buffer, "\",\r"); |
2990 else | 2981 else |
2991 buffer_insert_c_string (current_buffer, "\"};\r"); | 2982 buffer_insert_ascstring (current_buffer, "\"};\r"); |
2992 } | 2983 } |
2993 | 2984 |
2994 retval = Fbuffer_substring (Qnil, Qnil, Qnil); | 2985 retval = Fbuffer_substring (Qnil, Qnil, Qnil); |
2995 XpmFree (data); | 2986 XpmFree (data); |
2996 | 2987 |
3697 int UNUSED (escapeflag)) | 3688 int UNUSED (escapeflag)) |
3698 { | 3689 { |
3699 Lisp_Glyph *glyph = XGLYPH (obj); | 3690 Lisp_Glyph *glyph = XGLYPH (obj); |
3700 | 3691 |
3701 if (print_readably) | 3692 if (print_readably) |
3702 printing_unreadable_object ("#<glyph 0x%x>", glyph->header.uid); | 3693 printing_unreadable_lcrecord (obj, 0); |
3703 | 3694 |
3704 write_fmt_string_lisp (printcharfun, "#<glyph (%s", 1, Fglyph_type (obj)); | 3695 write_fmt_string_lisp (printcharfun, "#<glyph (%s", 1, Fglyph_type (obj)); |
3705 write_fmt_string_lisp (printcharfun, ") %S", 1, glyph->image); | 3696 write_fmt_string_lisp (printcharfun, ") %S", 1, glyph->image); |
3706 write_fmt_string (printcharfun, "0x%x>", glyph->header.uid); | 3697 write_fmt_string (printcharfun, "0x%x>", glyph->header.uid); |
3707 } | 3698 } |
3711 be eq. | 3702 be eq. |
3712 | 3703 |
3713 This isn't concerned with "unspecified" attributes, that's what | 3704 This isn't concerned with "unspecified" attributes, that's what |
3714 #'glyph-differs-from-default-p is for. */ | 3705 #'glyph-differs-from-default-p is for. */ |
3715 static int | 3706 static int |
3716 glyph_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) | 3707 glyph_equal (Lisp_Object obj1, Lisp_Object obj2, int depth, |
3708 int UNUSED (foldcase)) | |
3717 { | 3709 { |
3718 Lisp_Glyph *g1 = XGLYPH (obj1); | 3710 Lisp_Glyph *g1 = XGLYPH (obj1); |
3719 Lisp_Glyph *g2 = XGLYPH (obj2); | 3711 Lisp_Glyph *g2 = XGLYPH (obj2); |
3720 | 3712 |
3721 depth++; | 3713 depth++; |
3722 | 3714 |
3723 return (internal_equal (g1->image, g2->image, depth) && | 3715 return (internal_equal (g1->image, g2->image, depth) && |
3724 internal_equal (g1->contrib_p, g2->contrib_p, depth) && | 3716 internal_equal (g1->contrib_p, g2->contrib_p, depth) && |
3725 internal_equal (g1->baseline, g2->baseline, depth) && | 3717 internal_equal (g1->baseline, g2->baseline, depth) && |
3726 internal_equal (g1->face, g2->face, depth) && | 3718 internal_equal (g1->face, g2->face, depth) && |
3727 !plists_differ (g1->plist, g2->plist, 0, 0, depth + 1)); | 3719 !plists_differ (g1->plist, g2->plist, 0, 0, depth + 1, 0)); |
3728 } | 3720 } |
3729 | 3721 |
3730 static Hashcode | 3722 static Hashcode |
3731 glyph_hash (Lisp_Object obj, int depth) | 3723 glyph_hash (Lisp_Object obj, int depth) |
3732 { | 3724 { |
4277 image_instance_layout (instance, width, height, xoffset, yoffset, domain); | 4269 image_instance_layout (instance, width, height, xoffset, yoffset, domain); |
4278 } | 4270 } |
4279 | 4271 |
4280 | 4272 |
4281 /***************************************************************************** | 4273 /***************************************************************************** |
4282 * glyph cachel functions * | 4274 * glyph cachel functions * |
4283 *****************************************************************************/ | 4275 *****************************************************************************/ |
4276 | |
4277 #define NUM_PRECACHED_GLYPHS 6 | |
4278 #define LOOP_OVER_PRECACHED_GLYPHS \ | |
4279 FROB (Vcontinuation_glyph, CONT_GLYPH_INDEX) \ | |
4280 FROB (Vtruncation_glyph, TRUN_GLYPH_INDEX) \ | |
4281 FROB (Vhscroll_glyph, HSCROLL_GLYPH_INDEX) \ | |
4282 FROB (Vcontrol_arrow_glyph, CONTROL_GLYPH_INDEX) \ | |
4283 FROB (Voctal_escape_glyph, OCT_ESC_GLYPH_INDEX) \ | |
4284 FROB (Vinvisible_text_glyph, INVIS_GLYPH_INDEX) | |
4285 | |
4284 | 4286 |
4285 /* #### All of this is 95% copied from face cachels. Consider | 4287 /* #### All of this is 95% copied from face cachels. Consider |
4286 consolidating. | 4288 consolidating. |
4287 | 4289 |
4288 Why do we need glyph_cachels? Simply because a glyph_cachel captures | 4290 Why do we need glyph_cachels? Simply because a glyph_cachel captures |
4353 | 4355 |
4354 update_glyph_cachel_data (w, glyph, &new_cachel); | 4356 update_glyph_cachel_data (w, glyph, &new_cachel); |
4355 Dynarr_add (w->glyph_cachels, new_cachel); | 4357 Dynarr_add (w->glyph_cachels, new_cachel); |
4356 } | 4358 } |
4357 | 4359 |
4360 #ifdef ERROR_CHECK_GLYPHS | |
4361 | |
4362 /* The precached glyphs should always occur in slots 0 - 5, with each glyph in the | |
4363 slot reserved for it. Meanwhile any other glyphs should always occur in slots | |
4364 6 or greater. */ | |
4365 static void | |
4366 verify_glyph_index (Lisp_Object glyph, glyph_index idx) | |
4367 { | |
4368 if (0) | |
4369 ; | |
4370 #define FROB(glyph_obj, gindex) \ | |
4371 else if (EQ (glyph, glyph_obj)) \ | |
4372 assert (gindex == idx); | |
4373 LOOP_OVER_PRECACHED_GLYPHS | |
4374 else | |
4375 assert (idx >= NUM_PRECACHED_GLYPHS); | |
4376 #undef FROB | |
4377 } | |
4378 | |
4379 #endif /* ERROR_CHECK_GLYPHS */ | |
4380 | |
4358 glyph_index | 4381 glyph_index |
4359 get_glyph_cachel_index (struct window *w, Lisp_Object glyph) | 4382 get_glyph_cachel_index (struct window *w, Lisp_Object glyph) |
4360 { | 4383 { |
4361 int elt; | 4384 int elt; |
4362 | 4385 |
4368 struct glyph_cachel *cachel = | 4391 struct glyph_cachel *cachel = |
4369 Dynarr_atp (w->glyph_cachels, elt); | 4392 Dynarr_atp (w->glyph_cachels, elt); |
4370 | 4393 |
4371 if (EQ (cachel->glyph, glyph) && !NILP (glyph)) | 4394 if (EQ (cachel->glyph, glyph) && !NILP (glyph)) |
4372 { | 4395 { |
4396 #ifdef ERROR_CHECK_GLYPHS | |
4397 verify_glyph_index (glyph, elt); | |
4398 #endif /* ERROR_CHECK_GLYPHS */ | |
4373 update_glyph_cachel_data (w, glyph, cachel); | 4399 update_glyph_cachel_data (w, glyph, cachel); |
4374 return elt; | 4400 return elt; |
4375 } | 4401 } |
4376 } | 4402 } |
4377 | 4403 |
4382 | 4408 |
4383 void | 4409 void |
4384 reset_glyph_cachels (struct window *w) | 4410 reset_glyph_cachels (struct window *w) |
4385 { | 4411 { |
4386 Dynarr_reset (w->glyph_cachels); | 4412 Dynarr_reset (w->glyph_cachels); |
4387 get_glyph_cachel_index (w, Vcontinuation_glyph); | 4413 #define FROB(glyph_obj, gindex) \ |
4388 get_glyph_cachel_index (w, Vtruncation_glyph); | 4414 get_glyph_cachel_index (w, glyph_obj); |
4389 get_glyph_cachel_index (w, Vhscroll_glyph); | 4415 LOOP_OVER_PRECACHED_GLYPHS |
4390 get_glyph_cachel_index (w, Vcontrol_arrow_glyph); | 4416 #undef FROB |
4391 get_glyph_cachel_index (w, Voctal_escape_glyph); | |
4392 get_glyph_cachel_index (w, Vinvisible_text_glyph); | |
4393 } | 4417 } |
4394 | 4418 |
4395 void | 4419 void |
4396 mark_glyph_cachels_as_not_updated (struct window *w) | 4420 mark_glyph_cachels_as_not_updated (struct window *w) |
4397 { | 4421 { |
4398 int elt; | 4422 int elt; |
4399 | 4423 |
4424 /* A previous bug resulted from the glyph cachels never getting reset | |
4425 in the minibuffer window after creation, and another glyph added before | |
4426 we got a chance to add the six normal glyphs that should go first, and | |
4427 we got called with only one glyph present. */ | |
4428 assert (Dynarr_length (w->glyph_cachels) >= NUM_PRECACHED_GLYPHS); | |
4400 /* We need to have a dirty flag to tell if the glyph has changed. | 4429 /* We need to have a dirty flag to tell if the glyph has changed. |
4401 We can check to see if each glyph variable is actually a | 4430 We can check to see if each glyph variable is actually a |
4402 completely different glyph, though. */ | 4431 completely different glyph, though. */ |
4403 #define FROB(glyph_obj, gindex) \ | 4432 #define FROB(glyph_obj, gindex) \ |
4404 update_glyph_cachel_data (w, glyph_obj, \ | 4433 update_glyph_cachel_data (w, glyph_obj, \ |
4405 Dynarr_atp (w->glyph_cachels, gindex)) | 4434 Dynarr_atp (w->glyph_cachels, gindex)); |
4406 | 4435 LOOP_OVER_PRECACHED_GLYPHS |
4407 FROB (Vcontinuation_glyph, CONT_GLYPH_INDEX); | |
4408 FROB (Vtruncation_glyph, TRUN_GLYPH_INDEX); | |
4409 FROB (Vhscroll_glyph, HSCROLL_GLYPH_INDEX); | |
4410 FROB (Vcontrol_arrow_glyph, CONTROL_GLYPH_INDEX); | |
4411 FROB (Voctal_escape_glyph, OCT_ESC_GLYPH_INDEX); | |
4412 FROB (Vinvisible_text_glyph, INVIS_GLYPH_INDEX); | |
4413 #undef FROB | 4436 #undef FROB |
4414 | 4437 |
4415 for (elt = 0; elt < Dynarr_length (w->glyph_cachels); elt++) | 4438 for (elt = 0; elt < Dynarr_length (w->glyph_cachels); elt++) |
4416 { | 4439 { |
4417 Dynarr_atp (w->glyph_cachels, elt)->updated = 0; | 4440 Dynarr_atp (w->glyph_cachels, elt)->updated = 0; |
4450 #endif /* MEMORY_USAGE_STATS */ | 4473 #endif /* MEMORY_USAGE_STATS */ |
4451 | 4474 |
4452 | 4475 |
4453 | 4476 |
4454 /***************************************************************************** | 4477 /***************************************************************************** |
4455 * subwindow cachel functions * | 4478 * subwindow cachel functions * |
4456 *****************************************************************************/ | 4479 *****************************************************************************/ |
4457 /* Subwindows are curious in that you have to physically unmap them to | 4480 /* Subwindows are curious in that you have to physically unmap them to |
4458 not display them. It is problematic deciding what to do in | 4481 not display them. It is problematic deciding what to do in |
4459 redisplay. We have two caches - a per-window instance cache that | 4482 redisplay. We have two caches - a per-window instance cache that |
4460 keeps track of subwindows on a window, these are linked to their | 4483 keeps track of subwindows on a window, these are linked to their |
4547 unmap_subwindow (value); | 4570 unmap_subwindow (value); |
4548 } | 4571 } |
4549 } | 4572 } |
4550 | 4573 |
4551 /***************************************************************************** | 4574 /***************************************************************************** |
4552 * subwindow exposure ignorance * | 4575 * subwindow exposure ignorance * |
4553 *****************************************************************************/ | 4576 *****************************************************************************/ |
4554 /* when we unmap subwindows the associated window system will generate | 4577 /* when we unmap subwindows the associated window system will generate |
4555 expose events. This we do not want as redisplay already copes with | 4578 expose events. This we do not want as redisplay already copes with |
4556 the repainting necessary. Worse, we can get in an endless cycle of | 4579 the repainting necessary. Worse, we can get in an endless cycle of |
4557 redisplay if we are not careful. Thus we keep a per-frame list of | 4580 redisplay if we are not careful. Thus we keep a per-frame list of |