comparison src/glyphs-x.c @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents fdefd0186b75
children e38acbeb1cae
comparison
equal deleted inserted replaced
770:336a418893b5 771:943eaba38521
1 /* X-specific Lisp objects. 1 /* X-specific Lisp objects.
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc. 2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
3 Copyright (C) 1995 Board of Trustees, University of Illinois. 3 Copyright (C) 1995 Board of Trustees, University of Illinois.
4 Copyright (C) 1995 Tinker Systems 4 Copyright (C) 1995 Tinker Systems
5 Copyright (C) 1995, 1996 Ben Wing 5 Copyright (C) 1995, 1996, 2001, 2002 Ben Wing
6 Copyright (C) 1995 Sun Microsystems 6 Copyright (C) 1995 Sun Microsystems
7 Copyright (C) 1999, 2000 Andy Piper 7 Copyright (C) 1999, 2000 Andy Piper
8 8
9 This file is part of XEmacs. 9 This file is part of XEmacs.
10 10
47 TODO: 47 TODO:
48 Support the GrayScale, StaticColor and StaticGray visual classes. 48 Support the GrayScale, StaticColor and StaticGray visual classes.
49 Convert images.el to C and stick it in here? 49 Convert images.el to C and stick it in here?
50 */ 50 */
51 51
52 /* Mule-ized last 6-22-00 */
53
52 #include <config.h> 54 #include <config.h>
53 #include "lisp.h" 55 #include "lisp.h"
54 #include "lstream.h" 56 #include "lstream.h"
55 #include "console-x.h" 57 #include "console-x.h"
56 #include "glyphs-x.h" 58 #include "glyphs-x.h"
57 #include "objects-x.h" 59 #include "objects-x.h"
58 #ifdef HAVE_WIDGETS 60 #ifdef HAVE_X_WIDGETS
59 #include "gui-x.h" 61 #include "gui-x.h"
60 #endif 62 #endif
61 #include "xmu.h" 63 #include "xmu.h"
62 64
63 #include "buffer.h" 65 #include "buffer.h"
69 #include "faces.h" 71 #include "faces.h"
70 72
71 #include "imgproc.h" 73 #include "imgproc.h"
72 74
73 #include "sysfile.h" 75 #include "sysfile.h"
76 #include "sysproc.h" /* for qxe_getpid() */
74 77
75 #include <setjmp.h> 78 #include <setjmp.h>
76 79
77 #ifdef FILE_CODING
78 #include "file-coding.h" 80 #include "file-coding.h"
79 #endif
80 81
81 #ifdef LWLIB_WIDGETS_MOTIF 82 #ifdef LWLIB_WIDGETS_MOTIF
82 #include <Xm/Xm.h> 83 #include <Xm/Xm.h>
83 #include <Xm/Scale.h> 84 #include <Xm/Scale.h>
84 #endif 85 #endif
126 127
127 DEFINE_IMAGE_INSTANTIATOR_FORMAT (font); 128 DEFINE_IMAGE_INSTANTIATOR_FORMAT (font);
128 129
129 DEFINE_IMAGE_INSTANTIATOR_FORMAT (autodetect); 130 DEFINE_IMAGE_INSTANTIATOR_FORMAT (autodetect);
130 131
131 #ifdef HAVE_WIDGETS 132 #ifdef HAVE_X_WIDGETS
132 DECLARE_IMAGE_INSTANTIATOR_FORMAT (layout); 133 DECLARE_IMAGE_INSTANTIATOR_FORMAT (layout);
133 DEFINE_DEVICE_IIFORMAT (x, widget); 134 DEFINE_DEVICE_IIFORMAT (x, widget);
134 DEFINE_DEVICE_IIFORMAT (x, native_layout); 135 DEFINE_DEVICE_IIFORMAT (x, native_layout);
135 DEFINE_DEVICE_IIFORMAT (x, button); 136 DEFINE_DEVICE_IIFORMAT (x, button);
136 DEFINE_DEVICE_IIFORMAT (x, progress_gauge); 137 DEFINE_DEVICE_IIFORMAT (x, progress_gauge);
147 Lisp_Object pointer_fg, 148 Lisp_Object pointer_fg,
148 Lisp_Object pointer_bg, 149 Lisp_Object pointer_bg,
149 int dest_mask, 150 int dest_mask,
150 Lisp_Object domain); 151 Lisp_Object domain);
151 152
152 #ifdef HAVE_WIDGETS 153 #ifdef HAVE_X_WIDGETS
153 static void 154 static void
154 update_widget_face (widget_value* wv, 155 update_widget_face (widget_value* wv,
155 Lisp_Image_Instance* ii, Lisp_Object domain); 156 Lisp_Image_Instance* ii, Lisp_Object domain);
156 static void 157 static void
157 update_tab_widget_face (widget_value* wv, 158 update_tab_widget_face (widget_value* wv,
171 /* convert from a series of RGB triples to an XImage formated for the */ 172 /* convert from a series of RGB triples to an XImage formated for the */
172 /* proper display */ 173 /* proper display */
173 /************************************************************************/ 174 /************************************************************************/
174 static XImage * 175 static XImage *
175 convert_EImage_to_XImage (Lisp_Object device, int width, int height, 176 convert_EImage_to_XImage (Lisp_Object device, int width, int height,
176 unsigned char *pic, unsigned long **pixtbl, 177 UChar_Binary *pic, unsigned long **pixtbl,
177 int *npixels) 178 int *npixels)
178 { 179 {
179 Display *dpy; 180 Display *dpy;
180 Colormap cmap; 181 Colormap cmap;
181 Visual *vis; 182 Visual *vis;
182 XImage *outimg; 183 XImage *outimg;
183 int depth, bitmap_pad, bits_per_pixel, byte_cnt, i, j; 184 int depth, bitmap_pad, bits_per_pixel, byte_cnt, i, j;
184 int rd,gr,bl,q; 185 int rd,gr,bl,q;
185 unsigned char *data, *ip, *dp; 186 UChar_Binary *data, *ip, *dp;
186 quant_table *qtable = 0; 187 quant_table *qtable = 0;
187 union { 188 union {
188 FOUR_BYTE_TYPE val; 189 FOUR_BYTE_TYPE val;
189 char cp[4]; 190 char cp[4];
190 } conv; 191 } conv;
219 if (!outimg) return NULL; 220 if (!outimg) return NULL;
220 221
221 bits_per_pixel = outimg->bits_per_pixel; 222 bits_per_pixel = outimg->bits_per_pixel;
222 byte_cnt = bits_per_pixel >> 3; 223 byte_cnt = bits_per_pixel >> 3;
223 224
224 data = (unsigned char *) xmalloc (outimg->bytes_per_line * height); 225 data = (UChar_Binary *) xmalloc (outimg->bytes_per_line * height);
225 if (!data) 226 if (!data)
226 { 227 {
227 XDestroyImage (outimg); 228 XDestroyImage (outimg);
228 return NULL; 229 return NULL;
229 } 230 }
403 { 404 {
404 Display *dpy = DEVICE_X_DISPLAY 405 Display *dpy = DEVICE_X_DISPLAY
405 (XDEVICE (IMAGE_INSTANCE_DEVICE (p))); 406 (XDEVICE (IMAGE_INSTANCE_DEVICE (p)));
406 if (0) 407 if (0)
407 ; 408 ;
408 #ifdef HAVE_WIDGETS 409 #ifdef HAVE_X_WIDGETS
409 else if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET) 410 else if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET)
410 { 411 {
411 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) 412 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
412 { 413 {
413 #ifdef DEBUG_WIDGETS 414 #ifdef DEBUG_WIDGETS
590 /* We only check the bitmapFilePath resource on the original X device. */ 591 /* We only check the bitmapFilePath resource on the original X device. */
591 display = DEVICE_X_DISPLAY (XDEVICE (Vdefault_x_device)); 592 display = DEVICE_X_DISPLAY (XDEVICE (Vdefault_x_device));
592 593
593 #ifdef USE_XBMLANGPATH 594 #ifdef USE_XBMLANGPATH
594 { 595 {
595 char *path = egetenv ("XBMLANGPATH"); 596 Intbyte *path = egetenv ("XBMLANGPATH");
597 Extbyte *pathext;
596 SubstitutionRec subs[1]; 598 SubstitutionRec subs[1];
597 subs[0].match = 'B'; 599 subs[0].match = 'B';
598 subs[0].substitution = (char *) XSTRING_DATA (name); 600 LISP_STRING_TO_EXTERNAL (name, subs[0].substitution, Qfile_name);
601 C_STRING_TO_EXTERNAL (path, pathext, Qfile_name);
599 /* #### Motif uses a big hairy default if $XBMLANGPATH isn't set. 602 /* #### Motif uses a big hairy default if $XBMLANGPATH isn't set.
600 We don't. If you want it used, set it. */ 603 We don't. If you want it used, set it. */
601 if (path && 604 if (pathext &&
602 (path = XtResolvePathname (display, "bitmaps", 0, 0, path, 605 (pathext = XtResolvePathname (display, "bitmaps", 0, 0, pathext,
603 subs, XtNumber (subs), 0))) 606 subs, XtNumber (subs), 0)))
604 { 607 {
605 name = build_string (path); 608 name = build_ext_string (pathext, Qfile_name);
606 XtFree (path); 609 XtFree (pathext);
607 return (name); 610 return (name);
608 } 611 }
609 } 612 }
610 #endif 613 #endif
611 614
614 char *type = 0; 617 char *type = 0;
615 XrmValue value; 618 XrmValue value;
616 if (XrmGetResource (XtDatabase (display), 619 if (XrmGetResource (XtDatabase (display),
617 "bitmapFilePath", "BitmapFilePath", &type, &value) 620 "bitmapFilePath", "BitmapFilePath", &type, &value)
618 && !strcmp (type, "String")) 621 && !strcmp (type, "String"))
619 Vx_bitmap_file_path = decode_env_path (0, (char *) value.addr); 622 {
623 Intbyte *path;
624
625 EXTERNAL_TO_C_STRING (value.addr, path, Qfile_name);
626 Vx_bitmap_file_path = split_env_path (0, path);
627 }
620 Vx_bitmap_file_path = nconc2 (Vx_bitmap_file_path, 628 Vx_bitmap_file_path = nconc2 (Vx_bitmap_file_path,
621 (decode_path (BITMAPDIR))); 629 (split_external_path (BITMAPDIR)));
622 } 630 }
623 631
624 { 632 {
625 Lisp_Object found; 633 Lisp_Object found;
626 if (locate_file (Vx_bitmap_file_path, name, Qnil, &found, R_OK) < 0) 634 if (locate_file (Vx_bitmap_file_path, name, Qnil, &found, R_OK) < 0)
640 static Lisp_Object 648 static Lisp_Object
641 locate_pixmap_file (Lisp_Object name) 649 locate_pixmap_file (Lisp_Object name)
642 { 650 {
643 return x_locate_pixmap_file (name); 651 return x_locate_pixmap_file (name);
644 } 652 }
645
646 #if 0
647 static void
648 write_lisp_string_to_temp_file (Lisp_Object string, char *filename_out)
649 {
650 Lisp_Object instream, outstream;
651 Lstream *istr, *ostr;
652 char tempbuf[1024]; /* some random amount */
653 int fubar = 0;
654 FILE *tmpfil;
655 static Extbyte_dynarr *conversion_out_dynarr;
656 Bytecount bstart, bend;
657 struct gcpro gcpro1, gcpro2;
658 #ifdef FILE_CODING
659 Lisp_Object conv_out_stream;
660 Lstream *costr;
661 struct gcpro gcpro3;
662 #endif
663
664 /* This function can GC */
665 if (!conversion_out_dynarr)
666 conversion_out_dynarr = Dynarr_new (Extbyte);
667 else
668 Dynarr_reset (conversion_out_dynarr);
669
670 /* Create the temporary file ... */
671 sprintf (filename_out, "/tmp/emacs%d.XXXXXX", (int) getpid ());
672 mktemp (filename_out);
673 tmpfil = fopen (filename_out, "w");
674 if (!tmpfil)
675 {
676 if (tmpfil)
677 {
678 int old_errno = errno;
679 fclose (tmpfil);
680 unlink (filename_out);
681 errno = old_errno;
682 }
683 report_file_error ("Creating temp file",
684 build_string (filename_out));
685 }
686
687 CHECK_STRING (string);
688 get_string_range_byte (string, Qnil, Qnil, &bstart, &bend,
689 GB_HISTORICAL_STRING_BEHAVIOR);
690 instream = make_lisp_string_input_stream (string, bstart, bend);
691 istr = XLSTREAM (instream);
692 /* setup the out stream */
693 outstream = make_dynarr_output_stream((unsigned_char_dynarr *)conversion_out_dynarr);
694 ostr = XLSTREAM (outstream);
695 #ifdef FILE_CODING
696 /* setup the conversion stream */
697 conv_out_stream = make_encoding_output_stream (ostr, Fget_coding_system(Qbinary));
698 costr = XLSTREAM (conv_out_stream);
699 GCPRO3 (instream, outstream, conv_out_stream);
700 #else
701 GCPRO2 (instream, outstream);
702 #endif
703
704 /* Get the data while doing the conversion */
705 while (1)
706 {
707 Bytecount size_in_bytes = Lstream_read (istr, tempbuf, sizeof (tempbuf));
708 if (!size_in_bytes)
709 break;
710 /* It does seem the flushes are necessary... */
711 #ifdef FILE_CODING
712 Lstream_write (costr, tempbuf, size_in_bytes);
713 Lstream_flush (costr);
714 #else
715 Lstream_write (ostr, tempbuf, size_in_bytes);
716 #endif
717 Lstream_flush (ostr);
718 if (fwrite ((unsigned char *)Dynarr_atp(conversion_out_dynarr, 0),
719 Dynarr_length(conversion_out_dynarr), 1, tmpfil) != 1)
720 {
721 fubar = 1;
722 break;
723 }
724 /* reset the dynarr */
725 Lstream_rewind(ostr);
726 }
727
728 if (fclose (tmpfil) != 0)
729 fubar = 1;
730 Lstream_close (istr);
731 #ifdef FILE_CODING
732 Lstream_close (costr);
733 #endif
734 Lstream_close (ostr);
735
736 UNGCPRO;
737 Lstream_delete (istr);
738 Lstream_delete (ostr);
739 #ifdef FILE_CODING
740 Lstream_delete (costr);
741 #endif
742
743 if (fubar)
744 report_file_error ("Writing temp file",
745 build_string (filename_out));
746 }
747 #endif /* 0 */
748 653
749 654
750 /************************************************************************/ 655 /************************************************************************/
751 /* cursor functions */ 656 /* cursor functions */
752 /************************************************************************/ 657 /************************************************************************/
943 848
944 static void 849 static void
945 x_init_image_instance_from_eimage (Lisp_Image_Instance *ii, 850 x_init_image_instance_from_eimage (Lisp_Image_Instance *ii,
946 int width, int height, 851 int width, int height,
947 int slices, 852 int slices,
948 unsigned char *eimage, 853 UChar_Binary *eimage,
949 int dest_mask, 854 int dest_mask,
950 Lisp_Object instantiator, 855 Lisp_Object instantiator,
951 Lisp_Object domain) 856 Lisp_Object domain)
952 { 857 {
953 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 858 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
992 /* Given inline data for a mono pixmap, create and return the 897 /* Given inline data for a mono pixmap, create and return the
993 corresponding X object. */ 898 corresponding X object. */
994 899
995 static Pixmap 900 static Pixmap
996 pixmap_from_xbm_inline (Lisp_Object device, int width, int height, 901 pixmap_from_xbm_inline (Lisp_Object device, int width, int height,
997 /* Note that data is in ext-format! */ 902 Char_Binary *bits)
998 const char *bits) 903 {
999 { 904 return XCreatePixmapFromBitmapData (DEVICE_X_DISPLAY (XDEVICE (device)),
1000 return XCreatePixmapFromBitmapData 905 XtWindow (DEVICE_XT_APP_SHELL
1001 (DEVICE_X_DISPLAY (XDEVICE (device)), 906 (XDEVICE (device))),
1002 XtWindow (DEVICE_XT_APP_SHELL (XDEVICE (device))), 907 bits, width, height,
1003 (char *) bits, width, height, 908 1, 0, 1);
1004 1, 0, 1);
1005 } 909 }
1006 910
1007 /* Given inline data for a mono pixmap, initialize the given 911 /* Given inline data for a mono pixmap, initialize the given
1008 image instance accordingly. */ 912 image instance accordingly. */
1009 913
1010 static void 914 static void
1011 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii, 915 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii,
1012 int width, int height, 916 int width, int height,
1013 /* Note that data is in ext-format! */ 917 Char_Binary *bits,
1014 const char *bits,
1015 Lisp_Object instantiator, 918 Lisp_Object instantiator,
1016 Lisp_Object pointer_fg, 919 Lisp_Object pointer_fg,
1017 Lisp_Object pointer_bg, 920 Lisp_Object pointer_bg,
1018 int dest_mask, 921 int dest_mask,
1019 Pixmap mask, 922 Pixmap mask,
1062 switch (type) 965 switch (type)
1063 { 966 {
1064 case IMAGE_MONO_PIXMAP: 967 case IMAGE_MONO_PIXMAP:
1065 { 968 {
1066 IMAGE_INSTANCE_X_PIXMAP (ii) = 969 IMAGE_INSTANCE_X_PIXMAP (ii) =
1067 pixmap_from_xbm_inline (device, width, height, (Extbyte *) bits); 970 pixmap_from_xbm_inline (device, width, height, bits);
1068 } 971 }
1069 break; 972 break;
1070 973
1071 case IMAGE_COLOR_PIXMAP: 974 case IMAGE_COLOR_PIXMAP:
1072 { 975 {
1096 happen. */ 999 happen. */
1097 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground; 1000 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
1098 IMAGE_INSTANCE_PIXMAP_BG (ii) = background; 1001 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
1099 IMAGE_INSTANCE_X_PIXMAP (ii) = 1002 IMAGE_INSTANCE_X_PIXMAP (ii) =
1100 XCreatePixmapFromBitmapData (dpy, draw, 1003 XCreatePixmapFromBitmapData (dpy, draw,
1101 (char *) bits, width, height, 1004 (Char_Binary *) bits, width, height,
1102 fg, bg, d); 1005 fg, bg, d);
1103 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = d; 1006 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = d;
1104 } 1007 }
1105 break; 1008 break;
1106 1009
1111 1014
1112 check_pointer_sizes (scr, width, height, instantiator); 1015 check_pointer_sizes (scr, width, height, instantiator);
1113 1016
1114 source = 1017 source =
1115 XCreatePixmapFromBitmapData (dpy, draw, 1018 XCreatePixmapFromBitmapData (dpy, draw,
1116 (char *) bits, width, height, 1019 (Char_Binary *) bits, width, height,
1117 1, 0, 1); 1020 1, 0, 1);
1118 1021
1119 if (NILP (foreground)) 1022 if (NILP (foreground))
1120 foreground = pointer_fg; 1023 foreground = pointer_fg;
1121 if (NILP (background)) 1024 if (NILP (background))
1146 1049
1147 static void 1050 static void
1148 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator, 1051 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
1149 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1052 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1150 int dest_mask, int width, int height, 1053 int dest_mask, int width, int height,
1151 /* Note that data is in ext-format! */ 1054 Char_Binary *bits)
1152 const char *bits)
1153 { 1055 {
1154 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data); 1056 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
1155 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file); 1057 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
1156 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1058 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1157 Pixmap mask = 0; 1059 Pixmap mask = 0;
1158 1060
1159 if (!NILP (mask_data)) 1061 if (!NILP (mask_data))
1160 { 1062 {
1161 const char *ext_data; 1063 Char_Binary *ext_data;
1162 1064
1163 LISP_STRING_TO_EXTERNAL (XCAR (XCDR (XCDR (mask_data))), ext_data, Qbinary); 1065 LISP_STRING_TO_EXTERNAL (XCAR (XCDR (XCDR (mask_data))), ext_data,
1066 Qbinary);
1164 mask = pixmap_from_xbm_inline (IMAGE_INSTANCE_DEVICE (ii), 1067 mask = pixmap_from_xbm_inline (IMAGE_INSTANCE_DEVICE (ii),
1165 XINT (XCAR (mask_data)), 1068 XINT (XCAR (mask_data)),
1166 XINT (XCAR (XCDR (mask_data))), 1069 XINT (XCAR (XCDR (mask_data))),
1167 ext_data); 1070 ext_data);
1168 } 1071 }
1178 x_xbm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 1081 x_xbm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
1179 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1082 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1180 int dest_mask, Lisp_Object domain) 1083 int dest_mask, Lisp_Object domain)
1181 { 1084 {
1182 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1085 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1183 const char *ext_data; 1086 Char_Binary *ext_data;
1184 1087
1185 assert (!NILP (data)); 1088 assert (!NILP (data));
1186 1089
1187 LISP_STRING_TO_EXTERNAL (XCAR (XCDR (XCDR (data))), ext_data, Qbinary); 1090 LISP_STRING_TO_EXTERNAL (XCAR (XCDR (XCDR (data))), ext_data, Qbinary);
1188 1091
1267 /* Duplicate the pixel value so that we still have a lock on it if 1170 /* Duplicate the pixel value so that we still have a lock on it if
1268 the pixel we were passed is later freed. */ 1171 the pixel we were passed is later freed. */
1269 if (! XAllocColor (dpy, cmap, &color)) 1172 if (! XAllocColor (dpy, cmap, &color))
1270 abort (); /* it must be allocable since we're just duplicating it */ 1173 abort (); /* it must be allocable since we're just duplicating it */
1271 1174
1272 symbols [i].name = (char *) XSTRING_DATA (XCAR (cons)); 1175 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (cons), C_STRING_MALLOC,
1273 symbols [i].pixel = color.pixel; 1176 symbols[i].name, Qctext);
1274 symbols [i].value = 0; 1177 symbols[i].pixel = color.pixel;
1178 symbols[i].value = 0;
1275 free_cons (XCONS (cons)); 1179 free_cons (XCONS (cons));
1276 cons = results; 1180 cons = results;
1277 results = XCDR (results); 1181 results = XCDR (results);
1278 free_cons (XCONS (cons)); 1182 free_cons (XCONS (cons));
1279 } 1183 }
1385 } 1289 }
1386 1290
1387 color_symbols = extract_xpm_color_names (&xpmattrs, device, domain, 1291 color_symbols = extract_xpm_color_names (&xpmattrs, device, domain,
1388 color_symbol_alist); 1292 color_symbol_alist);
1389 1293
1390 result = XpmCreatePixmapFromBuffer (dpy, 1294 {
1391 XtWindow(DEVICE_XT_APP_SHELL (XDEVICE(device))), 1295 Extbyte *dataext;
1392 (char *) XSTRING_DATA (data), 1296
1393 &pixmap, &mask, &xpmattrs); 1297 LISP_STRING_TO_EXTERNAL (data, dataext, Qctext);
1298
1299 result =
1300 XpmCreatePixmapFromBuffer (dpy,
1301 XtWindow
1302 (DEVICE_XT_APP_SHELL (XDEVICE(device))),
1303 dataext, &pixmap, &mask, &xpmattrs);
1304 }
1394 1305
1395 if (color_symbols) 1306 if (color_symbols)
1396 { 1307 {
1308 int i;
1309
1310 for (i = 0; i < (int) xpmattrs.numsymbols; i++)
1311 xfree (color_symbols[i].name);
1397 xfree (color_symbols); 1312 xfree (color_symbols);
1398 xpmattrs.colorsymbols = 0; /* in case XpmFreeAttr is too smart... */ 1313 xpmattrs.colorsymbols = 0; /* in case XpmFreeAttr is too smart... */
1399 xpmattrs.numsymbols = 0; 1314 xpmattrs.numsymbols = 0;
1400 } 1315 }
1401 1316
1654 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1569 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1655 int dest_mask, Lisp_Object domain) 1570 int dest_mask, Lisp_Object domain)
1656 { 1571 {
1657 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1572 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1658 int i, stattis; 1573 int i, stattis;
1659 char *bits, *bp; 1574 Char_Binary *bits, *bp;
1660 const char *p; 1575 Char_Binary *p;
1661 const char * volatile emsg = 0; 1576 const Intbyte * volatile emsg = 0;
1662 const char * volatile dstring; 1577 Char_Binary * volatile dstring;
1663 1578
1664 assert (!NILP (data)); 1579 assert (!NILP (data));
1665 1580
1666 LISP_STRING_TO_EXTERNAL (data, dstring, Qbinary); 1581 LISP_STRING_TO_EXTERNAL (data, dstring, Qbinary);
1667 1582
1671 } 1586 }
1672 1587
1673 /* Must use setjmp not SETJMP because we used jmp_buf above not JMP_BUF */ 1588 /* Must use setjmp not SETJMP because we used jmp_buf above not JMP_BUF */
1674 if (!(stattis = setjmp (comp_env))) 1589 if (!(stattis = setjmp (comp_env)))
1675 { 1590 {
1676 UnCompAll ((char *) dstring); 1591 UnCompAll (dstring);
1677 UnGenFace (); 1592 UnGenFace ();
1678 } 1593 }
1679 1594
1680 switch (stattis) 1595 switch (stattis)
1681 { 1596 {
1691 } 1606 }
1692 1607
1693 if (emsg) 1608 if (emsg)
1694 gui_error_2 (emsg, data, Qimage); 1609 gui_error_2 (emsg, data, Qimage);
1695 1610
1696 bp = bits = (char *) alloca (PIXELS / 8); 1611 bp = bits = (Char_Binary *) alloca (PIXELS / 8);
1697 1612
1698 /* the compface library exports char F[], which uses a single byte per 1613 /* the compface library exports char F[], which uses a single byte per
1699 pixel to represent a 48x48 bitmap. Yuck. */ 1614 pixel to represent a 48x48 bitmap. Yuck. */
1700 for (i = 0, p = F; i < (PIXELS / 8); ++i) 1615 for (i = 0, p = F; i < (PIXELS / 8); ++i)
1701 { 1616 {
1703 /* reverse the bit order of each byte... */ 1618 /* reverse the bit order of each byte... */
1704 for (b = n = 0; b < 8; ++b) 1619 for (b = n = 0; b < 8; ++b)
1705 { 1620 {
1706 n |= ((*p++) << b); 1621 n |= ((*p++) << b);
1707 } 1622 }
1708 *bp++ = (char) n; 1623 *bp++ = (Char_Binary) n;
1709 } 1624 }
1710 1625
1711 xbm_instantiate_1 (image_instance, instantiator, pointer_fg, 1626 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
1712 pointer_bg, dest_mask, 48, 48, bits); 1627 pointer_bg, dest_mask, 48, 48, bits);
1713 } 1628 }
1894 XLoadFont_got_error = 1; 1809 XLoadFont_got_error = 1;
1895 return 0; 1810 return 0;
1896 } 1811 }
1897 1812
1898 static Font 1813 static Font
1899 safe_XLoadFont (Display *dpy, char *name) 1814 safe_XLoadFont (Display *dpy, Intbyte *name)
1900 { 1815 {
1901 Font font; 1816 Font font;
1902 int (*old_handler) (Display *, XErrorEvent *); 1817 int (*old_handler) (Display *, XErrorEvent *);
1818 Extbyte *nameext;
1819
1903 XLoadFont_got_error = 0; 1820 XLoadFont_got_error = 0;
1904 XSync (dpy, 0); 1821 XSync (dpy, 0);
1905 old_handler = XSetErrorHandler (XLoadFont_error_handler); 1822 old_handler = XSetErrorHandler (XLoadFont_error_handler);
1906 font = XLoadFont (dpy, name); 1823 C_STRING_TO_EXTERNAL (name, nameext, Qfile_name);
1824 font = XLoadFont (dpy, nameext);
1907 XSync (dpy, 0); 1825 XSync (dpy, 0);
1908 XSetErrorHandler (old_handler); 1826 XSetErrorHandler (old_handler);
1909 if (XLoadFont_got_error) return 0; 1827 if (XLoadFont_got_error) return 0;
1910 return font; 1828 return font;
1911 } 1829 }
1926 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1844 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1927 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 1845 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
1928 Display *dpy; 1846 Display *dpy;
1929 XColor fg, bg; 1847 XColor fg, bg;
1930 Font source, mask; 1848 Font source, mask;
1931 char source_name[MAXPATHLEN], mask_name[MAXPATHLEN], dummy; 1849 Intbyte source_name[PATH_MAX], mask_name[PATH_MAX], dummy;
1932 int source_char, mask_char; 1850 int source_char, mask_char;
1933 int count; 1851 int count;
1934 Lisp_Object foreground, background; 1852 Lisp_Object foreground, background;
1935 1853
1936 if (!DEVICE_X_P (XDEVICE (device))) 1854 if (!DEVICE_X_P (XDEVICE (device)))
1958 count = sscanf ((char *) XSTRING_DATA (data), 1876 count = sscanf ((char *) XSTRING_DATA (data),
1959 "FONT %s %d %s %d %c", 1877 "FONT %s %d %s %d %c",
1960 source_name, &source_char, 1878 source_name, &source_char,
1961 mask_name, &mask_char, &dummy); 1879 mask_name, &mask_char, &dummy);
1962 /* Allow "%s %d %d" as well... */ 1880 /* Allow "%s %d %d" as well... */
1963 if (count == 3 && (1 == sscanf (mask_name, "%d %c", &mask_char, &dummy))) 1881 if (count == 3 && (1 == sscanf ((char *) mask_name, "%d %c", &mask_char,
1882 &dummy)))
1964 count = 4, mask_name[0] = 0; 1883 count = 4, mask_name[0] = 0;
1965 1884
1966 if (count != 2 && count != 4) 1885 if (count != 2 && count != 4)
1967 syntax_error ("invalid cursor specification", data); 1886 syntax_error ("invalid cursor specification", data);
1968 source = safe_XLoadFont (dpy, source_name); 1887 source = safe_XLoadFont (dpy, source_name);
1969 if (! source) 1888 if (! source)
1970 signal_error_2 (Qgui_error, 1889 signal_error_2 (Qgui_error,
1971 "couldn't load font", build_string (source_name), data); 1890 "couldn't load font", build_intstring (source_name), data);
1972 if (count == 2) 1891 if (count == 2)
1973 mask = 0; 1892 mask = 0;
1974 else if (!mask_name[0]) 1893 else if (!mask_name[0])
1975 mask = source; 1894 mask = source;
1976 else 1895 else
1977 { 1896 {
1978 mask = safe_XLoadFont (dpy, mask_name); 1897 mask = safe_XLoadFont (dpy, mask_name);
1979 if (!mask) 1898 if (!mask)
1980 signal_continuable_error_2 (Qgui_error, 1899 signal_continuable_error_2 (Qgui_error,
1981 "couldn't load font", 1900 "couldn't load font",
1982 build_string (mask_name), data); 1901 build_intstring (mask_name), data);
1983 } 1902 }
1984 if (!mask) 1903 if (!mask)
1985 mask_char = 0; 1904 mask_char = 0;
1986 1905
1987 /* #### call XQueryTextExtents() and check_pointer_sizes() here. */ 1906 /* #### call XQueryTextExtents() and check_pointer_sizes() here. */
2022 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1941 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
2023 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1942 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2024 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 1943 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
2025 Display *dpy; 1944 Display *dpy;
2026 int i; 1945 int i;
2027 const char *name_ext; 1946 const Extbyte *name_ext;
2028 Lisp_Object foreground, background; 1947 Lisp_Object foreground, background;
2029 1948
2030 if (!DEVICE_X_P (XDEVICE (device))) 1949 if (!DEVICE_X_P (XDEVICE (device)))
2031 gui_error ("Not an X device", device); 1950 gui_error ("Not an X device", device);
2032 1951
2178 of this for us. */ 2097 of this for us. */
2179 static void 2098 static void
2180 x_redisplay_widget (Lisp_Image_Instance *p) 2099 x_redisplay_widget (Lisp_Image_Instance *p)
2181 { 2100 {
2182 /* This function can GC if IN_REDISPLAY is false. */ 2101 /* This function can GC if IN_REDISPLAY is false. */
2183 #ifdef HAVE_WIDGETS 2102 #ifdef HAVE_X_WIDGETS
2184 widget_value* wv = 0; 2103 widget_value* wv = 0;
2185 2104
2186 /* First get the items if they have changed since this is a 2105 /* First get the items if they have changed since this is a
2187 structural change. As such it will nuke all added values so we 2106 structural change. As such it will nuke all added values so we
2188 need to update most other things after the items have changed.*/ 2107 need to update most other things after the items have changed.*/
2227 } 2146 }
2228 2147
2229 /* Possibly update the text. */ 2148 /* Possibly update the text. */
2230 if (IMAGE_INSTANCE_TEXT_CHANGED (p)) 2149 if (IMAGE_INSTANCE_TEXT_CHANGED (p))
2231 { 2150 {
2232 char* str; 2151 Extbyte* str;
2233 Lisp_Object val = IMAGE_INSTANCE_WIDGET_TEXT (p); 2152 Lisp_Object val = IMAGE_INSTANCE_WIDGET_TEXT (p);
2234 LISP_STRING_TO_EXTERNAL (val, str, Qnative); 2153 LISP_STRING_TO_EXTERNAL (val, str, Qnative);
2235 wv->value = str; 2154 wv->value = str;
2236 } 2155 }
2237 2156
2339 (subwindow, property, data)) 2258 (subwindow, property, data))
2340 { 2259 {
2341 Atom property_atom; 2260 Atom property_atom;
2342 Lisp_Subwindow *sw; 2261 Lisp_Subwindow *sw;
2343 Display *dpy; 2262 Display *dpy;
2263 Extbyte *propext, *dataext;
2264 Bytecount datalen;
2344 2265
2345 CHECK_SUBWINDOW (subwindow); 2266 CHECK_SUBWINDOW (subwindow);
2346 CHECK_STRING (property); 2267 CHECK_STRING (property);
2347 CHECK_STRING (data); 2268 CHECK_STRING (data);
2348 2269
2349 sw = XSUBWINDOW (subwindow); 2270 sw = XSUBWINDOW (subwindow);
2350 dpy = DisplayOfScreen (LISP_DEVICE_TO_X_SCREEN 2271 dpy = DisplayOfScreen (LISP_DEVICE_TO_X_SCREEN
2351 (FRAME_DEVICE (XFRAME (sw->frame)))); 2272 (FRAME_DEVICE (XFRAME (sw->frame))));
2352 2273
2353 property_atom = XInternAtom (dpy, (char *) XSTRING_DATA (property), False); 2274 LISP_TO_EXTERNAL (property, propext, Qctext);
2275 TO_EXTERNAL_FORMAT (LISP_STRING, data,
2276 ALLOCA, (dataext, datalen), Qctext);
2277 property_atom = XInternAtom (dpy, propext, False);
2354 XChangeProperty (dpy, sw->subwindow, property_atom, XA_STRING, 8, 2278 XChangeProperty (dpy, sw->subwindow, property_atom, XA_STRING, 8,
2355 PropModeReplace, 2279 PropModeReplace, dataext, datalen);
2356 XSTRING_DATA (data),
2357 XSTRING_LENGTH (data));
2358
2359 return property; 2280 return property;
2360 } 2281 }
2361 #endif 2282 #endif
2362 2283
2363 2284
2364 #ifdef HAVE_WIDGETS 2285 #ifdef HAVE_X_WIDGETS
2365 2286
2366 /************************************************************************/ 2287 /************************************************************************/
2367 /* widgets */ 2288 /* widgets */
2368 /************************************************************************/ 2289 /************************************************************************/
2369 2290
2556 return Qunbound; 2477 return Qunbound;
2557 } 2478 }
2558 2479
2559 /* Instantiate a layout control for putting other widgets in. */ 2480 /* Instantiate a layout control for putting other widgets in. */
2560 static void 2481 static void
2561 x_native_layout_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2482 x_native_layout_instantiate (Lisp_Object image_instance,
2483 Lisp_Object instantiator,
2562 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2484 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2563 int dest_mask, Lisp_Object domain) 2485 int dest_mask, Lisp_Object domain)
2564 { 2486 {
2565 x_widget_instantiate (image_instance, instantiator, pointer_fg, 2487 x_widget_instantiate (image_instance, instantiator, pointer_fg,
2566 pointer_bg, dest_mask, domain, "layout", 0); 2488 pointer_bg, dest_mask, domain, "layout", 0);
2683 } 2605 }
2684 2606
2685 /* instantiate an edit control */ 2607 /* instantiate an edit control */
2686 static void 2608 static void
2687 x_edit_field_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2609 x_edit_field_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2688 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2610 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2689 int dest_mask, Lisp_Object domain) 2611 int dest_mask, Lisp_Object domain)
2690 { 2612 {
2691 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2613 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2692 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); 2614 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
2693 widget_value* wv = gui_items_to_widget_values (image_instance, gui, 0); 2615 widget_value* wv = gui_items_to_widget_values (image_instance, gui, 0);
2694 2616
2698 2620
2699 #if defined (LWLIB_WIDGETS_MOTIF) && XmVERSION > 1 2621 #if defined (LWLIB_WIDGETS_MOTIF) && XmVERSION > 1
2700 /* instantiate a combo control */ 2622 /* instantiate a combo control */
2701 static void 2623 static void
2702 x_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2624 x_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2703 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2625 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2704 int dest_mask, Lisp_Object domain) 2626 int dest_mask, Lisp_Object domain)
2705 { 2627 {
2706 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2628 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2707 widget_value * wv = 0; 2629 widget_value * wv = 0;
2708 /* This is not done generically because of sizing problems under 2630 /* This is not done generically because of sizing problems under
2709 mswindows. */ 2631 mswindows. */
2832 widget_value* wv = gui_items_to_widget_values (image_instance, gui, 0); 2754 widget_value* wv = gui_items_to_widget_values (image_instance, gui, 0);
2833 2755
2834 x_widget_instantiate (image_instance, instantiator, pointer_fg, 2756 x_widget_instantiate (image_instance, instantiator, pointer_fg,
2835 pointer_bg, dest_mask, domain, "button", wv); 2757 pointer_bg, dest_mask, domain, "button", wv);
2836 } 2758 }
2837 #endif /* HAVE_WIDGETS */ 2759 #endif /* HAVE_X_WIDGETS */
2838 2760
2839 2761
2840 /************************************************************************/ 2762 /************************************************************************/
2841 /* initialization */ 2763 /* initialization */
2842 /************************************************************************/ 2764 /************************************************************************/
2870 void 2792 void
2871 image_instantiator_format_create_glyphs_x (void) 2793 image_instantiator_format_create_glyphs_x (void)
2872 { 2794 {
2873 IIFORMAT_VALID_CONSOLE (x, nothing); 2795 IIFORMAT_VALID_CONSOLE (x, nothing);
2874 IIFORMAT_VALID_CONSOLE (x, string); 2796 IIFORMAT_VALID_CONSOLE (x, string);
2875 #ifdef HAVE_WIDGETS 2797 #ifdef HAVE_X_WIDGETS
2876 IIFORMAT_VALID_CONSOLE (x, layout); 2798 IIFORMAT_VALID_CONSOLE (x, layout);
2877 #endif 2799 #endif
2878 IIFORMAT_VALID_CONSOLE (x, formatted_string); 2800 IIFORMAT_VALID_CONSOLE (x, formatted_string);
2879 IIFORMAT_VALID_CONSOLE (x, inherit); 2801 IIFORMAT_VALID_CONSOLE (x, inherit);
2880 #ifdef HAVE_XPM 2802 #ifdef HAVE_XPM
2896 INITIALIZE_DEVICE_IIFORMAT (x, xbm); 2818 INITIALIZE_DEVICE_IIFORMAT (x, xbm);
2897 IIFORMAT_HAS_DEVMETHOD (x, xbm, instantiate); 2819 IIFORMAT_HAS_DEVMETHOD (x, xbm, instantiate);
2898 2820
2899 INITIALIZE_DEVICE_IIFORMAT (x, subwindow); 2821 INITIALIZE_DEVICE_IIFORMAT (x, subwindow);
2900 IIFORMAT_HAS_DEVMETHOD (x, subwindow, instantiate); 2822 IIFORMAT_HAS_DEVMETHOD (x, subwindow, instantiate);
2901 #ifdef HAVE_WIDGETS 2823 #ifdef HAVE_X_WIDGETS
2902 /* layout widget */ 2824 /* layout widget */
2903 INITIALIZE_DEVICE_IIFORMAT (x, native_layout); 2825 INITIALIZE_DEVICE_IIFORMAT (x, native_layout);
2904 IIFORMAT_HAS_DEVMETHOD (x, native_layout, instantiate); 2826 IIFORMAT_HAS_DEVMETHOD (x, native_layout, instantiate);
2905 /* button widget */ 2827 /* button widget */
2906 INITIALIZE_DEVICE_IIFORMAT (x, button); 2828 INITIALIZE_DEVICE_IIFORMAT (x, button);