Mercurial > hg > xemacs-beta
comparison src/glyphs-x.c @ 4252:8475ff9c49ea
[xemacs-hg @ 2007-11-05 14:59:20 by didierv]
Fix recent image related crashes
author | didierv |
---|---|
date | Mon, 05 Nov 2007 14:59:24 +0000 |
parents | 9b4442ac18c7 |
children | 383ab474a241 |
comparison
equal
deleted
inserted
replaced
4251:b45f331a659d | 4252:8475ff9c49ea |
---|---|
157 /* image instance methods */ | 157 /* image instance methods */ |
158 /************************************************************************/ | 158 /************************************************************************/ |
159 | 159 |
160 /************************************************************************/ | 160 /************************************************************************/ |
161 /* convert from a series of RGB triples to an XImage formated for the */ | 161 /* convert from a series of RGB triples to an XImage formated for the */ |
162 /* proper display */ | 162 /* proper display */ |
163 /************************************************************************/ | 163 /************************************************************************/ |
164 static XImage * | 164 static XImage * |
165 convert_EImage_to_XImage (Lisp_Object device, int width, int height, | 165 convert_EImage_to_XImage (Lisp_Object device, int width, int height, |
166 Binbyte *pic, unsigned long **pixtbl, | 166 Binbyte *pic, unsigned long **pixtbl, |
167 int *npixels) | 167 int *npixels) |
589 #ifdef USE_XBMLANGPATH | 589 #ifdef USE_XBMLANGPATH |
590 { | 590 { |
591 Ibyte *path = egetenv ("XBMLANGPATH"); | 591 Ibyte *path = egetenv ("XBMLANGPATH"); |
592 if (path) | 592 if (path) |
593 { | 593 { |
594 Extbyte *pathext; | 594 Extbyte *pathext; |
595 SubstitutionRec subs[1]; | 595 SubstitutionRec subs[1]; |
596 subs[0].match = 'B'; | 596 subs[0].match = 'B'; |
597 LISP_STRING_TO_EXTERNAL (name, subs[0].substitution, Qfile_name); | 597 LISP_STRING_TO_EXTERNAL (name, subs[0].substitution, Qfile_name); |
598 C_STRING_TO_EXTERNAL (path, pathext, Qfile_name); | 598 C_STRING_TO_EXTERNAL (path, pathext, Qfile_name); |
599 /* #### Motif uses a big hairy default if $XBMLANGPATH isn't set. | 599 /* #### Motif uses a big hairy default if $XBMLANGPATH isn't set. |
600 We don't. If you want it used, set it. */ | 600 We don't. If you want it used, set it. */ |
601 if (pathext && | 601 if (pathext && |
602 (pathext = XtResolvePathname (display, "bitmaps", 0, 0, pathext, | 602 (pathext = XtResolvePathname (display, "bitmaps", 0, 0, pathext, |
603 subs, XtNumber (subs), 0))) | 603 subs, XtNumber (subs), 0))) |
604 { | 604 { |
605 name = build_ext_string (pathext, Qfile_name); | 605 name = build_ext_string (pathext, Qfile_name); |
606 XtFree (pathext); | 606 XtFree (pathext); |
607 return (name); | 607 return (name); |
608 } | 608 } |
609 } | 609 } |
610 } | 610 } |
1309 if (STRINGP (value)) | 1309 if (STRINGP (value)) |
1310 value = | 1310 value = |
1311 Fmake_color_instance | 1311 Fmake_color_instance |
1312 (value, device, encode_error_behavior_flag (ERROR_ME_DEBUG_WARN)); | 1312 (value, device, encode_error_behavior_flag (ERROR_ME_DEBUG_WARN)); |
1313 else | 1313 else |
1314 { | 1314 { |
1315 assert (COLOR_SPECIFIERP (value)); | 1315 assert (COLOR_SPECIFIERP (value)); |
1316 value = Fspecifier_instance (value, domain, Qnil, Qnil); | 1316 value = Fspecifier_instance (value, domain, Qnil, Qnil); |
1317 } | 1317 } |
1318 if (NILP (value)) | 1318 if (NILP (value)) |
1319 continue; | 1319 continue; |
1320 results = noseeum_cons (noseeum_cons (name, value), results); | 1320 results = noseeum_cons (noseeum_cons (name, value), results); |
1321 i++; | 1321 i++; |
1322 } | 1322 } |
1323 UNGCPRO; /* no more evaluation */ | 1323 UNGCPRO; /* no more evaluation */ |
1324 | 1324 |
1560 case IMAGE_POINTER: | 1560 case IMAGE_POINTER: |
1561 if (xpmattrs.valuemask & XpmHotspot) | 1561 if (xpmattrs.valuemask & XpmHotspot) |
1562 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = make_int (xpmattrs.x_hotspot); | 1562 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = make_int (xpmattrs.x_hotspot); |
1563 if (xpmattrs.valuemask & XpmHotspot) | 1563 if (xpmattrs.valuemask & XpmHotspot) |
1564 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = make_int (xpmattrs.y_hotspot); | 1564 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = make_int (xpmattrs.y_hotspot); |
1565 | 1565 |
1566 image_instance_convert_to_pointer (ii, instantiator, pointer_fg, | 1566 image_instance_convert_to_pointer (ii, instantiator, pointer_fg, |
1567 pointer_bg); | 1567 pointer_bg); |
1568 break; | 1568 break; |
1569 | 1569 |
1570 default: | 1570 default: |
1716 alist); | 1716 alist); |
1717 if (yhot != -1) | 1717 if (yhot != -1) |
1718 alist = Fcons (Fcons (Q_hotspot_y, make_int (yhot)), | 1718 alist = Fcons (Fcons (Q_hotspot_y, make_int (yhot)), |
1719 alist); | 1719 alist); |
1720 | 1720 |
1721 alist = xbm_mask_file_munging (alist, filename, Qnil, console_type); | 1721 alist = xbm_mask_file_munging (alist, filename, Qt, console_type); |
1722 | 1722 |
1723 { | 1723 { |
1724 Lisp_Object result = alist_to_tagged_vector (Qxbm, alist); | 1724 Lisp_Object result = alist_to_tagged_vector (Qxbm, alist); |
1725 free_alist (alist); | 1725 free_alist (alist); |
1726 RETURN_UNGCPRO (result); | 1726 RETURN_UNGCPRO (result); |
1787 if (dest_mask & IMAGE_POINTER_MASK) | 1787 if (dest_mask & IMAGE_POINTER_MASK) |
1788 { | 1788 { |
1789 const char *name_ext; | 1789 const char *name_ext; |
1790 LISP_STRING_TO_EXTERNAL (data, name_ext, Qfile_name); | 1790 LISP_STRING_TO_EXTERNAL (data, name_ext, Qfile_name); |
1791 if (XmuCursorNameToIndex (name_ext) != -1) | 1791 if (XmuCursorNameToIndex (name_ext) != -1) |
1792 { | 1792 { |
1793 result = alist_to_tagged_vector (Qcursor_font, alist); | 1793 result = alist_to_tagged_vector (Qcursor_font, alist); |
1794 is_cursor_font = 1; | 1794 is_cursor_font = 1; |
1795 } | 1795 } |
1796 } | 1796 } |
1797 | 1797 |
1798 if (!is_cursor_font) | 1798 if (!is_cursor_font) |
1799 result = alist_to_tagged_vector (Qstring, alist); | 1799 result = alist_to_tagged_vector (Qstring, alist); |
1800 free_alist (alist); | 1800 free_alist (alist); |
2076 else /* must be a widget */ | 2076 else /* must be a widget */ |
2077 { | 2077 { |
2078 /* Since we are being unmapped we want the enclosing frame to | 2078 /* Since we are being unmapped we want the enclosing frame to |
2079 get focus. The losing with simple scrolling but is the safest | 2079 get focus. The losing with simple scrolling but is the safest |
2080 thing to do. */ | 2080 thing to do. */ |
2081 emacs_Xt_handle_widget_losing_focus | 2081 emacs_Xt_handle_widget_losing_focus |
2082 ( XFRAME (IMAGE_INSTANCE_FRAME (p)), | 2082 ( XFRAME (IMAGE_INSTANCE_FRAME (p)), |
2083 IMAGE_INSTANCE_X_WIDGET_ID (p)); | 2083 IMAGE_INSTANCE_X_WIDGET_ID (p)); |
2084 XtUnmapWidget (IMAGE_INSTANCE_X_CLIPWIDGET (p)); | 2084 XtUnmapWidget (IMAGE_INSTANCE_X_CLIPWIDGET (p)); |
2085 } | 2085 } |
2086 } | 2086 } |
2173 yourself lwlibsux, lwlibsux ... lw_get_all_values returns a | 2173 yourself lwlibsux, lwlibsux ... lw_get_all_values returns a |
2174 reference to the real values rather than a copy thus any | 2174 reference to the real values rather than a copy thus any |
2175 changes we make to the values we get back will look like they | 2175 changes we make to the values we get back will look like they |
2176 have already been applied. If we rebuild the widget tree then | 2176 have already been applied. If we rebuild the widget tree then |
2177 we may lose properties. */ | 2177 we may lose properties. */ |
2178 wv = copy_widget_value_tree (lw_get_all_values | 2178 wv = copy_widget_value_tree (lw_get_all_values |
2179 (IMAGE_INSTANCE_X_WIDGET_LWID (p)), | 2179 (IMAGE_INSTANCE_X_WIDGET_LWID (p)), |
2180 NO_CHANGE); | 2180 NO_CHANGE); |
2181 } | 2181 } |
2182 | 2182 |
2183 /* Possibly update the colors and font */ | 2183 /* Possibly update the colors and font */ |
2234 if (XFRAME (IMAGE_INSTANCE_FRAME (p))->size_changed) | 2234 if (XFRAME (IMAGE_INSTANCE_FRAME (p))->size_changed) |
2235 { | 2235 { |
2236 Arg al[2]; | 2236 Arg al[2]; |
2237 XtSetArg (al [0], XtNx, &IMAGE_INSTANCE_X_WIDGET_XOFFSET (p)); | 2237 XtSetArg (al [0], XtNx, &IMAGE_INSTANCE_X_WIDGET_XOFFSET (p)); |
2238 XtSetArg (al [1], XtNy, &IMAGE_INSTANCE_X_WIDGET_YOFFSET (p)); | 2238 XtSetArg (al [1], XtNy, &IMAGE_INSTANCE_X_WIDGET_YOFFSET (p)); |
2239 XtGetValues (FRAME_X_TEXT_WIDGET | 2239 XtGetValues (FRAME_X_TEXT_WIDGET |
2240 (XFRAME (IMAGE_INSTANCE_FRAME (p))), al, 2); | 2240 (XFRAME (IMAGE_INSTANCE_FRAME (p))), al, 2); |
2241 } | 2241 } |
2242 | 2242 |
2243 /* now modify the widget */ | 2243 /* now modify the widget */ |
2244 lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (p), wv, True); | 2244 lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (p), wv, True); |
2975 "autodetect"); | 2975 "autodetect"); |
2976 | 2976 |
2977 IIFORMAT_HAS_METHOD (autodetect, validate); | 2977 IIFORMAT_HAS_METHOD (autodetect, validate); |
2978 IIFORMAT_HAS_METHOD (autodetect, normalize); | 2978 IIFORMAT_HAS_METHOD (autodetect, normalize); |
2979 IIFORMAT_HAS_METHOD (autodetect, possible_dest_types); | 2979 IIFORMAT_HAS_METHOD (autodetect, possible_dest_types); |
2980 /* #### autodetect is flawed IMO: | 2980 /* #### autodetect is flawed IMO: |
2981 1. It makes the assumption that you can detect whether the user | 2981 1. It makes the assumption that you can detect whether the user |
2982 wanted a cursor or a string based on the data, since the data is a | 2982 wanted a cursor or a string based on the data, since the data is a |
2983 string you have to prioritise cursors. Instead we will force users | 2983 string you have to prioritise cursors. Instead we will force users |
2984 to pick the appropriate image type, this is what we do under | 2984 to pick the appropriate image type, this is what we do under |
2985 MS-Windows anyway. | 2985 MS-Windows anyway. |