Mercurial > hg > xemacs-beta
comparison src/glyphs.c @ 440:8de8e3f6228a r21-2-28
Import from CVS: tag r21-2-28
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:33:38 +0200 |
parents | 84b14dcb0985 |
children | abe6d1db359e |
comparison
equal
deleted
inserted
replaced
439:357dd071b03c | 440:8de8e3f6228a |
---|---|
166 Lisp_Object d = Dynarr_at (the_image_instantiator_format_entry_dynarr, i). | 166 Lisp_Object d = Dynarr_at (the_image_instantiator_format_entry_dynarr, i). |
167 device; | 167 device; |
168 if ((NILP (d) && NILP (device)) | 168 if ((NILP (d) && NILP (device)) |
169 || | 169 || |
170 (!NILP (device) && | 170 (!NILP (device) && |
171 EQ (CONSOLE_TYPE (XCONSOLE | 171 EQ (CONSOLE_TYPE (XCONSOLE |
172 (DEVICE_CONSOLE (XDEVICE (device)))), d))) | 172 (DEVICE_CONSOLE (XDEVICE (device)))), d))) |
173 return Dynarr_at (the_image_instantiator_format_entry_dynarr, i).meths; | 173 return Dynarr_at (the_image_instantiator_format_entry_dynarr, i).meths; |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
561 { | 561 { |
562 struct gcpro gcpro1; | 562 struct gcpro gcpro1; |
563 struct image_instantiator_methods *meths; | 563 struct image_instantiator_methods *meths; |
564 | 564 |
565 GCPRO1 (instantiator); | 565 GCPRO1 (instantiator); |
566 | 566 |
567 meths = decode_image_instantiator_format (XVECTOR_DATA (instantiator)[0], | 567 meths = decode_image_instantiator_format (XVECTOR_DATA (instantiator)[0], |
568 ERROR_ME); | 568 ERROR_ME); |
569 RETURN_UNGCPRO (IIFORMAT_METH_OR_GIVEN (meths, normalize, | 569 RETURN_UNGCPRO (IIFORMAT_METH_OR_GIVEN (meths, normalize, |
570 (instantiator, contype), | 570 (instantiator, contype), |
571 instantiator)); | 571 instantiator)); |
592 meths = decode_image_instantiator_format (XVECTOR_DATA (instantiator)[0], | 592 meths = decode_image_instantiator_format (XVECTOR_DATA (instantiator)[0], |
593 ERROR_ME); | 593 ERROR_ME); |
594 methp = (int)HAS_IIFORMAT_METH_P (meths, instantiate); | 594 methp = (int)HAS_IIFORMAT_METH_P (meths, instantiate); |
595 MAYBE_IIFORMAT_METH (meths, instantiate, (ii, instantiator, pointer_fg, | 595 MAYBE_IIFORMAT_METH (meths, instantiate, (ii, instantiator, pointer_fg, |
596 pointer_bg, dest_mask, domain)); | 596 pointer_bg, dest_mask, domain)); |
597 | 597 |
598 /* now do device specific instantiation */ | 598 /* now do device specific instantiation */ |
599 meths = decode_device_ii_format (device, XVECTOR_DATA (instantiator)[0], | 599 meths = decode_device_ii_format (device, XVECTOR_DATA (instantiator)[0], |
600 ERROR_ME_NOT); | 600 ERROR_ME_NOT); |
601 | 601 |
602 if (!methp && (!meths || !HAS_IIFORMAT_METH_P (meths, instantiate))) | 602 if (!methp && (!meths || !HAS_IIFORMAT_METH_P (meths, instantiate))) |
618 Lisp_Object Qimage_instancep; | 618 Lisp_Object Qimage_instancep; |
619 | 619 |
620 static Lisp_Object | 620 static Lisp_Object |
621 mark_image_instance (Lisp_Object obj) | 621 mark_image_instance (Lisp_Object obj) |
622 { | 622 { |
623 struct Lisp_Image_Instance *i = XIMAGE_INSTANCE (obj); | 623 Lisp_Image_Instance *i = XIMAGE_INSTANCE (obj); |
624 | 624 |
625 mark_object (i->name); | 625 mark_object (i->name); |
626 /* We don't mark the glyph reference since that would create a | 626 /* We don't mark the glyph reference since that would create a |
627 circularity preventing GC. */ | 627 circularity preventing GC. */ |
628 switch (IMAGE_INSTANCE_TYPE (i)) | 628 switch (IMAGE_INSTANCE_TYPE (i)) |
639 mark_object (IMAGE_INSTANCE_PIXMAP_FG (i)); | 639 mark_object (IMAGE_INSTANCE_PIXMAP_FG (i)); |
640 mark_object (IMAGE_INSTANCE_PIXMAP_BG (i)); | 640 mark_object (IMAGE_INSTANCE_PIXMAP_BG (i)); |
641 break; | 641 break; |
642 | 642 |
643 case IMAGE_WIDGET: | 643 case IMAGE_WIDGET: |
644 case IMAGE_LAYOUT: | |
644 mark_object (IMAGE_INSTANCE_WIDGET_TYPE (i)); | 645 mark_object (IMAGE_INSTANCE_WIDGET_TYPE (i)); |
645 mark_object (IMAGE_INSTANCE_WIDGET_PROPS (i)); | 646 mark_object (IMAGE_INSTANCE_WIDGET_PROPS (i)); |
646 mark_object (IMAGE_INSTANCE_WIDGET_FACE (i)); | 647 mark_object (IMAGE_INSTANCE_WIDGET_FACE (i)); |
647 mark_object (IMAGE_INSTANCE_WIDGET_ITEMS (i)); | 648 mark_object (IMAGE_INSTANCE_WIDGET_ITEMS (i)); |
648 case IMAGE_SUBWINDOW: | 649 case IMAGE_SUBWINDOW: |
649 mark_object (IMAGE_INSTANCE_SUBWINDOW_FRAME (i)); | 650 mark_object (IMAGE_INSTANCE_SUBWINDOW_FRAME (i)); |
650 break; | 651 break; |
651 | 652 |
652 case IMAGE_LAYOUT: | |
653 mark_object (IMAGE_INSTANCE_LAYOUT_CHILDREN (i)); | |
654 mark_object (IMAGE_INSTANCE_LAYOUT_BORDER (i)); | |
655 mark_object (IMAGE_INSTANCE_SUBWINDOW_FRAME (i)); | |
656 break; | |
657 | |
658 default: | 653 default: |
659 break; | 654 break; |
660 } | 655 } |
661 | 656 |
662 MAYBE_DEVMETH (XDEVICE (i->device), mark_image_instance, (i)); | 657 MAYBE_DEVMETH (XDEVICE (i->device), mark_image_instance, (i)); |
667 static void | 662 static void |
668 print_image_instance (Lisp_Object obj, Lisp_Object printcharfun, | 663 print_image_instance (Lisp_Object obj, Lisp_Object printcharfun, |
669 int escapeflag) | 664 int escapeflag) |
670 { | 665 { |
671 char buf[100]; | 666 char buf[100]; |
672 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (obj); | 667 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (obj); |
673 | 668 |
674 if (print_readably) | 669 if (print_readably) |
675 error ("printing unreadable object #<image-instance 0x%x>", | 670 error ("printing unreadable object #<image-instance 0x%x>", |
676 ii->header.uid); | 671 ii->header.uid); |
677 write_c_string ("#<image-instance (", printcharfun); | 672 write_c_string ("#<image-instance (", printcharfun); |
779 description what that frame is. */ | 774 description what that frame is. */ |
780 | 775 |
781 write_c_string (" on #<", printcharfun); | 776 write_c_string (" on #<", printcharfun); |
782 { | 777 { |
783 struct frame* f = XFRAME (IMAGE_INSTANCE_SUBWINDOW_FRAME (ii)); | 778 struct frame* f = XFRAME (IMAGE_INSTANCE_SUBWINDOW_FRAME (ii)); |
784 | 779 |
785 if (!FRAME_LIVE_P (f)) | 780 if (!FRAME_LIVE_P (f)) |
786 write_c_string ("dead", printcharfun); | 781 write_c_string ("dead", printcharfun); |
787 else | 782 else |
788 write_c_string (DEVICE_TYPE_NAME (XDEVICE (FRAME_DEVICE (f))), | 783 write_c_string (DEVICE_TYPE_NAME (XDEVICE (FRAME_DEVICE (f))), |
789 printcharfun); | 784 printcharfun); |
790 | 785 |
791 write_c_string ("-frame ", printcharfun); | 786 write_c_string ("-frame ", printcharfun); |
792 } | 787 } |
793 write_c_string (">", printcharfun); | 788 write_c_string (">", printcharfun); |
794 sprintf (buf, " 0x%p", IMAGE_INSTANCE_SUBWINDOW_ID (ii)); | 789 sprintf (buf, " 0x%p", IMAGE_INSTANCE_SUBWINDOW_ID (ii)); |
795 write_c_string (buf, printcharfun); | 790 write_c_string (buf, printcharfun); |
796 | 791 |
797 break; | 792 break; |
798 | 793 |
799 default: | 794 default: |
800 abort (); | 795 abort (); |
801 } | 796 } |
807 } | 802 } |
808 | 803 |
809 static void | 804 static void |
810 finalize_image_instance (void *header, int for_disksave) | 805 finalize_image_instance (void *header, int for_disksave) |
811 { | 806 { |
812 struct Lisp_Image_Instance *i = (struct Lisp_Image_Instance *) header; | 807 Lisp_Image_Instance *i = (Lisp_Image_Instance *) header; |
813 | 808 |
814 if (IMAGE_INSTANCE_TYPE (i) == IMAGE_NOTHING) | 809 if (IMAGE_INSTANCE_TYPE (i) == IMAGE_NOTHING) |
815 /* objects like this exist at dump time, so don't bomb out. */ | 810 /* objects like this exist at dump time, so don't bomb out. */ |
816 return; | 811 return; |
817 if (for_disksave) finalose (i); | 812 if (for_disksave) finalose (i); |
819 /* do this so that the cachels get reset */ | 814 /* do this so that the cachels get reset */ |
820 if (IMAGE_INSTANCE_TYPE (i) == IMAGE_WIDGET | 815 if (IMAGE_INSTANCE_TYPE (i) == IMAGE_WIDGET |
821 || | 816 || |
822 IMAGE_INSTANCE_TYPE (i) == IMAGE_SUBWINDOW) | 817 IMAGE_INSTANCE_TYPE (i) == IMAGE_SUBWINDOW) |
823 { | 818 { |
824 MARK_FRAME_SUBWINDOWS_CHANGED | 819 MARK_FRAME_SUBWINDOWS_CHANGED |
825 (XFRAME (IMAGE_INSTANCE_SUBWINDOW_FRAME (i))); | 820 (XFRAME (IMAGE_INSTANCE_SUBWINDOW_FRAME (i))); |
826 } | 821 } |
827 | 822 |
828 MAYBE_DEVMETH (XDEVICE (i->device), finalize_image_instance, (i)); | 823 MAYBE_DEVMETH (XDEVICE (i->device), finalize_image_instance, (i)); |
829 } | 824 } |
830 | 825 |
831 static int | 826 static int |
832 image_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) | 827 image_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) |
833 { | 828 { |
834 struct Lisp_Image_Instance *i1 = XIMAGE_INSTANCE (obj1); | 829 Lisp_Image_Instance *i1 = XIMAGE_INSTANCE (obj1); |
835 struct Lisp_Image_Instance *i2 = XIMAGE_INSTANCE (obj2); | 830 Lisp_Image_Instance *i2 = XIMAGE_INSTANCE (obj2); |
836 struct device *d1 = XDEVICE (i1->device); | 831 struct device *d1 = XDEVICE (i1->device); |
837 struct device *d2 = XDEVICE (i2->device); | 832 struct device *d2 = XDEVICE (i2->device); |
838 | 833 |
839 if (d1 != d2) | 834 if (d1 != d2) |
840 return 0; | 835 return 0; |
879 depth + 1))) | 874 depth + 1))) |
880 return 0; | 875 return 0; |
881 break; | 876 break; |
882 | 877 |
883 case IMAGE_WIDGET: | 878 case IMAGE_WIDGET: |
879 case IMAGE_LAYOUT: | |
884 if (!(EQ (IMAGE_INSTANCE_WIDGET_TYPE (i1), | 880 if (!(EQ (IMAGE_INSTANCE_WIDGET_TYPE (i1), |
885 IMAGE_INSTANCE_WIDGET_TYPE (i2)) | 881 IMAGE_INSTANCE_WIDGET_TYPE (i2)) |
886 && IMAGE_INSTANCE_SUBWINDOW_ID (i1) == | 882 && IMAGE_INSTANCE_SUBWINDOW_ID (i1) == |
887 IMAGE_INSTANCE_SUBWINDOW_ID (i2) | 883 IMAGE_INSTANCE_SUBWINDOW_ID (i2) |
888 && internal_equal (IMAGE_INSTANCE_WIDGET_ITEMS (i1), | 884 && internal_equal (IMAGE_INSTANCE_WIDGET_ITEMS (i1), |
892 IMAGE_INSTANCE_WIDGET_PROPS (i2), | 888 IMAGE_INSTANCE_WIDGET_PROPS (i2), |
893 depth + 1) | 889 depth + 1) |
894 )) | 890 )) |
895 return 0; | 891 return 0; |
896 break; | 892 break; |
897 | 893 |
898 case IMAGE_LAYOUT: | |
899 if (IMAGE_INSTANCE_TYPE (i1) == IMAGE_LAYOUT | |
900 && | |
901 !(EQ (IMAGE_INSTANCE_LAYOUT_BORDER (i1), | |
902 IMAGE_INSTANCE_LAYOUT_BORDER (i2)) | |
903 && | |
904 internal_equal (IMAGE_INSTANCE_LAYOUT_CHILDREN (i1), | |
905 IMAGE_INSTANCE_LAYOUT_CHILDREN (i2), | |
906 depth + 1))) | |
907 return 0; | |
908 break; | |
909 | |
910 case IMAGE_SUBWINDOW: | 894 case IMAGE_SUBWINDOW: |
911 if (!(IMAGE_INSTANCE_SUBWINDOW_ID (i1) == | 895 if (!(IMAGE_INSTANCE_SUBWINDOW_ID (i1) == |
912 IMAGE_INSTANCE_SUBWINDOW_ID (i2))) | 896 IMAGE_INSTANCE_SUBWINDOW_ID (i2))) |
913 return 0; | 897 return 0; |
914 break; | 898 break; |
921 } | 905 } |
922 | 906 |
923 static unsigned long | 907 static unsigned long |
924 image_instance_hash (Lisp_Object obj, int depth) | 908 image_instance_hash (Lisp_Object obj, int depth) |
925 { | 909 { |
926 struct Lisp_Image_Instance *i = XIMAGE_INSTANCE (obj); | 910 Lisp_Image_Instance *i = XIMAGE_INSTANCE (obj); |
927 struct device *d = XDEVICE (i->device); | 911 struct device *d = XDEVICE (i->device); |
928 unsigned long hash = HASH3 ((unsigned long) d, | 912 unsigned long hash = HASH3 ((unsigned long) d, |
929 IMAGE_INSTANCE_WIDTH (i), | 913 IMAGE_INSTANCE_WIDTH (i), |
930 IMAGE_INSTANCE_HEIGHT (i)); | 914 IMAGE_INSTANCE_HEIGHT (i)); |
931 | 915 |
947 internal_hash (IMAGE_INSTANCE_PIXMAP_FILENAME (i), | 931 internal_hash (IMAGE_INSTANCE_PIXMAP_FILENAME (i), |
948 depth + 1)); | 932 depth + 1)); |
949 break; | 933 break; |
950 | 934 |
951 case IMAGE_WIDGET: | 935 case IMAGE_WIDGET: |
952 hash = HASH4 (hash, | 936 case IMAGE_LAYOUT: |
937 hash = HASH4 (hash, | |
953 internal_hash (IMAGE_INSTANCE_WIDGET_TYPE (i), depth + 1), | 938 internal_hash (IMAGE_INSTANCE_WIDGET_TYPE (i), depth + 1), |
954 internal_hash (IMAGE_INSTANCE_WIDGET_PROPS (i), depth + 1), | 939 internal_hash (IMAGE_INSTANCE_WIDGET_PROPS (i), depth + 1), |
955 internal_hash (IMAGE_INSTANCE_WIDGET_ITEMS (i), depth + 1)); | 940 internal_hash (IMAGE_INSTANCE_WIDGET_ITEMS (i), depth + 1)); |
956 case IMAGE_SUBWINDOW: | 941 case IMAGE_SUBWINDOW: |
957 hash = HASH2 (hash, (int) IMAGE_INSTANCE_SUBWINDOW_ID (i)); | 942 hash = HASH2 (hash, (int) IMAGE_INSTANCE_SUBWINDOW_ID (i)); |
958 break; | 943 break; |
959 | 944 |
960 case IMAGE_LAYOUT: | |
961 hash = HASH3 (hash, | |
962 internal_hash (IMAGE_INSTANCE_LAYOUT_BORDER (i), depth + 1), | |
963 internal_hash (IMAGE_INSTANCE_LAYOUT_CHILDREN (i), | |
964 depth + 1)); | |
965 break; | |
966 | |
967 default: | 945 default: |
968 abort (); | 946 abort (); |
969 } | 947 } |
970 | 948 |
971 return HASH2 (hash, DEVMETH_OR_GIVEN (d, image_instance_hash, (i, depth), | 949 return HASH2 (hash, DEVMETH_OR_GIVEN (d, image_instance_hash, (i, depth), |
974 | 952 |
975 DEFINE_LRECORD_IMPLEMENTATION ("image-instance", image_instance, | 953 DEFINE_LRECORD_IMPLEMENTATION ("image-instance", image_instance, |
976 mark_image_instance, print_image_instance, | 954 mark_image_instance, print_image_instance, |
977 finalize_image_instance, image_instance_equal, | 955 finalize_image_instance, image_instance_equal, |
978 image_instance_hash, 0, | 956 image_instance_hash, 0, |
979 struct Lisp_Image_Instance); | 957 Lisp_Image_Instance); |
980 | 958 |
981 static Lisp_Object | 959 static Lisp_Object |
982 allocate_image_instance (Lisp_Object device, Lisp_Object glyph) | 960 allocate_image_instance (Lisp_Object device, Lisp_Object glyph) |
983 { | 961 { |
984 struct Lisp_Image_Instance *lp = | 962 Lisp_Image_Instance *lp = |
985 alloc_lcrecord_type (struct Lisp_Image_Instance, &lrecord_image_instance); | 963 alloc_lcrecord_type (Lisp_Image_Instance, &lrecord_image_instance); |
986 Lisp_Object val; | 964 Lisp_Object val; |
987 | 965 |
988 zero_lcrecord (lp); | 966 zero_lcrecord (lp); |
989 lp->device = device; | 967 lp->device = device; |
990 lp->type = IMAGE_NOTHING; | 968 lp->type = IMAGE_NOTHING; |
1239 If DEST-TYPES is omitted, all possible types are allowed. | 1217 If DEST-TYPES is omitted, all possible types are allowed. |
1240 | 1218 |
1241 NO-ERROR controls what happens when the image cannot be generated. | 1219 NO-ERROR controls what happens when the image cannot be generated. |
1242 If nil, an error message is generated. If t, no messages are | 1220 If nil, an error message is generated. If t, no messages are |
1243 generated and this function returns nil. If anything else, a warning | 1221 generated and this function returns nil. If anything else, a warning |
1244 message is generated and this function returns nil. | 1222 message is generated and this function returns nil. |
1245 */ | 1223 */ |
1246 (data, device, dest_types, no_error)) | 1224 (data, device, dest_types, no_error)) |
1247 { | 1225 { |
1248 Error_behavior errb = decode_error_behavior_flag (no_error); | 1226 Error_behavior errb = decode_error_behavior_flag (no_error); |
1249 | 1227 |
1294 else | 1272 else |
1295 return Qnil; | 1273 return Qnil; |
1296 } | 1274 } |
1297 | 1275 |
1298 DEFUN ("image-instance-property", Fimage_instance_property, 2, 2, 0, /* | 1276 DEFUN ("image-instance-property", Fimage_instance_property, 2, 2, 0, /* |
1299 Return the given property of the given image instance. | 1277 Return the given property of the given image instance. |
1300 Returns nil if the property or the property method do not exist for | 1278 Returns nil if the property or the property method do not exist for |
1301 the image instance in the domain. | 1279 the image instance in the domain. |
1302 */ | 1280 */ |
1303 (image_instance, prop)) | 1281 (image_instance, prop)) |
1304 { | 1282 { |
1305 struct Lisp_Image_Instance* ii; | 1283 Lisp_Image_Instance* ii; |
1306 Lisp_Object type, ret; | 1284 Lisp_Object type, ret; |
1307 struct image_instantiator_methods* meths; | 1285 struct image_instantiator_methods* meths; |
1308 | 1286 |
1309 CHECK_IMAGE_INSTANCE (image_instance); | 1287 CHECK_IMAGE_INSTANCE (image_instance); |
1310 CHECK_SYMBOL (prop); | 1288 CHECK_SYMBOL (prop); |
1311 ii = XIMAGE_INSTANCE (image_instance); | 1289 ii = XIMAGE_INSTANCE (image_instance); |
1312 | 1290 |
1313 /* ... then try device specific methods ... */ | 1291 /* ... then try device specific methods ... */ |
1314 type = encode_image_instance_type (IMAGE_INSTANCE_TYPE (ii)); | 1292 type = encode_image_instance_type (IMAGE_INSTANCE_TYPE (ii)); |
1315 meths = decode_device_ii_format (IMAGE_INSTANCE_DEVICE (ii), | 1293 meths = decode_device_ii_format (IMAGE_INSTANCE_DEVICE (ii), |
1316 type, ERROR_ME_NOT); | 1294 type, ERROR_ME_NOT); |
1317 if (meths && HAS_IIFORMAT_METH_P (meths, property) | 1295 if (meths && HAS_IIFORMAT_METH_P (meths, property) |
1318 && | 1296 && |
1319 !UNBOUNDP (ret = IIFORMAT_METH (meths, property, (image_instance, prop)))) | 1297 !UNBOUNDP (ret = IIFORMAT_METH (meths, property, (image_instance, prop)))) |
1320 { | 1298 { |
1321 return ret; | 1299 return ret; |
1322 } | 1300 } |
1323 /* ... then format specific methods ... */ | 1301 /* ... then format specific methods ... */ |
1331 /* ... then fail */ | 1309 /* ... then fail */ |
1332 return Qnil; | 1310 return Qnil; |
1333 } | 1311 } |
1334 | 1312 |
1335 DEFUN ("set-image-instance-property", Fset_image_instance_property, 3, 3, 0, /* | 1313 DEFUN ("set-image-instance-property", Fset_image_instance_property, 3, 3, 0, /* |
1336 Set the given property of the given image instance. | 1314 Set the given property of the given image instance. |
1337 Does nothing if the property or the property method do not exist for | 1315 Does nothing if the property or the property method do not exist for |
1338 the image instance in the domain. | 1316 the image instance in the domain. |
1339 */ | 1317 */ |
1340 (image_instance, prop, val)) | 1318 (image_instance, prop, val)) |
1341 { | 1319 { |
1342 struct Lisp_Image_Instance* ii; | 1320 Lisp_Image_Instance* ii; |
1343 Lisp_Object type, ret; | 1321 Lisp_Object type, ret; |
1344 struct image_instantiator_methods* meths; | 1322 struct image_instantiator_methods* meths; |
1345 | 1323 |
1346 CHECK_IMAGE_INSTANCE (image_instance); | 1324 CHECK_IMAGE_INSTANCE (image_instance); |
1347 CHECK_SYMBOL (prop); | 1325 CHECK_SYMBOL (prop); |
1348 ii = XIMAGE_INSTANCE (image_instance); | 1326 ii = XIMAGE_INSTANCE (image_instance); |
1349 type = encode_image_instance_type (IMAGE_INSTANCE_TYPE (ii)); | 1327 type = encode_image_instance_type (IMAGE_INSTANCE_TYPE (ii)); |
1350 /* try device specific methods first ... */ | 1328 /* try device specific methods first ... */ |
1351 meths = decode_device_ii_format (IMAGE_INSTANCE_DEVICE (ii), | 1329 meths = decode_device_ii_format (IMAGE_INSTANCE_DEVICE (ii), |
1352 type, ERROR_ME_NOT); | 1330 type, ERROR_ME_NOT); |
1353 if (meths && HAS_IIFORMAT_METH_P (meths, set_property) | 1331 if (meths && HAS_IIFORMAT_METH_P (meths, set_property) |
1354 && | 1332 && |
1355 !UNBOUNDP (ret = | 1333 !UNBOUNDP (ret = |
1356 IIFORMAT_METH (meths, set_property, (image_instance, prop, val)))) | 1334 IIFORMAT_METH (meths, set_property, (image_instance, prop, val)))) |
1357 { | 1335 { |
1358 val = ret; | 1336 val = ret; |
1359 } | 1337 } |
1360 else | 1338 else |
1361 { | 1339 { |
1362 /* ... then format specific methods ... */ | 1340 /* ... then format specific methods ... */ |
1363 meths = decode_device_ii_format (Qnil, type, ERROR_ME_NOT); | 1341 meths = decode_device_ii_format (Qnil, type, ERROR_ME_NOT); |
1364 if (meths && HAS_IIFORMAT_METH_P (meths, set_property) | 1342 if (meths && HAS_IIFORMAT_METH_P (meths, set_property) |
1365 && | 1343 && |
1366 !UNBOUNDP (ret = | 1344 !UNBOUNDP (ret = |
1367 IIFORMAT_METH (meths, set_property, (image_instance, prop, val)))) | 1345 IIFORMAT_METH (meths, set_property, (image_instance, prop, val)))) |
1368 { | 1346 { |
1369 val = ret; | 1347 val = ret; |
1370 } | 1348 } |
1371 else | 1349 else |
1372 { | 1350 { |
1373 val = Qnil; | 1351 val = Qnil; |
1374 } | 1352 } |
1375 } | 1353 } |
1376 | 1354 |
1377 /* Make sure the image instance gets redisplayed. */ | 1355 /* Make sure the image instance gets redisplayed. |
1356 | |
1357 ### This currently does not change the dirty state of an | |
1358 enclosing layout which may be bad. */ | |
1378 MARK_IMAGE_INSTANCE_CHANGED (ii); | 1359 MARK_IMAGE_INSTANCE_CHANGED (ii); |
1379 MARK_SUBWINDOWS_STATE_CHANGED; | 1360 MARK_SUBWINDOWS_STATE_CHANGED; |
1380 MARK_GLYPHS_CHANGED; | 1361 MARK_GLYPHS_CHANGED; |
1381 | 1362 |
1382 return val; | 1363 return val; |
1549 return XIMAGE_INSTANCE_PIXMAP_FG (image_instance); | 1530 return XIMAGE_INSTANCE_PIXMAP_FG (image_instance); |
1550 | 1531 |
1551 case IMAGE_WIDGET: | 1532 case IMAGE_WIDGET: |
1552 return FACE_FOREGROUND ( | 1533 return FACE_FOREGROUND ( |
1553 XIMAGE_INSTANCE_WIDGET_FACE (image_instance), | 1534 XIMAGE_INSTANCE_WIDGET_FACE (image_instance), |
1554 XIMAGE_INSTANCE_SUBWINDOW_FRAME | 1535 XIMAGE_INSTANCE_SUBWINDOW_FRAME |
1555 (image_instance)); | 1536 (image_instance)); |
1556 | 1537 |
1557 default: | 1538 default: |
1558 return Qnil; | 1539 return Qnil; |
1559 } | 1540 } |
1576 return XIMAGE_INSTANCE_PIXMAP_BG (image_instance); | 1557 return XIMAGE_INSTANCE_PIXMAP_BG (image_instance); |
1577 | 1558 |
1578 case IMAGE_WIDGET: | 1559 case IMAGE_WIDGET: |
1579 return FACE_BACKGROUND ( | 1560 return FACE_BACKGROUND ( |
1580 XIMAGE_INSTANCE_WIDGET_FACE (image_instance), | 1561 XIMAGE_INSTANCE_WIDGET_FACE (image_instance), |
1581 XIMAGE_INSTANCE_SUBWINDOW_FRAME | 1562 XIMAGE_INSTANCE_SUBWINDOW_FRAME |
1582 (image_instance)); | 1563 (image_instance)); |
1583 | 1564 |
1584 default: | 1565 default: |
1585 return Qnil; | 1566 return Qnil; |
1586 } | 1567 } |
1626 /************************************************************************/ | 1607 /************************************************************************/ |
1627 | 1608 |
1628 /* Find out desired geometry of the image instance. If there is no | 1609 /* Find out desired geometry of the image instance. If there is no |
1629 special function then just return the width and / or height. */ | 1610 special function then just return the width and / or height. */ |
1630 void | 1611 void |
1631 image_instance_query_geometry (Lisp_Object image_instance, | 1612 image_instance_query_geometry (Lisp_Object image_instance, |
1632 unsigned int* width, unsigned int* height, | 1613 unsigned int* width, unsigned int* height, |
1633 enum image_instance_geometry disp, | 1614 enum image_instance_geometry disp, |
1634 Lisp_Object domain) | 1615 Lisp_Object domain) |
1635 { | 1616 { |
1636 struct Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance); | 1617 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance); |
1637 Lisp_Object type; | 1618 Lisp_Object type; |
1638 struct image_instantiator_methods* meths; | 1619 struct image_instantiator_methods* meths; |
1639 | 1620 |
1640 type = encode_image_instance_type (IMAGE_INSTANCE_TYPE (ii)); | 1621 type = encode_image_instance_type (IMAGE_INSTANCE_TYPE (ii)); |
1641 meths = decode_device_ii_format (Qnil, type, ERROR_ME_NOT); | 1622 meths = decode_device_ii_format (Qnil, type, ERROR_ME_NOT); |
1642 | 1623 |
1643 if (meths && HAS_IIFORMAT_METH_P (meths, query_geometry)) | 1624 if (meths && HAS_IIFORMAT_METH_P (meths, query_geometry)) |
1644 { | 1625 { |
1645 IIFORMAT_METH (meths, query_geometry, (image_instance, width, height, | 1626 IIFORMAT_METH (meths, query_geometry, (image_instance, width, height, |
1646 disp, domain)); | 1627 disp, domain)); |
1647 } | 1628 } |
1648 else | 1629 else |
1649 { | 1630 { |
1650 if (width) | 1631 if (width) |
1660 function relatively simple to take account of that. An alternative | 1641 function relatively simple to take account of that. An alternative |
1661 approach is to consider separately the two cases, one where you | 1642 approach is to consider separately the two cases, one where you |
1662 don't mind what size you have (normal widgets) and one where you | 1643 don't mind what size you have (normal widgets) and one where you |
1663 want to specifiy something (layout widgets). */ | 1644 want to specifiy something (layout widgets). */ |
1664 void | 1645 void |
1665 image_instance_layout (Lisp_Object image_instance, | 1646 image_instance_layout (Lisp_Object image_instance, |
1666 unsigned int width, unsigned int height, | 1647 unsigned int width, unsigned int height, |
1667 Lisp_Object domain) | 1648 Lisp_Object domain) |
1668 { | 1649 { |
1669 struct Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance); | 1650 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance); |
1670 Lisp_Object type; | 1651 Lisp_Object type; |
1671 struct image_instantiator_methods* meths; | 1652 struct image_instantiator_methods* meths; |
1672 | 1653 |
1673 type = encode_image_instance_type (IMAGE_INSTANCE_TYPE (ii)); | 1654 type = encode_image_instance_type (IMAGE_INSTANCE_TYPE (ii)); |
1674 meths = decode_device_ii_format (Qnil, type, ERROR_ME_NOT); | 1655 meths = decode_device_ii_format (Qnil, type, ERROR_ME_NOT); |
1681 unsigned int dwidth, dheight; | 1662 unsigned int dwidth, dheight; |
1682 | 1663 |
1683 /* Get the desired geometry. */ | 1664 /* Get the desired geometry. */ |
1684 if (meths && HAS_IIFORMAT_METH_P (meths, query_geometry)) | 1665 if (meths && HAS_IIFORMAT_METH_P (meths, query_geometry)) |
1685 { | 1666 { |
1686 IIFORMAT_METH (meths, query_geometry, (image_instance, &dwidth, &dheight, | 1667 IIFORMAT_METH (meths, query_geometry, (image_instance, &dwidth, &dheight, |
1687 IMAGE_DESIRED_GEOMETRY, | 1668 IMAGE_DESIRED_GEOMETRY, |
1688 domain)); | 1669 domain)); |
1689 } | 1670 } |
1690 else | 1671 else |
1691 { | 1672 { |
1692 dwidth = IMAGE_INSTANCE_WIDTH (ii); | 1673 dwidth = IMAGE_INSTANCE_WIDTH (ii); |
1702 | 1683 |
1703 /* At this point width and height should contain sane values. Thus | 1684 /* At this point width and height should contain sane values. Thus |
1704 we set the glyph geometry and lay it out. */ | 1685 we set the glyph geometry and lay it out. */ |
1705 IMAGE_INSTANCE_WIDTH (ii) = width; | 1686 IMAGE_INSTANCE_WIDTH (ii) = width; |
1706 IMAGE_INSTANCE_HEIGHT (ii) = height; | 1687 IMAGE_INSTANCE_HEIGHT (ii) = height; |
1707 | 1688 |
1708 if (meths && HAS_IIFORMAT_METH_P (meths, layout)) | 1689 if (meths && HAS_IIFORMAT_METH_P (meths, layout)) |
1709 { | 1690 { |
1710 IIFORMAT_METH (meths, layout, (image_instance, width, height, domain)); | 1691 IIFORMAT_METH (meths, layout, (image_instance, width, height, domain)); |
1711 } | 1692 } |
1712 /* else no change to the geometry. */ | 1693 /* else no change to the geometry. */ |
1694 | |
1695 XIMAGE_INSTANCE_DIRTYP (image_instance) = 0; | |
1696 } | |
1697 | |
1698 /* | |
1699 * Mark image instance in W as dirty if (a) W's faces have changed and | |
1700 * (b) GLYPH_OR_II instance in W is a string. | |
1701 * | |
1702 * Return non-zero if instance has been marked dirty. | |
1703 */ | |
1704 int | |
1705 invalidate_glyph_geometry_maybe (Lisp_Object glyph_or_ii, struct window* w) | |
1706 { | |
1707 if (XFRAME(WINDOW_FRAME(w))->faces_changed) | |
1708 { | |
1709 Lisp_Object image = glyph_or_ii; | |
1710 | |
1711 if (GLYPHP (glyph_or_ii)) | |
1712 { | |
1713 Lisp_Object window; | |
1714 XSETWINDOW (window, w); | |
1715 image = glyph_image_instance (glyph_or_ii, window, ERROR_ME_NOT, 1); | |
1716 } | |
1717 | |
1718 if (TEXT_IMAGE_INSTANCEP (image)) | |
1719 { | |
1720 XIMAGE_INSTANCE_DIRTYP (image) = 1; | |
1721 if (GLYPHP (glyph_or_ii)) | |
1722 XGLYPH_DIRTYP (glyph_or_ii) = 1; | |
1723 return 1; | |
1724 } | |
1725 } | |
1726 | |
1727 return 0; | |
1713 } | 1728 } |
1714 | 1729 |
1715 | 1730 |
1716 /************************************************************************/ | 1731 /************************************************************************/ |
1717 /* error helpers */ | 1732 /* error helpers */ |
1743 static void | 1758 static void |
1744 nothing_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 1759 nothing_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
1745 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1760 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1746 int dest_mask, Lisp_Object domain) | 1761 int dest_mask, Lisp_Object domain) |
1747 { | 1762 { |
1748 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1763 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1749 | 1764 |
1750 if (dest_mask & IMAGE_NOTHING_MASK) | 1765 if (dest_mask & IMAGE_NOTHING_MASK) |
1751 IMAGE_INSTANCE_TYPE (ii) = IMAGE_NOTHING; | 1766 IMAGE_INSTANCE_TYPE (ii) = IMAGE_NOTHING; |
1752 else | 1767 else |
1753 incompatible_image_types (instantiator, dest_mask, IMAGE_NOTHING_MASK); | 1768 incompatible_image_types (instantiator, dest_mask, IMAGE_NOTHING_MASK); |
1813 string_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 1828 string_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
1814 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1829 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1815 int dest_mask, Lisp_Object domain) | 1830 int dest_mask, Lisp_Object domain) |
1816 { | 1831 { |
1817 Lisp_Object string = find_keyword_in_vector (instantiator, Q_data); | 1832 Lisp_Object string = find_keyword_in_vector (instantiator, Q_data); |
1818 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1833 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1819 | 1834 |
1820 /* Should never get here with a domain other than a window. */ | 1835 /* Should never get here with a domain other than a window. */ |
1821 assert (!NILP (string) && WINDOWP (domain)); | 1836 assert (!NILP (string) && WINDOWP (domain)); |
1822 if (dest_mask & IMAGE_TEXT_MASK) | 1837 if (dest_mask & IMAGE_TEXT_MASK) |
1823 { | 1838 { |
1824 IMAGE_INSTANCE_TYPE (ii) = IMAGE_TEXT; | 1839 IMAGE_INSTANCE_TYPE (ii) = IMAGE_TEXT; |
1833 everything. Note that the following methods are for text not string | 1848 everything. Note that the following methods are for text not string |
1834 since that is what the instantiated type is. The first method is a | 1849 since that is what the instantiated type is. The first method is a |
1835 helper that is used elsewhere for calculating text geometry. */ | 1850 helper that is used elsewhere for calculating text geometry. */ |
1836 void | 1851 void |
1837 query_string_geometry (Lisp_Object string, Lisp_Object face, | 1852 query_string_geometry (Lisp_Object string, Lisp_Object face, |
1838 unsigned int* width, unsigned int* height, | 1853 unsigned int* width, unsigned int* height, |
1839 unsigned int* descent, Lisp_Object domain) | 1854 unsigned int* descent, Lisp_Object domain) |
1840 { | 1855 { |
1841 struct font_metric_info fm; | 1856 struct font_metric_info fm; |
1842 unsigned char charsets[NUM_LEADING_BYTES]; | 1857 unsigned char charsets[NUM_LEADING_BYTES]; |
1843 struct face_cachel frame_cachel; | 1858 struct face_cachel frame_cachel; |
1849 { | 1864 { |
1850 /* Compute string metric info */ | 1865 /* Compute string metric info */ |
1851 find_charsets_in_bufbyte_string (charsets, | 1866 find_charsets_in_bufbyte_string (charsets, |
1852 XSTRING_DATA (string), | 1867 XSTRING_DATA (string), |
1853 XSTRING_LENGTH (string)); | 1868 XSTRING_LENGTH (string)); |
1854 | 1869 |
1855 /* Fallback to the default face if none was provided. */ | 1870 /* Fallback to the default face if none was provided. */ |
1856 if (!NILP (face)) | 1871 if (!NILP (face)) |
1857 { | 1872 { |
1858 reset_face_cachel (&frame_cachel); | 1873 reset_face_cachel (&frame_cachel); |
1859 update_face_cachel_data (&frame_cachel, frame, face); | 1874 update_face_cachel_data (&frame_cachel, frame, face); |
1861 } | 1876 } |
1862 else | 1877 else |
1863 { | 1878 { |
1864 cachel = WINDOW_FACE_CACHEL (XWINDOW (domain), DEFAULT_INDEX); | 1879 cachel = WINDOW_FACE_CACHEL (XWINDOW (domain), DEFAULT_INDEX); |
1865 } | 1880 } |
1866 | 1881 |
1867 ensure_face_cachel_complete (cachel, domain, charsets); | 1882 ensure_face_cachel_complete (cachel, domain, charsets); |
1868 face_cachel_charset_font_metric_info (cachel, charsets, &fm); | 1883 face_cachel_charset_font_metric_info (cachel, charsets, &fm); |
1869 | 1884 |
1870 *height = fm.ascent + fm.descent; | 1885 *height = fm.ascent + fm.descent; |
1871 /* #### descent only gets set if we query the height as well. */ | 1886 /* #### descent only gets set if we query the height as well. */ |
1872 if (descent) | 1887 if (descent) |
1873 *descent = fm.descent; | 1888 *descent = fm.descent; |
1874 } | 1889 } |
1875 | 1890 |
1876 /* Compute width */ | 1891 /* Compute width */ |
1877 if (width) | 1892 if (width) |
1878 { | 1893 { |
1879 if (!NILP (face)) | 1894 if (!NILP (face)) |
1880 *width = redisplay_frame_text_width_string (XFRAME (frame), | 1895 *width = redisplay_frame_text_width_string (XFRAME (frame), |
1898 | 1913 |
1899 /* Compute string font info */ | 1914 /* Compute string font info */ |
1900 find_charsets_in_bufbyte_string (charsets, | 1915 find_charsets_in_bufbyte_string (charsets, |
1901 XSTRING_DATA (string), | 1916 XSTRING_DATA (string), |
1902 XSTRING_LENGTH (string)); | 1917 XSTRING_LENGTH (string)); |
1903 | 1918 |
1904 reset_face_cachel (&frame_cachel); | 1919 reset_face_cachel (&frame_cachel); |
1905 update_face_cachel_data (&frame_cachel, frame, face); | 1920 update_face_cachel_data (&frame_cachel, frame, face); |
1906 cachel = &frame_cachel; | 1921 cachel = &frame_cachel; |
1907 | 1922 |
1908 ensure_face_cachel_complete (cachel, domain, charsets); | 1923 ensure_face_cachel_complete (cachel, domain, charsets); |
1909 | 1924 |
1910 for (i = 0; i < NUM_LEADING_BYTES; i++) | 1925 for (i = 0; i < NUM_LEADING_BYTES; i++) |
1911 { | 1926 { |
1912 if (charsets[i]) | 1927 if (charsets[i]) |
1913 { | 1928 { |
1914 return FACE_CACHEL_FONT (cachel, | 1929 return FACE_CACHEL_FONT (cachel, |
1915 CHARSET_BY_LEADING_BYTE (i + | 1930 CHARSET_BY_LEADING_BYTE (i + |
1916 MIN_LEADING_BYTE)); | 1931 MIN_LEADING_BYTE)); |
1917 | 1932 |
1918 } | 1933 } |
1919 } | 1934 } |
1920 | 1935 |
1921 return Qnil; /* NOT REACHED */ | 1936 return Qnil; /* NOT REACHED */ |
1922 } | 1937 } |
1923 | 1938 |
1924 static void | 1939 static void |
1925 text_query_geometry (Lisp_Object image_instance, | 1940 text_query_geometry (Lisp_Object image_instance, |
1926 unsigned int* width, unsigned int* height, | 1941 unsigned int* width, unsigned int* height, |
1927 enum image_instance_geometry disp, Lisp_Object domain) | 1942 enum image_instance_geometry disp, Lisp_Object domain) |
1928 { | 1943 { |
1929 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1944 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1930 unsigned int descent = 0; | 1945 unsigned int descent = 0; |
1931 | 1946 |
1932 query_string_geometry (IMAGE_INSTANCE_TEXT_STRING (ii), | 1947 query_string_geometry (IMAGE_INSTANCE_TEXT_STRING (ii), |
1933 IMAGE_INSTANCE_FACE (ii), | 1948 IMAGE_INSTANCE_FACE (ii), |
1934 width, height, &descent, domain); | 1949 width, height, &descent, domain); |
1941 /* set the properties of a string */ | 1956 /* set the properties of a string */ |
1942 static Lisp_Object | 1957 static Lisp_Object |
1943 text_set_property (Lisp_Object image_instance, Lisp_Object prop, | 1958 text_set_property (Lisp_Object image_instance, Lisp_Object prop, |
1944 Lisp_Object val) | 1959 Lisp_Object val) |
1945 { | 1960 { |
1946 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1961 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1947 | 1962 |
1948 if (EQ (prop, Q_data)) | 1963 if (EQ (prop, Q_data)) |
1949 { | 1964 { |
1950 CHECK_STRING (val); | 1965 CHECK_STRING (val); |
1951 IMAGE_INSTANCE_TEXT_STRING (ii) = val; | 1966 IMAGE_INSTANCE_TEXT_STRING (ii) = val; |
1980 { | 1995 { |
1981 /* #### implement this */ | 1996 /* #### implement this */ |
1982 warn_when_safe (Qunimplemented, Qnotice, | 1997 warn_when_safe (Qunimplemented, Qnotice, |
1983 "`formatted-string' not yet implemented; assuming `string'"); | 1998 "`formatted-string' not yet implemented; assuming `string'"); |
1984 | 1999 |
1985 string_instantiate (image_instance, instantiator, | 2000 string_instantiate (image_instance, instantiator, |
1986 pointer_fg, pointer_bg, dest_mask, domain); | 2001 pointer_fg, pointer_bg, dest_mask, domain); |
1987 } | 2002 } |
1988 | 2003 |
1989 | 2004 |
1990 /************************************************************************/ | 2005 /************************************************************************/ |
2147 unsigned int w, h; | 2162 unsigned int w, h; |
2148 Extbyte *data; | 2163 Extbyte *data; |
2149 int result; | 2164 int result; |
2150 CONST char *filename_ext; | 2165 CONST char *filename_ext; |
2151 | 2166 |
2152 GET_C_STRING_FILENAME_DATA_ALLOCA (name, filename_ext); | 2167 TO_EXTERNAL_FORMAT (LISP_STRING, name, |
2168 C_STRING_ALLOCA, filename_ext, | |
2169 Qfile_name); | |
2153 result = read_bitmap_data_from_file (filename_ext, &w, &h, | 2170 result = read_bitmap_data_from_file (filename_ext, &w, &h, |
2154 &data, xhot, yhot); | 2171 &data, xhot, yhot); |
2155 | 2172 |
2156 if (result == BitmapSuccess) | 2173 if (result == BitmapSuccess) |
2157 { | 2174 { |
2158 Lisp_Object retval; | 2175 Lisp_Object retval; |
2159 int len = (w + 7) / 8 * h; | 2176 int len = (w + 7) / 8 * h; |
2160 | 2177 |
2161 retval = list3 (make_int (w), make_int (h), | 2178 retval = list3 (make_int (w), make_int (h), |
2162 make_ext_string (data, len, FORMAT_BINARY)); | 2179 make_ext_string (data, len, Qbinary)); |
2163 XFree ((char *) data); | 2180 XFree ((char *) data); |
2164 return retval; | 2181 return retval; |
2165 } | 2182 } |
2166 | 2183 |
2167 switch (result) | 2184 switch (result) |
2390 pixmap_to_lisp_data (Lisp_Object name, int ok_if_data_invalid) | 2407 pixmap_to_lisp_data (Lisp_Object name, int ok_if_data_invalid) |
2391 { | 2408 { |
2392 char **data; | 2409 char **data; |
2393 int result; | 2410 int result; |
2394 char *fname = 0; | 2411 char *fname = 0; |
2395 | 2412 |
2396 GET_C_STRING_FILENAME_DATA_ALLOCA (name, fname); | 2413 TO_EXTERNAL_FORMAT (LISP_STRING, name, |
2414 C_STRING_ALLOCA, fname, | |
2415 Qfile_name); | |
2397 result = XpmReadFileToData (fname, &data); | 2416 result = XpmReadFileToData (fname, &data); |
2398 | 2417 |
2399 if (result == XpmSuccess) | 2418 if (result == XpmSuccess) |
2400 { | 2419 { |
2401 Lisp_Object retval = Qnil; | 2420 Lisp_Object retval = Qnil; |
2601 DEFINE_SPECIFIER_TYPE (image); | 2620 DEFINE_SPECIFIER_TYPE (image); |
2602 | 2621 |
2603 static void | 2622 static void |
2604 image_create (Lisp_Object obj) | 2623 image_create (Lisp_Object obj) |
2605 { | 2624 { |
2606 struct Lisp_Specifier *image = XIMAGE_SPECIFIER (obj); | 2625 Lisp_Specifier *image = XIMAGE_SPECIFIER (obj); |
2607 | 2626 |
2608 IMAGE_SPECIFIER_ALLOWED (image) = ~0; /* all are allowed */ | 2627 IMAGE_SPECIFIER_ALLOWED (image) = ~0; /* all are allowed */ |
2609 IMAGE_SPECIFIER_ATTACHEE (image) = Qnil; | 2628 IMAGE_SPECIFIER_ATTACHEE (image) = Qnil; |
2610 IMAGE_SPECIFIER_ATTACHEE_PROPERTY (image) = Qnil; | 2629 IMAGE_SPECIFIER_ATTACHEE_PROPERTY (image) = Qnil; |
2611 } | 2630 } |
2612 | 2631 |
2613 static void | 2632 static void |
2614 image_mark (Lisp_Object obj) | 2633 image_mark (Lisp_Object obj) |
2615 { | 2634 { |
2616 struct Lisp_Specifier *image = XIMAGE_SPECIFIER (obj); | 2635 Lisp_Specifier *image = XIMAGE_SPECIFIER (obj); |
2617 | 2636 |
2618 mark_object (IMAGE_SPECIFIER_ATTACHEE (image)); | 2637 mark_object (IMAGE_SPECIFIER_ATTACHEE (image)); |
2619 mark_object (IMAGE_SPECIFIER_ATTACHEE_PROPERTY (image)); | 2638 mark_object (IMAGE_SPECIFIER_ATTACHEE_PROPERTY (image)); |
2620 } | 2639 } |
2621 | 2640 |
2692 if (UNBOUNDP (subtable)) | 2711 if (UNBOUNDP (subtable)) |
2693 { | 2712 { |
2694 /* For the image instance cache, we do comparisons with EQ rather | 2713 /* For the image instance cache, we do comparisons with EQ rather |
2695 than with EQUAL, as we do for color and font names. | 2714 than with EQUAL, as we do for color and font names. |
2696 The reasons are: | 2715 The reasons are: |
2697 | 2716 |
2698 1) pixmap data can be very long, and thus the hashing and | 2717 1) pixmap data can be very long, and thus the hashing and |
2699 comparing will take awhile. | 2718 comparing will take awhile. |
2700 2) It's not so likely that we'll run into things that are EQUAL | 2719 2) It's not so likely that we'll run into things that are EQUAL |
2701 but not EQ (that can happen a lot with faces, because their | 2720 but not EQ (that can happen a lot with faces, because their |
2702 specifiers are copied around); but pixmaps tend not to be | 2721 specifiers are copied around); but pixmaps tend not to be |
2728 will occur most of the time so this probably slows things | 2747 will occur most of the time so this probably slows things |
2729 down. But with the current design I don't see anyway | 2748 down. But with the current design I don't see anyway |
2730 round it. */ | 2749 round it. */ |
2731 if (UNBOUNDP (instance) | 2750 if (UNBOUNDP (instance) |
2732 && | 2751 && |
2733 dest_mask & (IMAGE_SUBWINDOW_MASK | 2752 dest_mask & (IMAGE_SUBWINDOW_MASK |
2734 | IMAGE_WIDGET_MASK | 2753 | IMAGE_WIDGET_MASK |
2735 | IMAGE_TEXT_MASK)) | 2754 | IMAGE_TEXT_MASK)) |
2736 { | 2755 { |
2737 if (!WINDOWP (domain)) | 2756 if (!WINDOWP (domain)) |
2738 signal_simple_error ("Can't instantiate text or subwindow outside a window", | 2757 signal_simple_error ("Can't instantiate text or subwindow outside a window", |
2739 instantiator); | 2758 instantiator); |
2740 instance = Fgethash (instantiator, | 2759 instance = Fgethash (instantiator, |
2741 XWINDOW (domain)->subwindow_instance_cache, | 2760 XWINDOW (domain)->subwindow_instance_cache, |
2742 Qunbound); | 2761 Qunbound); |
2743 } | 2762 } |
2744 } | 2763 } |
2745 | 2764 |
2746 if (UNBOUNDP (instance)) | 2765 if (UNBOUNDP (instance)) |
2748 Lisp_Object locative = | 2767 Lisp_Object locative = |
2749 noseeum_cons (Qnil, | 2768 noseeum_cons (Qnil, |
2750 noseeum_cons (pointerp ? ls3 : instantiator, | 2769 noseeum_cons (pointerp ? ls3 : instantiator, |
2751 subtable)); | 2770 subtable)); |
2752 int speccount = specpdl_depth (); | 2771 int speccount = specpdl_depth (); |
2753 | 2772 |
2754 /* make sure we cache the failures, too. | 2773 /* make sure we cache the failures, too. |
2755 Use an unwind-protect to catch such errors. | 2774 Use an unwind-protect to catch such errors. |
2756 If we fail, the unwind-protect records nil in | 2775 If we fail, the unwind-protect records nil in |
2757 the hash table. If we succeed, we change the | 2776 the hash table. If we succeed, we change the |
2758 car of the locative to the resulting instance, | 2777 car of the locative to the resulting instance, |
2763 domain, | 2782 domain, |
2764 instantiator, | 2783 instantiator, |
2765 pointer_fg, pointer_bg, | 2784 pointer_fg, pointer_bg, |
2766 dest_mask, | 2785 dest_mask, |
2767 glyph); | 2786 glyph); |
2768 | 2787 |
2769 Fsetcar (locative, instance); | 2788 Fsetcar (locative, instance); |
2770 /* only after the image has been instantiated do we know | 2789 /* only after the image has been instantiated do we know |
2771 whether we need to put it in the per-window image instance | 2790 whether we need to put it in the per-window image instance |
2772 cache. */ | 2791 cache. */ |
2773 if (image_instance_type_to_mask (XIMAGE_INSTANCE_TYPE (instance)) | 2792 if (image_instance_type_to_mask (XIMAGE_INSTANCE_TYPE (instance)) |
2775 (IMAGE_SUBWINDOW_MASK | IMAGE_WIDGET_MASK)) | 2794 (IMAGE_SUBWINDOW_MASK | IMAGE_WIDGET_MASK)) |
2776 { | 2795 { |
2777 if (!WINDOWP (domain)) | 2796 if (!WINDOWP (domain)) |
2778 signal_simple_error ("Can't instantiate subwindow outside a window", | 2797 signal_simple_error ("Can't instantiate subwindow outside a window", |
2779 instantiator); | 2798 instantiator); |
2780 | 2799 |
2781 Fsetcdr (XCDR (locative), XWINDOW (domain)->subwindow_instance_cache ); | 2800 Fsetcdr (XCDR (locative), XWINDOW (domain)->subwindow_instance_cache ); |
2782 } | 2801 } |
2783 unbind_to (speccount, Qnil); | 2802 unbind_to (speccount, Qnil); |
2784 } | 2803 } |
2785 else | 2804 else |
2873 | 2892 |
2874 void | 2893 void |
2875 set_image_attached_to (Lisp_Object obj, Lisp_Object face_or_glyph, | 2894 set_image_attached_to (Lisp_Object obj, Lisp_Object face_or_glyph, |
2876 Lisp_Object property) | 2895 Lisp_Object property) |
2877 { | 2896 { |
2878 struct Lisp_Specifier *image = XIMAGE_SPECIFIER (obj); | 2897 Lisp_Specifier *image = XIMAGE_SPECIFIER (obj); |
2879 | 2898 |
2880 IMAGE_SPECIFIER_ATTACHEE (image) = face_or_glyph; | 2899 IMAGE_SPECIFIER_ATTACHEE (image) = face_or_glyph; |
2881 IMAGE_SPECIFIER_ATTACHEE_PROPERTY (image) = property; | 2900 IMAGE_SPECIFIER_ATTACHEE_PROPERTY (image) = property; |
2882 } | 2901 } |
2883 | 2902 |
2944 CHECK_VECTOR (instantiator); | 2963 CHECK_VECTOR (instantiator); |
2945 | 2964 |
2946 instantiator = Fcopy_sequence (instantiator); | 2965 instantiator = Fcopy_sequence (instantiator); |
2947 elt = XVECTOR_DATA (instantiator); | 2966 elt = XVECTOR_DATA (instantiator); |
2948 instantiator_len = XVECTOR_LENGTH (instantiator); | 2967 instantiator_len = XVECTOR_LENGTH (instantiator); |
2949 | 2968 |
2950 meths = decode_image_instantiator_format (elt[0], ERROR_ME); | 2969 meths = decode_image_instantiator_format (elt[0], ERROR_ME); |
2951 | 2970 |
2952 for (i = 1; i < instantiator_len; i += 2) | 2971 for (i = 1; i < instantiator_len; i += 2) |
2953 { | 2972 { |
2954 int j; | 2973 int j; |
3195 ****************************************************************************/ | 3214 ****************************************************************************/ |
3196 | 3215 |
3197 static Lisp_Object | 3216 static Lisp_Object |
3198 mark_glyph (Lisp_Object obj) | 3217 mark_glyph (Lisp_Object obj) |
3199 { | 3218 { |
3200 struct Lisp_Glyph *glyph = XGLYPH (obj); | 3219 Lisp_Glyph *glyph = XGLYPH (obj); |
3201 | 3220 |
3202 mark_object (glyph->image); | 3221 mark_object (glyph->image); |
3203 mark_object (glyph->contrib_p); | 3222 mark_object (glyph->contrib_p); |
3204 mark_object (glyph->baseline); | 3223 mark_object (glyph->baseline); |
3205 mark_object (glyph->face); | 3224 mark_object (glyph->face); |
3208 } | 3227 } |
3209 | 3228 |
3210 static void | 3229 static void |
3211 print_glyph (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) | 3230 print_glyph (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) |
3212 { | 3231 { |
3213 struct Lisp_Glyph *glyph = XGLYPH (obj); | 3232 Lisp_Glyph *glyph = XGLYPH (obj); |
3214 char buf[20]; | 3233 char buf[20]; |
3215 | 3234 |
3216 if (print_readably) | 3235 if (print_readably) |
3217 error ("printing unreadable object #<glyph 0x%x>", glyph->header.uid); | 3236 error ("printing unreadable object #<glyph 0x%x>", glyph->header.uid); |
3218 | 3237 |
3231 This isn't concerned with "unspecified" attributes, that's what | 3250 This isn't concerned with "unspecified" attributes, that's what |
3232 #'glyph-differs-from-default-p is for. */ | 3251 #'glyph-differs-from-default-p is for. */ |
3233 static int | 3252 static int |
3234 glyph_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) | 3253 glyph_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) |
3235 { | 3254 { |
3236 struct Lisp_Glyph *g1 = XGLYPH (obj1); | 3255 Lisp_Glyph *g1 = XGLYPH (obj1); |
3237 struct Lisp_Glyph *g2 = XGLYPH (obj2); | 3256 Lisp_Glyph *g2 = XGLYPH (obj2); |
3238 | 3257 |
3239 depth++; | 3258 depth++; |
3240 | 3259 |
3241 return (internal_equal (g1->image, g2->image, depth) && | 3260 return (internal_equal (g1->image, g2->image, depth) && |
3242 internal_equal (g1->contrib_p, g2->contrib_p, depth) && | 3261 internal_equal (g1->contrib_p, g2->contrib_p, depth) && |
3257 } | 3276 } |
3258 | 3277 |
3259 static Lisp_Object | 3278 static Lisp_Object |
3260 glyph_getprop (Lisp_Object obj, Lisp_Object prop) | 3279 glyph_getprop (Lisp_Object obj, Lisp_Object prop) |
3261 { | 3280 { |
3262 struct Lisp_Glyph *g = XGLYPH (obj); | 3281 Lisp_Glyph *g = XGLYPH (obj); |
3263 | 3282 |
3264 if (EQ (prop, Qimage)) return g->image; | 3283 if (EQ (prop, Qimage)) return g->image; |
3265 if (EQ (prop, Qcontrib_p)) return g->contrib_p; | 3284 if (EQ (prop, Qcontrib_p)) return g->contrib_p; |
3266 if (EQ (prop, Qbaseline)) return g->baseline; | 3285 if (EQ (prop, Qbaseline)) return g->baseline; |
3267 if (EQ (prop, Qface)) return g->face; | 3286 if (EQ (prop, Qface)) return g->face; |
3305 } | 3324 } |
3306 | 3325 |
3307 static Lisp_Object | 3326 static Lisp_Object |
3308 glyph_plist (Lisp_Object obj) | 3327 glyph_plist (Lisp_Object obj) |
3309 { | 3328 { |
3310 struct Lisp_Glyph *glyph = XGLYPH (obj); | 3329 Lisp_Glyph *glyph = XGLYPH (obj); |
3311 Lisp_Object result = glyph->plist; | 3330 Lisp_Object result = glyph->plist; |
3312 | 3331 |
3313 result = cons3 (Qface, glyph->face, result); | 3332 result = cons3 (Qface, glyph->face, result); |
3314 result = cons3 (Qbaseline, glyph->baseline, result); | 3333 result = cons3 (Qbaseline, glyph->baseline, result); |
3315 result = cons3 (Qcontrib_p, glyph->contrib_p, result); | 3334 result = cons3 (Qcontrib_p, glyph->contrib_p, result); |
3317 | 3336 |
3318 return result; | 3337 return result; |
3319 } | 3338 } |
3320 | 3339 |
3321 static const struct lrecord_description glyph_description[] = { | 3340 static const struct lrecord_description glyph_description[] = { |
3322 { XD_LISP_OBJECT, offsetof(struct Lisp_Glyph, image), 5 }, | 3341 { XD_LISP_OBJECT, offsetof (Lisp_Glyph, image) }, |
3342 { XD_LISP_OBJECT, offsetof (Lisp_Glyph, contrib_p) }, | |
3343 { XD_LISP_OBJECT, offsetof (Lisp_Glyph, baseline) }, | |
3344 { XD_LISP_OBJECT, offsetof (Lisp_Glyph, face) }, | |
3345 { XD_LISP_OBJECT, offsetof (Lisp_Glyph, plist) }, | |
3323 { XD_END } | 3346 { XD_END } |
3324 }; | 3347 }; |
3325 | 3348 |
3326 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS ("glyph", glyph, | 3349 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS ("glyph", glyph, |
3327 mark_glyph, print_glyph, 0, | 3350 mark_glyph, print_glyph, 0, |
3328 glyph_equal, glyph_hash, glyph_description, | 3351 glyph_equal, glyph_hash, glyph_description, |
3329 glyph_getprop, glyph_putprop, | 3352 glyph_getprop, glyph_putprop, |
3330 glyph_remprop, glyph_plist, | 3353 glyph_remprop, glyph_plist, |
3331 struct Lisp_Glyph); | 3354 Lisp_Glyph); |
3332 | 3355 |
3333 Lisp_Object | 3356 Lisp_Object |
3334 allocate_glyph (enum glyph_type type, | 3357 allocate_glyph (enum glyph_type type, |
3335 void (*after_change) (Lisp_Object glyph, Lisp_Object property, | 3358 void (*after_change) (Lisp_Object glyph, Lisp_Object property, |
3336 Lisp_Object locale)) | 3359 Lisp_Object locale)) |
3337 { | 3360 { |
3338 /* This function can GC */ | 3361 /* This function can GC */ |
3339 Lisp_Object obj = Qnil; | 3362 Lisp_Object obj = Qnil; |
3340 struct Lisp_Glyph *g = | 3363 Lisp_Glyph *g = alloc_lcrecord_type (Lisp_Glyph, &lrecord_glyph); |
3341 alloc_lcrecord_type (struct Lisp_Glyph, &lrecord_glyph); | |
3342 | 3364 |
3343 g->type = type; | 3365 g->type = type; |
3344 g->image = Fmake_specifier (Qimage); /* This function can GC */ | 3366 g->image = Fmake_specifier (Qimage); /* This function can GC */ |
3345 g->dirty = 0; | 3367 g->dirty = 0; |
3346 switch (g->type) | 3368 switch (g->type) |
3347 { | 3369 { |
3348 case GLYPH_BUFFER: | 3370 case GLYPH_BUFFER: |
3349 XIMAGE_SPECIFIER_ALLOWED (g->image) = | 3371 XIMAGE_SPECIFIER_ALLOWED (g->image) = |
3350 IMAGE_NOTHING_MASK | IMAGE_TEXT_MASK | 3372 IMAGE_NOTHING_MASK | IMAGE_TEXT_MASK |
3351 | IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK | 3373 | IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK |
3352 | IMAGE_SUBWINDOW_MASK | IMAGE_WIDGET_MASK | 3374 | IMAGE_SUBWINDOW_MASK | IMAGE_WIDGET_MASK |
3353 | IMAGE_LAYOUT_MASK; | 3375 | IMAGE_LAYOUT_MASK; |
3354 break; | 3376 break; |
3355 case GLYPH_POINTER: | 3377 case GLYPH_POINTER: |
3356 XIMAGE_SPECIFIER_ALLOWED (g->image) = | 3378 XIMAGE_SPECIFIER_ALLOWED (g->image) = |
3498 { | 3520 { |
3499 Lisp_Object specifier = GLYPH_IMAGE (XGLYPH (glyph)); | 3521 Lisp_Object specifier = GLYPH_IMAGE (XGLYPH (glyph)); |
3500 | 3522 |
3501 /* This can never return Qunbound. All glyphs have 'nothing as | 3523 /* This can never return Qunbound. All glyphs have 'nothing as |
3502 a fallback. */ | 3524 a fallback. */ |
3503 Lisp_Object image_instance = specifier_instance (specifier, Qunbound, | 3525 Lisp_Object image_instance = specifier_instance (specifier, Qunbound, |
3504 domain, errb, no_quit, 0, | 3526 domain, errb, no_quit, 0, |
3505 Qzero); | 3527 Qzero); |
3528 assert (!UNBOUNDP (image_instance)); | |
3506 | 3529 |
3507 return image_instance; | 3530 return image_instance; |
3508 } | 3531 } |
3509 | 3532 |
3510 static Lisp_Object | 3533 static Lisp_Object |
3593 unsigned short | 3616 unsigned short |
3594 glyph_height (Lisp_Object glyph_or_image, Lisp_Object domain) | 3617 glyph_height (Lisp_Object glyph_or_image, Lisp_Object domain) |
3595 { | 3618 { |
3596 Lisp_Object instance = glyph_image_instance_maybe (glyph_or_image, | 3619 Lisp_Object instance = glyph_image_instance_maybe (glyph_or_image, |
3597 domain); | 3620 domain); |
3598 | 3621 |
3599 if (!IMAGE_INSTANCEP (instance)) | 3622 if (!IMAGE_INSTANCEP (instance)) |
3600 return 0; | 3623 return 0; |
3601 | 3624 |
3602 if (XIMAGE_INSTANCE_DIRTYP (instance)) | 3625 if (XIMAGE_INSTANCE_DIRTYP (instance)) |
3603 image_instance_layout (instance, IMAGE_UNSPECIFIED_GEOMETRY, | 3626 image_instance_layout (instance, IMAGE_UNSPECIFIED_GEOMETRY, |
3642 { | 3665 { |
3643 XSETWINDOW (window, decode_window (window)); | 3666 XSETWINDOW (window, decode_window (window)); |
3644 CHECK_GLYPH (glyph); | 3667 CHECK_GLYPH (glyph); |
3645 | 3668 |
3646 return make_int (glyph_height (glyph, window)); | 3669 return make_int (glyph_height (glyph, window)); |
3647 } | |
3648 | |
3649 static unsigned int | |
3650 glyph_dirty_p (Lisp_Object glyph_or_image, Lisp_Object window) | |
3651 { | |
3652 return XIMAGE_INSTANCE_DIRTYP (glyph_image_instance_maybe | |
3653 (glyph_or_image, window)); | |
3654 } | 3670 } |
3655 | 3671 |
3656 static void | 3672 static void |
3657 set_glyph_dirty_p (Lisp_Object glyph_or_image, Lisp_Object window, int dirty) | 3673 set_glyph_dirty_p (Lisp_Object glyph_or_image, Lisp_Object window, int dirty) |
3658 { | 3674 { |
3726 } | 3742 } |
3727 | 3743 |
3728 #if 0 /* Not used for now */ | 3744 #if 0 /* Not used for now */ |
3729 static void | 3745 static void |
3730 glyph_query_geometry (Lisp_Object glyph_or_image, Lisp_Object window, | 3746 glyph_query_geometry (Lisp_Object glyph_or_image, Lisp_Object window, |
3731 unsigned int* width, unsigned int* height, | 3747 unsigned int* width, unsigned int* height, |
3732 enum image_instance_geometry disp, Lisp_Object domain) | 3748 enum image_instance_geometry disp, Lisp_Object domain) |
3733 { | 3749 { |
3734 Lisp_Object instance = glyph_or_image; | 3750 Lisp_Object instance = glyph_or_image; |
3735 | 3751 |
3736 if (GLYPHP (glyph_or_image)) | 3752 if (GLYPHP (glyph_or_image)) |
3737 instance = glyph_image_instance (glyph_or_image, window, ERROR_ME_NOT, 1); | 3753 instance = glyph_image_instance (glyph_or_image, window, ERROR_ME_NOT, 1); |
3738 | 3754 |
3739 image_instance_query_geometry (instance, width, height, disp, domain); | 3755 image_instance_query_geometry (instance, width, height, disp, domain); |
3740 } | 3756 } |
3741 | 3757 |
3742 static void | 3758 static void |
3743 glyph_layout (Lisp_Object glyph_or_image, Lisp_Object window, | 3759 glyph_layout (Lisp_Object glyph_or_image, Lisp_Object window, |
3745 { | 3761 { |
3746 Lisp_Object instance = glyph_or_image; | 3762 Lisp_Object instance = glyph_or_image; |
3747 | 3763 |
3748 if (GLYPHP (glyph_or_image)) | 3764 if (GLYPHP (glyph_or_image)) |
3749 instance = glyph_image_instance (glyph_or_image, window, ERROR_ME_NOT, 1); | 3765 instance = glyph_image_instance (glyph_or_image, window, ERROR_ME_NOT, 1); |
3750 | 3766 |
3751 image_instance_layout (instance, width, height, domain); | 3767 image_instance_layout (instance, width, height, domain); |
3752 } | 3768 } |
3753 #endif | 3769 #endif |
3754 | 3770 |
3755 | 3771 |
3780 static void | 3796 static void |
3781 update_glyph_cachel_data (struct window *w, Lisp_Object glyph, | 3797 update_glyph_cachel_data (struct window *w, Lisp_Object glyph, |
3782 struct glyph_cachel *cachel) | 3798 struct glyph_cachel *cachel) |
3783 { | 3799 { |
3784 if (!cachel->updated || NILP (cachel->glyph) || !EQ (cachel->glyph, glyph) | 3800 if (!cachel->updated || NILP (cachel->glyph) || !EQ (cachel->glyph, glyph) |
3785 || XGLYPH_DIRTYP (cachel->glyph)) | 3801 || XGLYPH_DIRTYP (cachel->glyph) |
3802 || XFRAME(WINDOW_FRAME(w))->faces_changed) | |
3786 { | 3803 { |
3787 Lisp_Object window, instance; | 3804 Lisp_Object window, instance; |
3788 | 3805 |
3789 XSETWINDOW (window, w); | 3806 XSETWINDOW (window, w); |
3790 | 3807 |
3791 cachel->glyph = glyph; | 3808 cachel->glyph = glyph; |
3792 /* Speed things up slightly by grabbing the glyph instantiation | 3809 /* Speed things up slightly by grabbing the glyph instantiation |
3793 and passing it to the size functions. */ | 3810 and passing it to the size functions. */ |
3794 instance = glyph_image_instance (glyph, window, ERROR_ME_NOT, 1); | 3811 instance = glyph_image_instance (glyph, window, ERROR_ME_NOT, 1); |
3795 cachel->dirty = XGLYPH_DIRTYP (glyph) = glyph_dirty_p (glyph, window); | 3812 |
3813 /* Mark text instance of the glyph dirty if faces have changed, | |
3814 because its geometry might have changed. */ | |
3815 invalidate_glyph_geometry_maybe (instance, w); | |
3816 | |
3817 /* #### Do the following 2 lines buy us anything? --kkm */ | |
3818 XGLYPH_DIRTYP (glyph) = XIMAGE_INSTANCE_DIRTYP (instance); | |
3819 cachel->dirty = XGLYPH_DIRTYP (glyph); | |
3796 cachel->width = glyph_width (instance, window); | 3820 cachel->width = glyph_width (instance, window); |
3797 cachel->ascent = glyph_ascent (instance, window); | 3821 cachel->ascent = glyph_ascent (instance, window); |
3798 cachel->descent = glyph_descent (instance, window); | 3822 cachel->descent = glyph_descent (instance, window); |
3799 } | 3823 } |
3800 | 3824 |
3875 Dynarr_atp (w->glyph_cachels, elt)->updated = 0; | 3899 Dynarr_atp (w->glyph_cachels, elt)->updated = 0; |
3876 } | 3900 } |
3877 } | 3901 } |
3878 | 3902 |
3879 /* Unset the dirty bit on all the glyph cachels that have it. */ | 3903 /* Unset the dirty bit on all the glyph cachels that have it. */ |
3880 void | 3904 void |
3881 mark_glyph_cachels_as_clean (struct window* w) | 3905 mark_glyph_cachels_as_clean (struct window* w) |
3882 { | 3906 { |
3883 int elt; | 3907 int elt; |
3884 Lisp_Object window; | 3908 Lisp_Object window; |
3885 XSETWINDOW (window, w); | 3909 XSETWINDOW (window, w); |
4008 | 4032 |
4009 for (elt = 0; elt < Dynarr_length (f->subwindow_cachels); elt++) | 4033 for (elt = 0; elt < Dynarr_length (f->subwindow_cachels); elt++) |
4010 { | 4034 { |
4011 struct subwindow_cachel *cachel = | 4035 struct subwindow_cachel *cachel = |
4012 Dynarr_atp (f->subwindow_cachels, elt); | 4036 Dynarr_atp (f->subwindow_cachels, elt); |
4013 | 4037 |
4014 if (EQ (cachel->subwindow, subwindow) && !NILP (subwindow)) | 4038 if (EQ (cachel->subwindow, subwindow) && !NILP (subwindow)) |
4015 { | 4039 { |
4016 update_subwindow_cachel_data (f, subwindow, cachel); | 4040 update_subwindow_cachel_data (f, subwindow, cachel); |
4017 } | 4041 } |
4018 } | 4042 } |
4080 /* Checking for exact matches just isn't good enough as we | 4104 /* Checking for exact matches just isn't good enough as we |
4081 mighte get exposures for partially obscure subwindows, thus | 4105 mighte get exposures for partially obscure subwindows, thus |
4082 we have to check for overlaps. Being conservative we will | 4106 we have to check for overlaps. Being conservative we will |
4083 check for exposures wholly contained by the subwindow, this | 4107 check for exposures wholly contained by the subwindow, this |
4084 might give us what we want.*/ | 4108 might give us what we want.*/ |
4085 if (ei->x <= x && ei->y <= y | 4109 if (ei->x <= x && ei->y <= y |
4086 && ei->x + ei->width >= x + width | 4110 && ei->x + ei->width >= x + width |
4087 && ei->y + ei->height >= y + height) | 4111 && ei->y + ei->height >= y + height) |
4088 { | 4112 { |
4089 #ifdef DEBUG_WIDGETS | 4113 #ifdef DEBUG_WIDGETS |
4090 stderr_out ("ignored %d+%d, %dx%d for exposure %d+%d, %dx%d\n", | 4114 stderr_out ("ignored %d+%d, %dx%d for exposure %d+%d, %dx%d\n", |
4092 #endif | 4116 #endif |
4093 if (!prev) | 4117 if (!prev) |
4094 f->subwindow_exposures = ei->next; | 4118 f->subwindow_exposures = ei->next; |
4095 else | 4119 else |
4096 prev->next = ei->next; | 4120 prev->next = ei->next; |
4097 | 4121 |
4098 if (ei == f->subwindow_exposures_tail) | 4122 if (ei == f->subwindow_exposures_tail) |
4099 f->subwindow_exposures_tail = prev; | 4123 f->subwindow_exposures_tail = prev; |
4100 | 4124 |
4101 Blocktype_free (the_expose_ignore_blocktype, ei); | 4125 Blocktype_free (the_expose_ignore_blocktype, ei); |
4102 return 1; | 4126 return 1; |
4110 register_ignored_expose (struct frame* f, int x, int y, int width, int height) | 4134 register_ignored_expose (struct frame* f, int x, int y, int width, int height) |
4111 { | 4135 { |
4112 if (!hold_ignored_expose_registration) | 4136 if (!hold_ignored_expose_registration) |
4113 { | 4137 { |
4114 struct expose_ignore *ei; | 4138 struct expose_ignore *ei; |
4115 | 4139 |
4116 ei = Blocktype_alloc (the_expose_ignore_blocktype); | 4140 ei = Blocktype_alloc (the_expose_ignore_blocktype); |
4117 | 4141 |
4118 ei->next = NULL; | 4142 ei->next = NULL; |
4119 ei->x = x; | 4143 ei->x = x; |
4120 ei->y = y; | 4144 ei->y = y; |
4121 ei->width = width; | 4145 ei->width = width; |
4122 ei->height = height; | 4146 ei->height = height; |
4123 | 4147 |
4124 /* we have to add the exposure to the end of the list, since we | 4148 /* we have to add the exposure to the end of the list, since we |
4125 want to check the oldest events first. for speed we keep a record | 4149 want to check the oldest events first. for speed we keep a record |
4126 of the end so that we can add right to it. */ | 4150 of the end so that we can add right to it. */ |
4127 if (f->subwindow_exposures_tail) | 4151 if (f->subwindow_exposures_tail) |
4128 { | 4152 { |
4152 Dynarr_atp (f->subwindow_cachels, elt); | 4176 Dynarr_atp (f->subwindow_cachels, elt); |
4153 | 4177 |
4154 if (cachel->being_displayed | 4178 if (cachel->being_displayed |
4155 && | 4179 && |
4156 cachel->x <= x && cachel->y <= y | 4180 cachel->x <= x && cachel->y <= y |
4157 && | 4181 && |
4158 cachel->x + cachel->width >= x + width | 4182 cachel->x + cachel->width >= x + width |
4159 && | 4183 && |
4160 cachel->y + cachel->height >= y + height) | 4184 cachel->y + cachel->height >= y + height) |
4161 { | 4185 { |
4162 return 1; | 4186 return 1; |
4172 | 4196 |
4173 /* update the displayed characteristics of a subwindow */ | 4197 /* update the displayed characteristics of a subwindow */ |
4174 static void | 4198 static void |
4175 update_subwindow (Lisp_Object subwindow) | 4199 update_subwindow (Lisp_Object subwindow) |
4176 { | 4200 { |
4177 struct Lisp_Image_Instance* ii = XIMAGE_INSTANCE (subwindow); | 4201 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (subwindow); |
4178 | 4202 |
4179 if (!IMAGE_INSTANCE_TYPE (ii) == IMAGE_WIDGET | 4203 if (!IMAGE_INSTANCE_TYPE (ii) == IMAGE_WIDGET |
4180 || | 4204 || |
4181 NILP (IMAGE_INSTANCE_SUBWINDOW_FRAME (ii))) | 4205 NILP (IMAGE_INSTANCE_SUBWINDOW_FRAME (ii))) |
4182 return; | 4206 return; |
4199 if (f->subwindows_changed || f->subwindows_state_changed || f->faces_changed) | 4223 if (f->subwindows_changed || f->subwindows_state_changed || f->faces_changed) |
4200 for (elt = 0; elt < Dynarr_length (f->subwindow_cachels); elt++) | 4224 for (elt = 0; elt < Dynarr_length (f->subwindow_cachels); elt++) |
4201 { | 4225 { |
4202 struct subwindow_cachel *cachel = | 4226 struct subwindow_cachel *cachel = |
4203 Dynarr_atp (f->subwindow_cachels, elt); | 4227 Dynarr_atp (f->subwindow_cachels, elt); |
4204 | 4228 |
4205 if (cachel->being_displayed) | 4229 if (cachel->being_displayed) |
4206 { | 4230 { |
4207 update_subwindow (cachel->subwindow); | 4231 update_subwindow (cachel->subwindow); |
4208 } | 4232 } |
4209 } | 4233 } |
4210 } | 4234 } |
4211 | 4235 |
4212 /* remove a subwindow from its frame */ | 4236 /* remove a subwindow from its frame */ |
4213 void unmap_subwindow (Lisp_Object subwindow) | 4237 void unmap_subwindow (Lisp_Object subwindow) |
4214 { | 4238 { |
4215 struct Lisp_Image_Instance* ii = XIMAGE_INSTANCE (subwindow); | 4239 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (subwindow); |
4216 int elt; | 4240 int elt; |
4217 struct subwindow_cachel* cachel; | 4241 struct subwindow_cachel* cachel; |
4218 struct frame* f; | 4242 struct frame* f; |
4219 | 4243 |
4220 if (!(IMAGE_INSTANCE_TYPE (ii) == IMAGE_WIDGET | 4244 if (!(IMAGE_INSTANCE_TYPE (ii) == IMAGE_WIDGET |
4242 | 4266 |
4243 /* show a subwindow in its frame */ | 4267 /* show a subwindow in its frame */ |
4244 void map_subwindow (Lisp_Object subwindow, int x, int y, | 4268 void map_subwindow (Lisp_Object subwindow, int x, int y, |
4245 struct display_glyph_area *dga) | 4269 struct display_glyph_area *dga) |
4246 { | 4270 { |
4247 struct Lisp_Image_Instance* ii = XIMAGE_INSTANCE (subwindow); | 4271 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (subwindow); |
4248 int elt; | 4272 int elt; |
4249 struct subwindow_cachel* cachel; | 4273 struct subwindow_cachel* cachel; |
4250 struct frame* f; | 4274 struct frame* f; |
4251 | 4275 |
4252 if (!(IMAGE_INSTANCE_TYPE (ii) == IMAGE_WIDGET | 4276 if (!(IMAGE_INSTANCE_TYPE (ii) == IMAGE_WIDGET |
4253 || | 4277 || |
4275 before we show it. I'm not sure whether or not we need mark as | 4299 before we show it. I'm not sure whether or not we need mark as |
4276 clean here, but for now we will. */ | 4300 clean here, but for now we will. */ |
4277 if (IMAGE_INSTANCE_DIRTYP (ii)) | 4301 if (IMAGE_INSTANCE_DIRTYP (ii)) |
4278 { | 4302 { |
4279 update_subwindow (subwindow); | 4303 update_subwindow (subwindow); |
4280 IMAGE_INSTANCE_DIRTYP (ii) = 0; | 4304 IMAGE_INSTANCE_DIRTYP (ii) = 0; |
4281 } | 4305 } |
4282 | 4306 |
4283 MAYBE_DEVMETH (XDEVICE (ii->device), map_subwindow, (ii, x, y, dga)); | 4307 MAYBE_DEVMETH (XDEVICE (ii->device), map_subwindow, (ii, x, y, dga)); |
4284 } | 4308 } |
4285 | 4309 |
4293 void | 4317 void |
4294 subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 4318 subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
4295 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 4319 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
4296 int dest_mask, Lisp_Object domain) | 4320 int dest_mask, Lisp_Object domain) |
4297 { | 4321 { |
4298 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 4322 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
4299 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 4323 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
4300 Lisp_Object frame = FW_FRAME (domain); | 4324 Lisp_Object frame = FW_FRAME (domain); |
4301 Lisp_Object width = find_keyword_in_vector (instantiator, Q_pixel_width); | 4325 Lisp_Object width = find_keyword_in_vector (instantiator, Q_pixel_width); |
4302 Lisp_Object height = find_keyword_in_vector (instantiator, Q_pixel_height); | 4326 Lisp_Object height = find_keyword_in_vector (instantiator, Q_pixel_height); |
4303 | 4327 |
4304 if (NILP (frame)) | 4328 if (NILP (frame)) |
4305 signal_simple_error ("No selected frame", device); | 4329 signal_simple_error ("No selected frame", device); |
4306 | 4330 |
4307 if (!(dest_mask & IMAGE_SUBWINDOW_MASK)) | 4331 if (!(dest_mask & IMAGE_SUBWINDOW_MASK)) |
4308 incompatible_image_types (instantiator, dest_mask, IMAGE_SUBWINDOW_MASK); | 4332 incompatible_image_types (instantiator, dest_mask, IMAGE_SUBWINDOW_MASK); |
4309 | 4333 |
4310 ii->data = 0; | 4334 ii->data = 0; |
4311 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = 0; | 4335 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = 0; |
4313 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii) = frame; | 4337 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii) = frame; |
4314 | 4338 |
4315 /* #### This stuff may get overidden by the widget code and is | 4339 /* #### This stuff may get overidden by the widget code and is |
4316 actually really dumb now that we have dynamic geometry | 4340 actually really dumb now that we have dynamic geometry |
4317 calculations. What should really happen is that the subwindow | 4341 calculations. What should really happen is that the subwindow |
4318 should query its child for and appropriate geometry. */ | 4342 should query its child for an appropriate geometry. */ |
4319 if (NILP (width)) | 4343 if (NILP (width)) |
4320 IMAGE_INSTANCE_SUBWINDOW_WIDTH (ii) = 20; | 4344 IMAGE_INSTANCE_SUBWINDOW_WIDTH (ii) = 20; |
4321 else | 4345 else |
4322 { | 4346 { |
4323 int w = 1; | 4347 int w = 1; |
4496 CHECK_WEAK_LIST (arg); | 4520 CHECK_WEAK_LIST (arg); |
4497 | 4521 |
4498 if (!NILP (XWEAK_LIST_LIST (arg)) && !NILP (XCAR (XWEAK_LIST_LIST (arg)))) | 4522 if (!NILP (XWEAK_LIST_LIST (arg)) && !NILP (XCAR (XWEAK_LIST_LIST (arg)))) |
4499 { | 4523 { |
4500 Lisp_Object value = XCAR (XWEAK_LIST_LIST (arg)); | 4524 Lisp_Object value = XCAR (XWEAK_LIST_LIST (arg)); |
4501 | 4525 |
4502 if (IMAGE_INSTANCEP (value)) | 4526 if (IMAGE_INSTANCEP (value)) |
4503 { | 4527 { |
4504 struct Lisp_Image_Instance* ii = XIMAGE_INSTANCE (value); | 4528 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (value); |
4505 | 4529 |
4506 if (COLOR_PIXMAP_IMAGE_INSTANCEP (value) | 4530 if (COLOR_PIXMAP_IMAGE_INSTANCEP (value) |
4507 && | 4531 && |
4508 IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii) > 1 | 4532 IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii) > 1 |
4509 && | 4533 && |
4514 IMAGE_INSTANCE_PIXMAP_SLICE (ii) = | 4538 IMAGE_INSTANCE_PIXMAP_SLICE (ii) = |
4515 (IMAGE_INSTANCE_PIXMAP_SLICE (ii) + 1) | 4539 (IMAGE_INSTANCE_PIXMAP_SLICE (ii) + 1) |
4516 % IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii); | 4540 % IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii); |
4517 /* We might need to kick redisplay at this point - but we | 4541 /* We might need to kick redisplay at this point - but we |
4518 also might not. */ | 4542 also might not. */ |
4519 MARK_DEVICE_FRAMES_GLYPHS_CHANGED | 4543 MARK_DEVICE_FRAMES_GLYPHS_CHANGED |
4520 (XDEVICE (IMAGE_INSTANCE_DEVICE (ii))); | 4544 (XDEVICE (IMAGE_INSTANCE_DEVICE (ii))); |
4521 MARK_IMAGE_INSTANCE_CHANGED (ii); | 4545 MARK_IMAGE_INSTANCE_CHANGED (ii); |
4522 } | 4546 } |
4523 } | 4547 } |
4524 } | 4548 } |
4674 "image-conversion error", Qio_error); | 4698 "image-conversion error", Qio_error); |
4675 | 4699 |
4676 } | 4700 } |
4677 | 4701 |
4678 static const struct lrecord_description image_specifier_description[] = { | 4702 static const struct lrecord_description image_specifier_description[] = { |
4679 { XD_LISP_OBJECT, specifier_data_offset + offsetof(struct image_specifier, attachee), 2 }, | 4703 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct image_specifier, attachee) }, |
4704 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct image_specifier, attachee_property) }, | |
4680 { XD_END } | 4705 { XD_END } |
4681 }; | 4706 }; |
4682 | 4707 |
4683 void | 4708 void |
4684 specifier_type_create_image (void) | 4709 specifier_type_create_image (void) |
4702 REINITIALIZE_SPECIFIER_TYPE (image); | 4727 REINITIALIZE_SPECIFIER_TYPE (image); |
4703 } | 4728 } |
4704 | 4729 |
4705 | 4730 |
4706 static const struct lrecord_description iike_description_1[] = { | 4731 static const struct lrecord_description iike_description_1[] = { |
4707 { XD_LISP_OBJECT, offsetof(ii_keyword_entry, keyword), 1 }, | 4732 { XD_LISP_OBJECT, offsetof (ii_keyword_entry, keyword) }, |
4708 { XD_END } | 4733 { XD_END } |
4709 }; | 4734 }; |
4710 | 4735 |
4711 static const struct struct_description iike_description = { | 4736 static const struct struct_description iike_description = { |
4712 sizeof(ii_keyword_entry), | 4737 sizeof (ii_keyword_entry), |
4713 iike_description_1 | 4738 iike_description_1 |
4714 }; | 4739 }; |
4715 | 4740 |
4716 static const struct lrecord_description iiked_description_1[] = { | 4741 static const struct lrecord_description iiked_description_1[] = { |
4717 XD_DYNARR_DESC(ii_keyword_entry_dynarr, &iike_description), | 4742 XD_DYNARR_DESC (ii_keyword_entry_dynarr, &iike_description), |
4718 { XD_END } | 4743 { XD_END } |
4719 }; | 4744 }; |
4720 | 4745 |
4721 static const struct struct_description iiked_description = { | 4746 static const struct struct_description iiked_description = { |
4722 sizeof(ii_keyword_entry_dynarr), | 4747 sizeof (ii_keyword_entry_dynarr), |
4723 iiked_description_1 | 4748 iiked_description_1 |
4724 }; | 4749 }; |
4725 | 4750 |
4726 static const struct lrecord_description iife_description_1[] = { | 4751 static const struct lrecord_description iife_description_1[] = { |
4727 { XD_LISP_OBJECT, offsetof(image_instantiator_format_entry, symbol), 2 }, | 4752 { XD_LISP_OBJECT, offsetof (image_instantiator_format_entry, symbol) }, |
4728 { XD_STRUCT_PTR, offsetof(image_instantiator_format_entry, meths), 1, &iim_description }, | 4753 { XD_LISP_OBJECT, offsetof (image_instantiator_format_entry, device) }, |
4754 { XD_STRUCT_PTR, offsetof (image_instantiator_format_entry, meths), 1, &iim_description }, | |
4729 { XD_END } | 4755 { XD_END } |
4730 }; | 4756 }; |
4731 | 4757 |
4732 static const struct struct_description iife_description = { | 4758 static const struct struct_description iife_description = { |
4733 sizeof(image_instantiator_format_entry), | 4759 sizeof (image_instantiator_format_entry), |
4734 iife_description_1 | 4760 iife_description_1 |
4735 }; | 4761 }; |
4736 | 4762 |
4737 static const struct lrecord_description iifed_description_1[] = { | 4763 static const struct lrecord_description iifed_description_1[] = { |
4738 XD_DYNARR_DESC(image_instantiator_format_entry_dynarr, &iife_description), | 4764 XD_DYNARR_DESC (image_instantiator_format_entry_dynarr, &iife_description), |
4739 { XD_END } | 4765 { XD_END } |
4740 }; | 4766 }; |
4741 | 4767 |
4742 static const struct struct_description iifed_description = { | 4768 static const struct struct_description iifed_description = { |
4743 sizeof(image_instantiator_format_entry_dynarr), | 4769 sizeof (image_instantiator_format_entry_dynarr), |
4744 iifed_description_1 | 4770 iifed_description_1 |
4745 }; | 4771 }; |
4746 | 4772 |
4747 static const struct lrecord_description iim_description_1[] = { | 4773 static const struct lrecord_description iim_description_1[] = { |
4748 { XD_LISP_OBJECT, offsetof(struct image_instantiator_methods, symbol), 2 }, | 4774 { XD_LISP_OBJECT, offsetof (struct image_instantiator_methods, symbol) }, |
4749 { XD_STRUCT_PTR, offsetof(struct image_instantiator_methods, keywords), 1, &iiked_description }, | 4775 { XD_LISP_OBJECT, offsetof (struct image_instantiator_methods, device) }, |
4750 { XD_STRUCT_PTR, offsetof(struct image_instantiator_methods, consoles), 1, &cted_description }, | 4776 { XD_STRUCT_PTR, offsetof (struct image_instantiator_methods, keywords), 1, &iiked_description }, |
4777 { XD_STRUCT_PTR, offsetof (struct image_instantiator_methods, consoles), 1, &cted_description }, | |
4751 { XD_END } | 4778 { XD_END } |
4752 }; | 4779 }; |
4753 | 4780 |
4754 const struct struct_description iim_description = { | 4781 const struct struct_description iim_description = { |
4755 sizeof(struct image_instantiator_methods), | 4782 sizeof(struct image_instantiator_methods), |
4872 Vthe_nothing_vector = vector1 (Qnothing); | 4899 Vthe_nothing_vector = vector1 (Qnothing); |
4873 staticpro (&Vthe_nothing_vector); | 4900 staticpro (&Vthe_nothing_vector); |
4874 | 4901 |
4875 /* image instances */ | 4902 /* image instances */ |
4876 | 4903 |
4877 Vimage_instance_type_list = Fcons (Qnothing, | 4904 Vimage_instance_type_list = Fcons (Qnothing, |
4878 list6 (Qtext, Qmono_pixmap, Qcolor_pixmap, | 4905 list6 (Qtext, Qmono_pixmap, Qcolor_pixmap, |
4879 Qpointer, Qsubwindow, Qwidget)); | 4906 Qpointer, Qsubwindow, Qwidget)); |
4880 staticpro (&Vimage_instance_type_list); | 4907 staticpro (&Vimage_instance_type_list); |
4881 | 4908 |
4882 /* glyphs */ | 4909 /* glyphs */ |
4883 | 4910 |