Mercurial > emacs
comparison src/macfns.c @ 47278:fc811b81d1a3
(Fx_server_max_request_size): Fix spacing.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Fri, 06 Sep 2002 09:04:22 +0000 |
parents | e92a6d6dd53f |
children | 755c4233cfba |
comparison
equal
deleted
inserted
replaced
47277:8a4e82b00f6f | 47278:fc811b81d1a3 |
---|---|
192 (insert (substring (car symbol-list) 1)) | 192 (insert (substring (car symbol-list) 1)) |
193 (subst-char-in-region start (point) ?_ ?-)) | 193 (subst-char-in-region start (point) ?_ ?-)) |
194 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list))) | 194 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list))) |
195 (setq symbol-list (cdr symbol-list))))) | 195 (setq symbol-list (cdr symbol-list))))) |
196 | 196 |
197 */ | 197 */ |
198 | 198 |
199 /*&&& symbols declared here &&&*/ | 199 /*&&& symbols declared here &&&*/ |
200 Lisp_Object Qauto_raise; | 200 Lisp_Object Qauto_raise; |
201 Lisp_Object Qauto_lower; | 201 Lisp_Object Qauto_lower; |
202 Lisp_Object Qborder_color; | 202 Lisp_Object Qborder_color; |
299 error ("Mac OS not in use or not initialized"); | 299 error ("Mac OS not in use or not initialized"); |
300 } | 300 } |
301 | 301 |
302 /* Nonzero if we can use mouse menus. | 302 /* Nonzero if we can use mouse menus. |
303 You should not call this unless HAVE_MENUS is defined. */ | 303 You should not call this unless HAVE_MENUS is defined. */ |
304 | 304 |
305 int | 305 int |
306 have_menus_p () | 306 have_menus_p () |
307 { | 307 { |
308 return mac_in_use; | 308 return mac_in_use; |
309 } | 309 } |
341 } | 341 } |
342 | 342 |
343 if (NILP (frame)) | 343 if (NILP (frame)) |
344 { | 344 { |
345 struct frame *sf = XFRAME (selected_frame); | 345 struct frame *sf = XFRAME (selected_frame); |
346 | 346 |
347 if (FRAME_MAC_P (sf) && FRAME_LIVE_P (sf)) | 347 if (FRAME_MAC_P (sf) && FRAME_LIVE_P (sf)) |
348 return FRAME_MAC_DISPLAY_INFO (sf); | 348 return FRAME_MAC_DISPLAY_INFO (sf); |
349 else | 349 else |
350 return &one_mac_display_info; | 350 return &one_mac_display_info; |
351 } | 351 } |
492 int id; | 492 int id; |
493 | 493 |
494 /* MAC_TODO: for now fail if width is not mod 16 (toolbox requires it) */ | 494 /* MAC_TODO: for now fail if width is not mod 16 (toolbox requires it) */ |
495 | 495 |
496 id = x_allocate_bitmap_record (f); | 496 id = x_allocate_bitmap_record (f); |
497 | 497 |
498 if (width % 16 != 0) | 498 if (width % 16 != 0) |
499 return -1; | 499 return -1; |
500 | 500 |
501 dpyinfo->bitmaps[id - 1].bitmap_data = (char *) xmalloc (height * width); | 501 dpyinfo->bitmaps[id - 1].bitmap_data = (char *) xmalloc (height * width); |
502 if (! dpyinfo->bitmaps[id - 1].bitmap_data) | 502 if (! dpyinfo->bitmaps[id - 1].bitmap_data) |
555 hinst = LoadLibraryEx (filename, NULL, LOAD_LIBRARY_AS_DATAFILE); | 555 hinst = LoadLibraryEx (filename, NULL, LOAD_LIBRARY_AS_DATAFILE); |
556 | 556 |
557 if (hinst == NULL) | 557 if (hinst == NULL) |
558 return -1; | 558 return -1; |
559 | 559 |
560 | 560 |
561 result = XReadBitmapFile (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), | 561 result = XReadBitmapFile (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), |
562 filename, &width, &height, &bitmap, &xhot, &yhot); | 562 filename, &width, &height, &bitmap, &xhot, &yhot); |
563 if (result != BitmapSuccess) | 563 if (result != BitmapSuccess) |
564 return -1; | 564 return -1; |
565 | 565 |
778 height = FRAME_HEIGHT (f); | 778 height = FRAME_HEIGHT (f); |
779 | 779 |
780 /* Process foreground_color and background_color before anything else. | 780 /* Process foreground_color and background_color before anything else. |
781 They are independent of other properties, but other properties (e.g., | 781 They are independent of other properties, but other properties (e.g., |
782 cursor_color) are dependent upon them. */ | 782 cursor_color) are dependent upon them. */ |
783 for (p = 0; p < i; p++) | 783 for (p = 0; p < i; p++) |
784 { | 784 { |
785 Lisp_Object prop, val; | 785 Lisp_Object prop, val; |
786 | 786 |
787 prop = parms[p]; | 787 prop = parms[p]; |
788 val = values[p]; | 788 val = values[p]; |
980 GrafPtr oldport; | 980 GrafPtr oldport; |
981 | 981 |
982 #ifdef TARGET_API_MAC_CARBON | 982 #ifdef TARGET_API_MAC_CARBON |
983 { | 983 { |
984 Rect r; | 984 Rect r; |
985 | 985 |
986 GetWindowPortBounds (f->output_data.mac->mWP, &r); | 986 GetWindowPortBounds (f->output_data.mac->mWP, &r); |
987 SetPt (&pt, r.left, r.top); | 987 SetPt (&pt, r.left, r.top); |
988 } | 988 } |
989 #else /* not TARGET_API_MAC_CARBON */ | 989 #else /* not TARGET_API_MAC_CARBON */ |
990 SetPt (&pt, | 990 SetPt (&pt, |
992 f->output_data.mac->mWP->portRect.top); | 992 f->output_data.mac->mWP->portRect.top); |
993 #endif /* not TARGET_API_MAC_CARBON */ | 993 #endif /* not TARGET_API_MAC_CARBON */ |
994 GetPort (&oldport); | 994 GetPort (&oldport); |
995 LocalToGlobal (&pt); | 995 LocalToGlobal (&pt); |
996 SetPort (oldport); | 996 SetPort (oldport); |
997 | 997 |
998 *xptr = pt.h; | 998 *xptr = pt.h; |
999 *yptr = pt.v; | 999 *yptr = pt.v; |
1000 } | 1000 } |
1001 | 1001 |
1002 /* Insert a description of internally-recorded parameters of frame X | 1002 /* Insert a description of internally-recorded parameters of frame X |
1042 store_in_alist (alistptr, Qdisplay, | 1042 store_in_alist (alistptr, Qdisplay, |
1043 XCAR (FRAME_MAC_DISPLAY_INFO (f)->name_list_element)); | 1043 XCAR (FRAME_MAC_DISPLAY_INFO (f)->name_list_element)); |
1044 } | 1044 } |
1045 | 1045 |
1046 /* The default colors for the Mac color map */ | 1046 /* The default colors for the Mac color map */ |
1047 typedef struct colormap_t | 1047 typedef struct colormap_t |
1048 { | 1048 { |
1049 unsigned long color; | 1049 unsigned long color; |
1050 char *name; | 1050 char *name; |
1051 } colormap_t; | 1051 } colormap_t; |
1052 | 1052 |
1053 colormap_t mac_color_map[] = | 1053 colormap_t mac_color_map[] = |
1054 { | 1054 { |
1055 { RGB_TO_ULONG(255, 250, 250), "snow" }, | 1055 { RGB_TO_ULONG(255, 250, 250), "snow" }, |
1056 { RGB_TO_ULONG(248, 248, 255), "ghost white" }, | 1056 { RGB_TO_ULONG(248, 248, 255), "ghost white" }, |
1057 { RGB_TO_ULONG(248, 248, 255), "GhostWhite" }, | 1057 { RGB_TO_ULONG(248, 248, 255), "GhostWhite" }, |
1058 { RGB_TO_ULONG(245, 245, 245), "white smoke" }, | 1058 { RGB_TO_ULONG(245, 245, 245), "white smoke" }, |
1403 { RGB_TO_ULONG(193, 255, 193), "DarkSeaGreen1" }, | 1403 { RGB_TO_ULONG(193, 255, 193), "DarkSeaGreen1" }, |
1404 { RGB_TO_ULONG(180, 238, 180), "DarkSeaGreen2" }, | 1404 { RGB_TO_ULONG(180, 238, 180), "DarkSeaGreen2" }, |
1405 { RGB_TO_ULONG(155, 205, 155), "DarkSeaGreen3" }, | 1405 { RGB_TO_ULONG(155, 205, 155), "DarkSeaGreen3" }, |
1406 { RGB_TO_ULONG(105, 139, 105), "DarkSeaGreen4" }, | 1406 { RGB_TO_ULONG(105, 139, 105), "DarkSeaGreen4" }, |
1407 { RGB_TO_ULONG(84 , 255, 159), "SeaGreen1" }, | 1407 { RGB_TO_ULONG(84 , 255, 159), "SeaGreen1" }, |
1408 { RGB_TO_ULONG(78 , 238, 148), "SeaGreen2" }, | 1408 { RGB_TO_ULONG(78 , 238, 148), "SeaGreen2" }, |
1409 { RGB_TO_ULONG(67 , 205, 128), "SeaGreen3" }, | 1409 { RGB_TO_ULONG(67 , 205, 128), "SeaGreen3" }, |
1410 { RGB_TO_ULONG(46 , 139, 87 ), "SeaGreen4" }, | 1410 { RGB_TO_ULONG(46 , 139, 87 ), "SeaGreen4" }, |
1411 { RGB_TO_ULONG(154, 255, 154), "PaleGreen1" }, | 1411 { RGB_TO_ULONG(154, 255, 154), "PaleGreen1" }, |
1412 { RGB_TO_ULONG(144, 238, 144), "PaleGreen2" }, | 1412 { RGB_TO_ULONG(144, 238, 144), "PaleGreen2" }, |
1413 { RGB_TO_ULONG(124, 205, 124), "PaleGreen3" }, | 1413 { RGB_TO_ULONG(124, 205, 124), "PaleGreen3" }, |
1812 { | 1812 { |
1813 Lisp_Object ret = Qnil; | 1813 Lisp_Object ret = Qnil; |
1814 int i; | 1814 int i; |
1815 | 1815 |
1816 BLOCK_INPUT; | 1816 BLOCK_INPUT; |
1817 | 1817 |
1818 for (i = 0; i < sizeof (mac_color_map) / sizeof (mac_color_map[0]); i++) | 1818 for (i = 0; i < sizeof (mac_color_map) / sizeof (mac_color_map[0]); i++) |
1819 if (stricmp (colorname, mac_color_map[i].name) == 0) | 1819 if (stricmp (colorname, mac_color_map[i].name) == 0) |
1820 { | 1820 { |
1821 ret = mac_color_map[i].color; | 1821 ret = mac_color_map[i].color; |
1822 break; | 1822 break; |
1825 UNBLOCK_INPUT; | 1825 UNBLOCK_INPUT; |
1826 | 1826 |
1827 return ret; | 1827 return ret; |
1828 } | 1828 } |
1829 | 1829 |
1830 Lisp_Object | 1830 Lisp_Object |
1831 x_to_mac_color (colorname) | 1831 x_to_mac_color (colorname) |
1832 char * colorname; | 1832 char * colorname; |
1833 { | 1833 { |
1834 register Lisp_Object tail, ret = Qnil; | 1834 register Lisp_Object tail, ret = Qnil; |
1835 | 1835 |
1836 BLOCK_INPUT; | 1836 BLOCK_INPUT; |
1837 | 1837 |
1838 if (colorname[0] == '#') | 1838 if (colorname[0] == '#') |
1839 { | 1839 { |
1840 /* Could be an old-style RGB Device specification. */ | 1840 /* Could be an old-style RGB Device specification. */ |
1841 char *color; | 1841 char *color; |
1842 int size; | 1842 int size; |
1843 color = colorname + 1; | 1843 color = colorname + 1; |
1844 | 1844 |
1845 size = strlen(color); | 1845 size = strlen(color); |
1846 if (size == 3 || size == 6 || size == 9 || size == 12) | 1846 if (size == 3 || size == 6 || size == 9 || size == 12) |
1847 { | 1847 { |
1848 unsigned long colorval; | 1848 unsigned long colorval; |
1849 int i, pos; | 1849 int i, pos; |
1850 pos = 0; | 1850 pos = 0; |
1851 size /= 3; | 1851 size /= 3; |
1852 colorval = 0; | 1852 colorval = 0; |
1853 | 1853 |
1854 for (i = 0; i < 3; i++) | 1854 for (i = 0; i < 3; i++) |
1855 { | 1855 { |
1856 char *end; | 1856 char *end; |
1857 char t; | 1857 char t; |
1858 unsigned long value; | 1858 unsigned long value; |
1904 color = colorname + 4; | 1904 color = colorname + 4; |
1905 for (i = 0; i < 3; i++) | 1905 for (i = 0; i < 3; i++) |
1906 { | 1906 { |
1907 char *end; | 1907 char *end; |
1908 unsigned long value; | 1908 unsigned long value; |
1909 | 1909 |
1910 /* The check for 'x' in the following conditional takes into | 1910 /* The check for 'x' in the following conditional takes into |
1911 account the fact that strtol allows a "0x" in front of | 1911 account the fact that strtol allows a "0x" in front of |
1912 our numbers, and we don't. */ | 1912 our numbers, and we don't. */ |
1913 if (!isxdigit(color[0]) || color[1] == 'x') | 1913 if (!isxdigit(color[0]) || color[1] == 'x') |
1914 break; | 1914 break; |
1988 color = end + 1; | 1988 color = end + 1; |
1989 } | 1989 } |
1990 } | 1990 } |
1991 | 1991 |
1992 ret = mac_color_map_lookup (colorname); | 1992 ret = mac_color_map_lookup (colorname); |
1993 | 1993 |
1994 UNBLOCK_INPUT; | 1994 UNBLOCK_INPUT; |
1995 return ret; | 1995 return ret; |
1996 } | 1996 } |
1997 | 1997 |
1998 /* Gamma-correct COLOR on frame F. */ | 1998 /* Gamma-correct COLOR on frame F. */ |
2027 register Lisp_Object tem; | 2027 register Lisp_Object tem; |
2028 unsigned long mac_color_ref; | 2028 unsigned long mac_color_ref; |
2029 | 2029 |
2030 tem = x_to_mac_color (color); | 2030 tem = x_to_mac_color (color); |
2031 | 2031 |
2032 if (!NILP (tem)) | 2032 if (!NILP (tem)) |
2033 { | 2033 { |
2034 if (f) | 2034 if (f) |
2035 { | 2035 { |
2036 /* Apply gamma correction. */ | 2036 /* Apply gamma correction. */ |
2037 mac_color_ref = XUINT (tem); | 2037 mac_color_ref = XUINT (tem); |
2044 color_def->green = GREEN_FROM_ULONG (mac_color_ref); | 2044 color_def->green = GREEN_FROM_ULONG (mac_color_ref); |
2045 color_def->blue = BLUE_FROM_ULONG (mac_color_ref); | 2045 color_def->blue = BLUE_FROM_ULONG (mac_color_ref); |
2046 | 2046 |
2047 return 1; | 2047 return 1; |
2048 } | 2048 } |
2049 else | 2049 else |
2050 { | 2050 { |
2051 return 0; | 2051 return 0; |
2052 } | 2052 } |
2053 } | 2053 } |
2054 | 2054 |
2218 XINT (Vx_hourglass_pointer_shape)); | 2218 XINT (Vx_hourglass_pointer_shape)); |
2219 } | 2219 } |
2220 else | 2220 else |
2221 hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_watch); | 2221 hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_watch); |
2222 x_check_errors (FRAME_W32_DISPLAY (f), "bad busy pointer cursor: %s"); | 2222 x_check_errors (FRAME_W32_DISPLAY (f), "bad busy pointer cursor: %s"); |
2223 | 2223 |
2224 x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s"); | 2224 x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s"); |
2225 if (!EQ (Qnil, Vx_mode_pointer_shape)) | 2225 if (!EQ (Qnil, Vx_mode_pointer_shape)) |
2226 { | 2226 { |
2227 CHECK_NUMBER (Vx_mode_pointer_shape); | 2227 CHECK_NUMBER (Vx_mode_pointer_shape); |
2228 mode_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), | 2228 mode_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), |
2301 | 2301 |
2302 if (mode_cursor != f->output_data.w32->modeline_cursor | 2302 if (mode_cursor != f->output_data.w32->modeline_cursor |
2303 && f->output_data.w32->modeline_cursor != 0) | 2303 && f->output_data.w32->modeline_cursor != 0) |
2304 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->modeline_cursor); | 2304 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->modeline_cursor); |
2305 f->output_data.w32->modeline_cursor = mode_cursor; | 2305 f->output_data.w32->modeline_cursor = mode_cursor; |
2306 | 2306 |
2307 if (cross_cursor != f->output_data.w32->cross_cursor | 2307 if (cross_cursor != f->output_data.w32->cross_cursor |
2308 && f->output_data.w32->cross_cursor != 0) | 2308 && f->output_data.w32->cross_cursor != 0) |
2309 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->cross_cursor); | 2309 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->cross_cursor); |
2310 f->output_data.w32->cross_cursor = cross_cursor; | 2310 f->output_data.w32->cross_cursor = cross_cursor; |
2311 | 2311 |
2327 fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel, | 2327 fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel, |
2328 WHITE_PIX_DEFAULT (f)); | 2328 WHITE_PIX_DEFAULT (f)); |
2329 else | 2329 else |
2330 fore_pixel = FRAME_BACKGROUND_PIXEL (f); | 2330 fore_pixel = FRAME_BACKGROUND_PIXEL (f); |
2331 f->output_data.mac->cursor_pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); | 2331 f->output_data.mac->cursor_pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); |
2332 | 2332 |
2333 /* Make sure that the cursor color differs from the background color. */ | 2333 /* Make sure that the cursor color differs from the background color. */ |
2334 if (f->output_data.mac->cursor_pixel == FRAME_BACKGROUND_PIXEL (f)) | 2334 if (f->output_data.mac->cursor_pixel == FRAME_BACKGROUND_PIXEL (f)) |
2335 { | 2335 { |
2336 f->output_data.mac->cursor_pixel = f->output_data.mac->mouse_pixel; | 2336 f->output_data.mac->cursor_pixel = f->output_data.mac->mouse_pixel; |
2337 if (f->output_data.mac->cursor_pixel == fore_pixel) | 2337 if (f->output_data.mac->cursor_pixel == fore_pixel) |
2410 int result; | 2410 int result; |
2411 | 2411 |
2412 if (NILP (arg) && NILP (oldval)) | 2412 if (NILP (arg) && NILP (oldval)) |
2413 return; | 2413 return; |
2414 | 2414 |
2415 if (STRINGP (arg) && STRINGP (oldval) | 2415 if (STRINGP (arg) && STRINGP (oldval) |
2416 && EQ (Fstring_equal (oldval, arg), Qt)) | 2416 && EQ (Fstring_equal (oldval, arg), Qt)) |
2417 return; | 2417 return; |
2418 | 2418 |
2419 if (SYMBOLP (arg) && SYMBOLP (oldval) && EQ (arg, oldval)) | 2419 if (SYMBOLP (arg) && SYMBOLP (oldval) && EQ (arg, oldval)) |
2420 return; | 2420 return; |
2518 BLOCK_INPUT; | 2518 BLOCK_INPUT; |
2519 result = (STRINGP (fontset_name) | 2519 result = (STRINGP (fontset_name) |
2520 ? x_new_fontset (f, SDATA (fontset_name)) | 2520 ? x_new_fontset (f, SDATA (fontset_name)) |
2521 : x_new_font (f, SDATA (arg))); | 2521 : x_new_font (f, SDATA (arg))); |
2522 UNBLOCK_INPUT; | 2522 UNBLOCK_INPUT; |
2523 | 2523 |
2524 if (EQ (result, Qnil)) | 2524 if (EQ (result, Qnil)) |
2525 error ("Font `%s' is not defined", SDATA (arg)); | 2525 error ("Font `%s' is not defined", SDATA (arg)); |
2526 else if (EQ (result, Qt)) | 2526 else if (EQ (result, Qt)) |
2527 error ("The characters of the given font have varying widths"); | 2527 error ("The characters of the given font have varying widths"); |
2528 else if (STRINGP (result)) | 2528 else if (STRINGP (result)) |
2776 x_set_name (f, name, explicit) | 2776 x_set_name (f, name, explicit) |
2777 struct frame *f; | 2777 struct frame *f; |
2778 Lisp_Object name; | 2778 Lisp_Object name; |
2779 int explicit; | 2779 int explicit; |
2780 { | 2780 { |
2781 /* Make sure that requests from lisp code override requests from | 2781 /* Make sure that requests from lisp code override requests from |
2782 Emacs redisplay code. */ | 2782 Emacs redisplay code. */ |
2783 if (explicit) | 2783 if (explicit) |
2784 { | 2784 { |
2785 /* If we're switching from explicit to implicit, we had better | 2785 /* If we're switching from explicit to implicit, we had better |
2786 update the mode lines and thereby update the title. */ | 2786 update the mode lines and thereby update the title. */ |
2824 #else | 2824 #else |
2825 return; | 2825 return; |
2826 #endif | 2826 #endif |
2827 | 2827 |
2828 BLOCK_INPUT; | 2828 BLOCK_INPUT; |
2829 | 2829 |
2830 { | 2830 { |
2831 Str255 windowTitle; | 2831 Str255 windowTitle; |
2832 if (strlen (SDATA (name)) < 255) | 2832 if (strlen (SDATA (name)) < 255) |
2833 { | 2833 { |
2834 strcpy (windowTitle, SDATA (name)); | 2834 strcpy (windowTitle, SDATA (name)); |
2951 { | 2951 { |
2952 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) | 2952 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) |
2953 = (NILP (arg) | 2953 = (NILP (arg) |
2954 ? vertical_scroll_bar_none | 2954 ? vertical_scroll_bar_none |
2955 : EQ (Qright, arg) | 2955 : EQ (Qright, arg) |
2956 ? vertical_scroll_bar_right | 2956 ? vertical_scroll_bar_right |
2957 : vertical_scroll_bar_left); | 2957 : vertical_scroll_bar_left); |
2958 | 2958 |
2959 /* We set this parameter before creating the window for the | 2959 /* We set this parameter before creating the window for the |
2960 frame, so we can get the geometry right from the start. | 2960 frame, so we can get the geometry right from the start. |
2961 However, if the window hasn't been created yet, we shouldn't | 2961 However, if the window hasn't been created yet, we shouldn't |
2983 wid - 1) / wid; | 2983 wid - 1) / wid; |
2984 #else /* not MAC_OSX */ | 2984 #else /* not MAC_OSX */ |
2985 /* Make the actual width at least 14 pixels and a multiple of a | 2985 /* Make the actual width at least 14 pixels and a multiple of a |
2986 character width. */ | 2986 character width. */ |
2987 FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid; | 2987 FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid; |
2988 | 2988 |
2989 /* Use all of that space (aside from required margins) for the | 2989 /* Use all of that space (aside from required margins) for the |
2990 scroll bar. */ | 2990 scroll bar. */ |
2991 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0; | 2991 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0; |
2992 #endif /* not MAC_OSX */ | 2992 #endif /* not MAC_OSX */ |
2993 if (FRAME_MAC_WINDOW (f)) | 2993 if (FRAME_MAC_WINDOW (f)) |
3006 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f)); | 3006 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f)); |
3007 do_pending_window_change (0); | 3007 do_pending_window_change (0); |
3008 } | 3008 } |
3009 change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0); | 3009 change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0); |
3010 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0; | 3010 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0; |
3011 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0; | 3011 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0; |
3012 } | 3012 } |
3013 | 3013 |
3014 /* Subroutines of creating an frame. */ | 3014 /* Subroutines of creating an frame. */ |
3015 | 3015 |
3016 /* Make sure that Vx_resource_name is set to a reasonable value. | 3016 /* Make sure that Vx_resource_name is set to a reasonable value. |
3239 case RES_TYPE_BOOLEAN: | 3239 case RES_TYPE_BOOLEAN: |
3240 tem = Fdowncase (tem); | 3240 tem = Fdowncase (tem); |
3241 if (!strcmp (SDATA (tem), "on") | 3241 if (!strcmp (SDATA (tem), "on") |
3242 || !strcmp (SDATA (tem), "true")) | 3242 || !strcmp (SDATA (tem), "true")) |
3243 return Qt; | 3243 return Qt; |
3244 else | 3244 else |
3245 return Qnil; | 3245 return Qnil; |
3246 | 3246 |
3247 case RES_TYPE_STRING: | 3247 case RES_TYPE_STRING: |
3248 return tem; | 3248 return tem; |
3249 | 3249 |
3308 * Example: "=80x24+300-49" | 3308 * Example: "=80x24+300-49" |
3309 * The equal sign is optional. | 3309 * The equal sign is optional. |
3310 * It returns a bitmask that indicates which of the four values | 3310 * It returns a bitmask that indicates which of the four values |
3311 * were actually found in the string. For each value found, | 3311 * were actually found in the string. For each value found, |
3312 * the corresponding argument is updated; for each value | 3312 * the corresponding argument is updated; for each value |
3313 * not found, the corresponding argument is left unchanged. | 3313 * not found, the corresponding argument is left unchanged. |
3314 */ | 3314 */ |
3315 | 3315 |
3316 static int | 3316 static int |
3317 read_integer (string, NextString) | 3317 read_integer (string, NextString) |
3318 register char *string; | 3318 register char *string; |
3319 char **NextString; | 3319 char **NextString; |
3320 { | 3320 { |
3321 register int Result = 0; | 3321 register int Result = 0; |
3322 int Sign = 1; | 3322 int Sign = 1; |
3323 | 3323 |
3324 if (*string == '+') | 3324 if (*string == '+') |
3325 string++; | 3325 string++; |
3326 else if (*string == '-') | 3326 else if (*string == '-') |
3327 { | 3327 { |
3328 string++; | 3328 string++; |
3337 return (Result); | 3337 return (Result); |
3338 else | 3338 else |
3339 return (-Result); | 3339 return (-Result); |
3340 } | 3340 } |
3341 | 3341 |
3342 int | 3342 int |
3343 XParseGeometry (string, x, y, width, height) | 3343 XParseGeometry (string, x, y, width, height) |
3344 char *string; | 3344 char *string; |
3345 int *x, *y; | 3345 int *x, *y; |
3346 unsigned int *width, *height; /* RETURN */ | 3346 unsigned int *width, *height; /* RETURN */ |
3347 { | 3347 { |
3348 int mask = NoValue; | 3348 int mask = NoValue; |
3349 register char *strind; | 3349 register char *strind; |
3350 unsigned int tempWidth, tempHeight; | 3350 unsigned int tempWidth, tempHeight; |
3351 int tempX, tempY; | 3351 int tempX, tempY; |
3352 char *nextCharacter; | 3352 char *nextCharacter; |
3353 | 3353 |
3354 if ((string == NULL) || (*string == '\0')) return (mask); | 3354 if ((string == NULL) || (*string == '\0')) return (mask); |
3355 if (*string == '=') | 3355 if (*string == '=') |
3356 string++; /* ignore possible '=' at beg of geometry spec */ | 3356 string++; /* ignore possible '=' at beg of geometry spec */ |
3357 | 3357 |
3358 strind = (char *)string; | 3358 strind = (char *)string; |
3359 if (*strind != '+' && *strind != '-' && *strind != 'x') | 3359 if (*strind != '+' && *strind != '-' && *strind != 'x') |
3360 { | 3360 { |
3361 tempWidth = read_integer (strind, &nextCharacter); | 3361 tempWidth = read_integer (strind, &nextCharacter); |
3362 if (strind == nextCharacter) | 3362 if (strind == nextCharacter) |
3363 return (0); | 3363 return (0); |
3364 strind = nextCharacter; | 3364 strind = nextCharacter; |
3365 mask |= WidthValue; | 3365 mask |= WidthValue; |
3366 } | 3366 } |
3367 | 3367 |
3368 if (*strind == 'x' || *strind == 'X') | 3368 if (*strind == 'x' || *strind == 'X') |
3369 { | 3369 { |
3370 strind++; | 3370 strind++; |
3371 tempHeight = read_integer (strind, &nextCharacter); | 3371 tempHeight = read_integer (strind, &nextCharacter); |
3372 if (strind == nextCharacter) | 3372 if (strind == nextCharacter) |
3373 return (0); | 3373 return (0); |
3374 strind = nextCharacter; | 3374 strind = nextCharacter; |
3375 mask |= HeightValue; | 3375 mask |= HeightValue; |
3376 } | 3376 } |
3377 | 3377 |
3378 if ((*strind == '+') || (*strind == '-')) | 3378 if ((*strind == '+') || (*strind == '-')) |
3379 { | 3379 { |
3380 if (*strind == '-') | 3380 if (*strind == '-') |
3381 { | 3381 { |
3382 strind++; | 3382 strind++; |
3383 tempX = -read_integer (strind, &nextCharacter); | 3383 tempX = -read_integer (strind, &nextCharacter); |
3384 if (strind == nextCharacter) | 3384 if (strind == nextCharacter) |
3385 return (0); | 3385 return (0); |
3386 strind = nextCharacter; | 3386 strind = nextCharacter; |
3387 mask |= XNegative; | 3387 mask |= XNegative; |
3388 | 3388 |
3389 } | 3389 } |
3390 else | 3390 else |
3391 { | 3391 { |
3392 strind++; | 3392 strind++; |
3393 tempX = read_integer (strind, &nextCharacter); | 3393 tempX = read_integer (strind, &nextCharacter); |
3394 if (strind == nextCharacter) | 3394 if (strind == nextCharacter) |
3395 return (0); | 3395 return (0); |
3396 strind = nextCharacter; | 3396 strind = nextCharacter; |
3397 } | 3397 } |
3398 mask |= XValue; | 3398 mask |= XValue; |
3399 if ((*strind == '+') || (*strind == '-')) | 3399 if ((*strind == '+') || (*strind == '-')) |
3400 { | 3400 { |
3401 if (*strind == '-') | 3401 if (*strind == '-') |
3402 { | 3402 { |
3403 strind++; | 3403 strind++; |
3404 tempY = -read_integer (strind, &nextCharacter); | 3404 tempY = -read_integer (strind, &nextCharacter); |
3405 if (strind == nextCharacter) | 3405 if (strind == nextCharacter) |
3406 return (0); | 3406 return (0); |
3417 strind = nextCharacter; | 3417 strind = nextCharacter; |
3418 } | 3418 } |
3419 mask |= YValue; | 3419 mask |= YValue; |
3420 } | 3420 } |
3421 } | 3421 } |
3422 | 3422 |
3423 /* If strind isn't at the end of the string the it's an invalid | 3423 /* If strind isn't at the end of the string the it's an invalid |
3424 geometry specification. */ | 3424 geometry specification. */ |
3425 | 3425 |
3426 if (*strind != '\0') return (0); | 3426 if (*strind != '\0') return (0); |
3427 | 3427 |
3428 if (mask & XValue) | 3428 if (mask & XValue) |
3429 *x = tempX; | 3429 *x = tempX; |
3430 if (mask & YValue) | 3430 if (mask & YValue) |
3431 *y = tempY; | 3431 *y = tempY; |
3432 if (mask & WidthValue) | 3432 if (mask & WidthValue) |
3636 /* Use the resource name as the top-level window name | 3636 /* Use the resource name as the top-level window name |
3637 for looking up resources. Make a non-Lisp copy | 3637 for looking up resources. Make a non-Lisp copy |
3638 for the window manager, so GC relocation won't bother it. | 3638 for the window manager, so GC relocation won't bother it. |
3639 | 3639 |
3640 Elsewhere we specify the window name for the window manager. */ | 3640 Elsewhere we specify the window name for the window manager. */ |
3641 | 3641 |
3642 { | 3642 { |
3643 char *str = (char *) SDATA (Vx_resource_name); | 3643 char *str = (char *) SDATA (Vx_resource_name); |
3644 f->namebuf = (char *) xmalloc (strlen (str) + 1); | 3644 f->namebuf = (char *) xmalloc (strlen (str) + 1); |
3645 strcpy (f->namebuf, str); | 3645 strcpy (f->namebuf, str); |
3646 } | 3646 } |
3940 font = x_new_font (f, "-*-courier-*-10-*-mac-roman"); | 3940 font = x_new_font (f, "-*-courier-*-10-*-mac-roman"); |
3941 if (! STRINGP (font)) | 3941 if (! STRINGP (font)) |
3942 error ("Cannot find any usable font"); | 3942 error ("Cannot find any usable font"); |
3943 UNBLOCK_INPUT; | 3943 UNBLOCK_INPUT; |
3944 | 3944 |
3945 x_default_parameter (f, parms, Qfont, font, | 3945 x_default_parameter (f, parms, Qfont, font, |
3946 "font", "Font", RES_TYPE_STRING); | 3946 "font", "Font", RES_TYPE_STRING); |
3947 } | 3947 } |
3948 | 3948 |
3949 x_default_parameter (f, parms, Qborder_width, make_number (0), | 3949 x_default_parameter (f, parms, Qborder_width, make_number (0), |
3950 "borderwidth", "BorderWidth", RES_TYPE_NUMBER); | 3950 "borderwidth", "BorderWidth", RES_TYPE_NUMBER); |
3993 which calls change_frame_size, which calls Fset_window_buffer, | 3993 which calls change_frame_size, which calls Fset_window_buffer, |
3994 which runs hooks, which call Fvertical_motion. At the end, we | 3994 which runs hooks, which call Fvertical_motion. At the end, we |
3995 end up in init_iterator with a null face cache, which should not | 3995 end up in init_iterator with a null face cache, which should not |
3996 happen. */ | 3996 happen. */ |
3997 init_frame_faces (f); | 3997 init_frame_faces (f); |
3998 | 3998 |
3999 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1), | 3999 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1), |
4000 "menuBar", "MenuBar", RES_TYPE_NUMBER); | 4000 "menuBar", "MenuBar", RES_TYPE_NUMBER); |
4001 x_default_parameter (f, parms, Qtool_bar_lines, make_number (0), | 4001 x_default_parameter (f, parms, Qtool_bar_lines, make_number (0), |
4002 "toolBar", "ToolBar", RES_TYPE_NUMBER); | 4002 "toolBar", "ToolBar", RES_TYPE_NUMBER); |
4003 x_default_parameter (f, parms, Qbuffer_predicate, Qnil, | 4003 x_default_parameter (f, parms, Qbuffer_predicate, Qnil, |
4104 else | 4104 else |
4105 /* Must have been Qnil. */ | 4105 /* Must have been Qnil. */ |
4106 ; | 4106 ; |
4107 } | 4107 } |
4108 UNGCPRO; | 4108 UNGCPRO; |
4109 | 4109 |
4110 /* Make sure windows on this frame appear in calls to next-window | 4110 /* Make sure windows on this frame appear in calls to next-window |
4111 and similar functions. */ | 4111 and similar functions. */ |
4112 Vwindow_list = Qnil; | 4112 Vwindow_list = Qnil; |
4113 | 4113 |
4114 return unbind_to (count, frame); | 4114 return unbind_to (count, frame); |
4115 } | 4115 } |
4116 | 4116 |
4117 /* FRAME is used only to get a handle on the X display. We don't pass the | 4117 /* FRAME is used only to get a handle on the X display. We don't pass the |
4118 display info directly because we're called from frame.c, which doesn't | 4118 display info directly because we're called from frame.c, which doesn't |
4253 If omitted or nil, that stands for the selected frame's display. */) | 4253 If omitted or nil, that stands for the selected frame's display. */) |
4254 (display) | 4254 (display) |
4255 Lisp_Object display; | 4255 Lisp_Object display; |
4256 { | 4256 { |
4257 struct mac_display_info *dpyinfo = check_x_display_info (display); | 4257 struct mac_display_info *dpyinfo = check_x_display_info (display); |
4258 | 4258 |
4259 /* MAC_TODO: check whether this is right */ | 4259 /* MAC_TODO: check whether this is right */ |
4260 return make_number ((unsigned long) (pow (2, dpyinfo->n_cbits))); | 4260 return make_number ((unsigned long) (pow (2, dpyinfo->n_cbits))); |
4261 } | 4261 } |
4262 | 4262 |
4263 DEFUN ("x-server-max-request-size", Fx_server_max_request_size, | 4263 DEFUN ("x-server-max-request-size", Fx_server_max_request_size, |
4264 Sx_server_max_request_size, | 4264 Sx_server_max_request_size, |
4265 0, 1, 0, | 4265 0, 1, 0, |
4266 doc: /* Returns the maximum request size of the server of display DISPLAY. | 4266 doc: /* Returns the maximum request size of the server of display DISPLAY. |
4267 The optional argument DISPLAY specifies which display to ask about. | 4267 The optional argument DISPLAY specifies which display to ask about. |
4268 DISPLAY should be either a frame or a display name (a string). | 4268 DISPLAY should be either a frame or a display name (a string). |
4269 If omitted or nil, that stands for the selected frame's display. */) | 4269 If omitted or nil, that stands for the selected frame's display. */) |
4270 (display) | 4270 (display) |
4271 Lisp_Object display; | 4271 Lisp_Object display; |
4272 { | 4272 { |
4273 struct mac_display_info *dpyinfo = check_x_display_info (display); | 4273 struct mac_display_info *dpyinfo = check_x_display_info (display); |
4274 | 4274 |
4301 int mac_major_version, mac_minor_version; | 4301 int mac_major_version, mac_minor_version; |
4302 SInt32 response; | 4302 SInt32 response; |
4303 | 4303 |
4304 if (Gestalt (gestaltSystemVersion, &response) != noErr) | 4304 if (Gestalt (gestaltSystemVersion, &response) != noErr) |
4305 error ("Cannot get Mac OS version"); | 4305 error ("Cannot get Mac OS version"); |
4306 | 4306 |
4307 mac_major_version = (response >> 8) & 0xf; | 4307 mac_major_version = (response >> 8) & 0xf; |
4308 mac_minor_version = (response >> 4) & 0xf; | 4308 mac_minor_version = (response >> 4) & 0xf; |
4309 | 4309 |
4310 return Fcons (make_number (mac_major_version), | 4310 return Fcons (make_number (mac_major_version), |
4311 Fcons (make_number (mac_minor_version), Qnil)); | 4311 Fcons (make_number (mac_minor_version), Qnil)); |
4328 DISPLAY should be either a frame or a display name (a string). | 4328 DISPLAY should be either a frame or a display name (a string). |
4329 If omitted or nil, that stands for the selected frame's display. */) | 4329 If omitted or nil, that stands for the selected frame's display. */) |
4330 (display) | 4330 (display) |
4331 Lisp_Object display; | 4331 Lisp_Object display; |
4332 { | 4332 { |
4333 /* MAC_TODO: this is an approximation, and only of the main display */ | 4333 /* MAC_TODO: this is an approximation, and only of the main display */ |
4334 | 4334 |
4335 struct mac_display_info *dpyinfo = check_x_display_info (display); | 4335 struct mac_display_info *dpyinfo = check_x_display_info (display); |
4336 short h, v; | 4336 short h, v; |
4337 | 4337 |
4338 ScreenRes (&h, &v); | 4338 ScreenRes (&h, &v); |
4339 | 4339 |
4340 return make_number ((int) (v / 72.0 * 25.4)); | 4340 return make_number ((int) (v / 72.0 * 25.4)); |
4341 } | 4341 } |
4342 | 4342 |
4343 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, | 4343 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, |
4344 doc: /* Return the width in millimeters of the X display DISPLAY. | 4344 doc: /* Return the width in millimeters of the X display DISPLAY. |
4346 DISPLAY should be either a frame or a display name (a string). | 4346 DISPLAY should be either a frame or a display name (a string). |
4347 If omitted or nil, that stands for the selected frame's display. */) | 4347 If omitted or nil, that stands for the selected frame's display. */) |
4348 (display) | 4348 (display) |
4349 Lisp_Object display; | 4349 Lisp_Object display; |
4350 { | 4350 { |
4351 /* MAC_TODO: this is an approximation, and only of the main display */ | 4351 /* MAC_TODO: this is an approximation, and only of the main display */ |
4352 | 4352 |
4353 struct mac_display_info *dpyinfo = check_x_display_info (display); | 4353 struct mac_display_info *dpyinfo = check_x_display_info (display); |
4354 short h, v; | 4354 short h, v; |
4355 | 4355 |
4356 ScreenRes (&h, &v); | 4356 ScreenRes (&h, &v); |
4357 | 4357 |
4358 return make_number ((int) (h / 72.0 * 25.4)); | 4358 return make_number ((int) (h / 72.0 * 25.4)); |
4359 } | 4359 } |
4360 | 4360 |
4361 DEFUN ("x-display-backing-store", Fx_display_backing_store, | 4361 DEFUN ("x-display-backing-store", Fx_display_backing_store, |
4362 Sx_display_backing_store, 0, 1, 0, | 4362 Sx_display_backing_store, 0, 1, 0, |
4689 int | 4689 int |
4690 valid_image_p (object) | 4690 valid_image_p (object) |
4691 Lisp_Object object; | 4691 Lisp_Object object; |
4692 { | 4692 { |
4693 int valid_p = 0; | 4693 int valid_p = 0; |
4694 | 4694 |
4695 if (CONSP (object) && EQ (XCAR (object), Qimage)) | 4695 if (CONSP (object) && EQ (XCAR (object), Qimage)) |
4696 { | 4696 { |
4697 Lisp_Object symbol = Fplist_get (XCDR (object), QCtype); | 4697 Lisp_Object symbol = Fplist_get (XCDR (object), QCtype); |
4698 struct image_type *type = lookup_image_type (symbol); | 4698 struct image_type *type = lookup_image_type (symbol); |
4699 | 4699 |
4700 if (type) | 4700 if (type) |
4701 valid_p = type->valid_p (object); | 4701 valid_p = type->valid_p (object); |
4702 } | 4702 } |
4703 | 4703 |
4704 return valid_p; | 4704 return valid_p; |
4812 | 4812 |
4813 /* Record that we recognized the keyword. If a keywords | 4813 /* Record that we recognized the keyword. If a keywords |
4814 was found more than once, it's an error. */ | 4814 was found more than once, it's an error. */ |
4815 keywords[i].value = value; | 4815 keywords[i].value = value; |
4816 ++keywords[i].count; | 4816 ++keywords[i].count; |
4817 | 4817 |
4818 if (keywords[i].count > 1) | 4818 if (keywords[i].count > 1) |
4819 return 0; | 4819 return 0; |
4820 | 4820 |
4821 /* Check type of value against allowed type. */ | 4821 /* Check type of value against allowed type. */ |
4822 switch (keywords[i].type) | 4822 switch (keywords[i].type) |
4862 case IMAGE_DONT_CHECK_VALUE_TYPE: | 4862 case IMAGE_DONT_CHECK_VALUE_TYPE: |
4863 break; | 4863 break; |
4864 | 4864 |
4865 case IMAGE_FUNCTION_VALUE: | 4865 case IMAGE_FUNCTION_VALUE: |
4866 value = indirect_function (value); | 4866 value = indirect_function (value); |
4867 if (SUBRP (value) | 4867 if (SUBRP (value) |
4868 || COMPILEDP (value) | 4868 || COMPILEDP (value) |
4869 || (CONSP (value) && EQ (XCAR (value), Qlambda))) | 4869 || (CONSP (value) && EQ (XCAR (value), Qlambda))) |
4870 break; | 4870 break; |
4871 return 0; | 4871 return 0; |
4872 | 4872 |
4911 image_spec_value (spec, key, found) | 4911 image_spec_value (spec, key, found) |
4912 Lisp_Object spec, key; | 4912 Lisp_Object spec, key; |
4913 int *found; | 4913 int *found; |
4914 { | 4914 { |
4915 Lisp_Object tail; | 4915 Lisp_Object tail; |
4916 | 4916 |
4917 xassert (valid_image_p (spec)); | 4917 xassert (valid_image_p (spec)); |
4918 | 4918 |
4919 for (tail = XCDR (spec); | 4919 for (tail = XCDR (spec); |
4920 CONSP (tail) && CONSP (XCDR (tail)); | 4920 CONSP (tail) && CONSP (XCDR (tail)); |
4921 tail = XCDR (XCDR (tail))) | 4921 tail = XCDR (XCDR (tail))) |
4925 if (found) | 4925 if (found) |
4926 *found = 1; | 4926 *found = 1; |
4927 return XCAR (XCDR (tail)); | 4927 return XCAR (XCDR (tail)); |
4928 } | 4928 } |
4929 } | 4929 } |
4930 | 4930 |
4931 if (found) | 4931 if (found) |
4932 *found = 0; | 4932 *found = 0; |
4933 return Qnil; | 4933 return Qnil; |
4934 } | 4934 } |
4935 | 4935 |
4936 | 4936 |
4937 | 4937 |
4938 | 4938 |
4939 /*********************************************************************** | 4939 /*********************************************************************** |
4940 Image type independent image structures | 4940 Image type independent image structures |
4951 make_image (spec, hash) | 4951 make_image (spec, hash) |
4952 Lisp_Object spec; | 4952 Lisp_Object spec; |
4953 unsigned hash; | 4953 unsigned hash; |
4954 { | 4954 { |
4955 struct image *img = (struct image *) xmalloc (sizeof *img); | 4955 struct image *img = (struct image *) xmalloc (sizeof *img); |
4956 | 4956 |
4957 xassert (valid_image_p (spec)); | 4957 xassert (valid_image_p (spec)); |
4958 bzero (img, sizeof *img); | 4958 bzero (img, sizeof *img); |
4959 img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL)); | 4959 img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL)); |
4960 xassert (img->type != NULL); | 4960 xassert (img->type != NULL); |
4961 img->spec = spec; | 4961 img->spec = spec; |
5012 /* If IMG doesn't have a pixmap yet, load it now, using the image | 5012 /* If IMG doesn't have a pixmap yet, load it now, using the image |
5013 type dependent loader function. */ | 5013 type dependent loader function. */ |
5014 if (img->pixmap == 0 && !img->load_failed_p) | 5014 if (img->pixmap == 0 && !img->load_failed_p) |
5015 img->load_failed_p = img->type->load (f, img) == 0; | 5015 img->load_failed_p = img->type->load (f, img) == 0; |
5016 } | 5016 } |
5017 | 5017 |
5018 | 5018 |
5019 /* Value is the number of pixels for the ascent of image IMG when | 5019 /* Value is the number of pixels for the ascent of image IMG when |
5020 drawn in face FACE. */ | 5020 drawn in face FACE. */ |
5021 | 5021 |
5022 int | 5022 int |
5071 } | 5071 } |
5072 | 5072 |
5073 if (img->ncolors) | 5073 if (img->ncolors) |
5074 { | 5074 { |
5075 int class = FRAME_W32_DISPLAY_INFO (f)->visual->class; | 5075 int class = FRAME_W32_DISPLAY_INFO (f)->visual->class; |
5076 | 5076 |
5077 /* If display has an immutable color map, freeing colors is not | 5077 /* If display has an immutable color map, freeing colors is not |
5078 necessary and some servers don't allow it. So don't do it. */ | 5078 necessary and some servers don't allow it. So don't do it. */ |
5079 if (class != StaticColor | 5079 if (class != StaticColor |
5080 && class != StaticGray | 5080 && class != StaticGray |
5081 && class != TrueColor) | 5081 && class != TrueColor) |
5085 cmap = DefaultColormapOfScreen (FRAME_W32_DISPLAY_INFO (f)->screen); | 5085 cmap = DefaultColormapOfScreen (FRAME_W32_DISPLAY_INFO (f)->screen); |
5086 XFreeColors (FRAME_W32_DISPLAY (f), cmap, img->colors, | 5086 XFreeColors (FRAME_W32_DISPLAY (f), cmap, img->colors, |
5087 img->ncolors, 0); | 5087 img->ncolors, 0); |
5088 UNBLOCK_INPUT; | 5088 UNBLOCK_INPUT; |
5089 } | 5089 } |
5090 | 5090 |
5091 xfree (img->colors); | 5091 xfree (img->colors); |
5092 img->colors = NULL; | 5092 img->colors = NULL; |
5093 img->ncolors = 0; | 5093 img->ncolors = 0; |
5094 } | 5094 } |
5095 #endif /* MAC_TODO */ | 5095 #endif /* MAC_TODO */ |
5147 struct image_cache * | 5147 struct image_cache * |
5148 make_image_cache () | 5148 make_image_cache () |
5149 { | 5149 { |
5150 struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c); | 5150 struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c); |
5151 int size; | 5151 int size; |
5152 | 5152 |
5153 bzero (c, sizeof *c); | 5153 bzero (c, sizeof *c); |
5154 c->size = 50; | 5154 c->size = 50; |
5155 c->images = (struct image **) xmalloc (c->size * sizeof *c->images); | 5155 c->images = (struct image **) xmalloc (c->size * sizeof *c->images); |
5156 size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; | 5156 size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; |
5157 c->buckets = (struct image **) xmalloc (size); | 5157 c->buckets = (struct image **) xmalloc (size); |
5172 { | 5172 { |
5173 int i; | 5173 int i; |
5174 | 5174 |
5175 /* Cache should not be referenced by any frame when freed. */ | 5175 /* Cache should not be referenced by any frame when freed. */ |
5176 xassert (c->refcount == 0); | 5176 xassert (c->refcount == 0); |
5177 | 5177 |
5178 for (i = 0; i < c->used; ++i) | 5178 for (i = 0; i < c->used; ++i) |
5179 free_image (f, c->images[i]); | 5179 free_image (f, c->images[i]); |
5180 xfree (c->images); | 5180 xfree (c->images); |
5181 xfree (c->buckets); | 5181 xfree (c->buckets); |
5182 xfree (c); | 5182 xfree (c); |
5205 unsigned long old; | 5205 unsigned long old; |
5206 int i, any_freed_p = 0; | 5206 int i, any_freed_p = 0; |
5207 | 5207 |
5208 EMACS_GET_TIME (t); | 5208 EMACS_GET_TIME (t); |
5209 old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay); | 5209 old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay); |
5210 | 5210 |
5211 for (i = 0; i < c->used; ++i) | 5211 for (i = 0; i < c->used; ++i) |
5212 { | 5212 { |
5213 struct image *img = c->images[i]; | 5213 struct image *img = c->images[i]; |
5214 if (img != NULL | 5214 if (img != NULL |
5215 && (force_p | 5215 && (force_p |
5242 Lisp_Object frame; | 5242 Lisp_Object frame; |
5243 { | 5243 { |
5244 if (EQ (frame, Qt)) | 5244 if (EQ (frame, Qt)) |
5245 { | 5245 { |
5246 Lisp_Object tail; | 5246 Lisp_Object tail; |
5247 | 5247 |
5248 FOR_EACH_FRAME (tail, frame) | 5248 FOR_EACH_FRAME (tail, frame) |
5249 if (FRAME_MAC_P (XFRAME (frame))) | 5249 if (FRAME_MAC_P (XFRAME (frame))) |
5250 clear_image_cache (XFRAME (frame), 1); | 5250 clear_image_cache (XFRAME (frame), 1); |
5251 } | 5251 } |
5252 else | 5252 else |
5273 | 5273 |
5274 /* F must be a window-system frame, and SPEC must be a valid image | 5274 /* F must be a window-system frame, and SPEC must be a valid image |
5275 specification. */ | 5275 specification. */ |
5276 xassert (FRAME_WINDOW_P (f)); | 5276 xassert (FRAME_WINDOW_P (f)); |
5277 xassert (valid_image_p (spec)); | 5277 xassert (valid_image_p (spec)); |
5278 | 5278 |
5279 GCPRO1 (spec); | 5279 GCPRO1 (spec); |
5280 | 5280 |
5281 /* Look up SPEC in the hash table of the image cache. */ | 5281 /* Look up SPEC in the hash table of the image cache. */ |
5282 hash = sxhash (spec, 0); | 5282 hash = sxhash (spec, 0); |
5283 i = hash % IMAGE_CACHE_BUCKETS_SIZE; | 5283 i = hash % IMAGE_CACHE_BUCKETS_SIZE; |
5330 if (XINT (XCAR (margin)) > 0) | 5330 if (XINT (XCAR (margin)) > 0) |
5331 img->hmargin = XFASTINT (XCAR (margin)); | 5331 img->hmargin = XFASTINT (XCAR (margin)); |
5332 if (XINT (XCDR (margin)) > 0) | 5332 if (XINT (XCDR (margin)) > 0) |
5333 img->vmargin = XFASTINT (XCDR (margin)); | 5333 img->vmargin = XFASTINT (XCDR (margin)); |
5334 } | 5334 } |
5335 | 5335 |
5336 relief = image_spec_value (spec, QCrelief, NULL); | 5336 relief = image_spec_value (spec, QCrelief, NULL); |
5337 if (INTEGERP (relief)) | 5337 if (INTEGERP (relief)) |
5338 { | 5338 { |
5339 img->relief = XINT (relief); | 5339 img->relief = XINT (relief); |
5340 img->hmargin += abs (img->relief); | 5340 img->hmargin += abs (img->relief); |
5344 } | 5344 } |
5345 | 5345 |
5346 /* We're using IMG, so set its timestamp to `now'. */ | 5346 /* We're using IMG, so set its timestamp to `now'. */ |
5347 EMACS_GET_TIME (now); | 5347 EMACS_GET_TIME (now); |
5348 img->timestamp = EMACS_SECS (now); | 5348 img->timestamp = EMACS_SECS (now); |
5349 | 5349 |
5350 UNGCPRO; | 5350 UNGCPRO; |
5351 | 5351 |
5352 /* Value is the image id. */ | 5352 /* Value is the image id. */ |
5353 return img->id; | 5353 return img->id; |
5354 } | 5354 } |
5355 | 5355 |
5356 | 5356 |
5500 struct frame *f; | 5500 struct frame *f; |
5501 XImage *ximg; | 5501 XImage *ximg; |
5502 Pixmap pixmap; | 5502 Pixmap pixmap; |
5503 { | 5503 { |
5504 GC gc; | 5504 GC gc; |
5505 | 5505 |
5506 xassert (interrupt_input_blocked); | 5506 xassert (interrupt_input_blocked); |
5507 gc = XCreateGC (NULL, pixmap, 0, NULL); | 5507 gc = XCreateGC (NULL, pixmap, 0, NULL); |
5508 XPutImage (NULL, pixmap, gc, ximg, 0, 0, 0, 0, width, height); | 5508 XPutImage (NULL, pixmap, gc, ximg, 0, 0, 0, 0, width, height); |
5509 XFreeGC (NULL, gc); | 5509 XFreeGC (NULL, gc); |
5510 } | 5510 } |
5534 search_path = Fcons (Vdata_directory, Vx_bitmap_file_path); | 5534 search_path = Fcons (Vdata_directory, Vx_bitmap_file_path); |
5535 GCPRO2 (file_found, search_path); | 5535 GCPRO2 (file_found, search_path); |
5536 | 5536 |
5537 /* Try to find FILE in data-directory, then x-bitmap-file-path. */ | 5537 /* Try to find FILE in data-directory, then x-bitmap-file-path. */ |
5538 fd = openp (search_path, file, Qnil, &file_found, Qnil); | 5538 fd = openp (search_path, file, Qnil, &file_found, Qnil); |
5539 | 5539 |
5540 if (fd < 0) | 5540 if (fd < 0) |
5541 file_found = Qnil; | 5541 file_found = Qnil; |
5542 else | 5542 else |
5543 close (fd); | 5543 close (fd); |
5544 | 5544 |
5614 { | 5614 { |
5615 XBM_TK_IDENT = 256, | 5615 XBM_TK_IDENT = 256, |
5616 XBM_TK_NUMBER | 5616 XBM_TK_NUMBER |
5617 }; | 5617 }; |
5618 | 5618 |
5619 | 5619 |
5620 /* Return non-zero if OBJECT is a valid XBM-type image specification. | 5620 /* Return non-zero if OBJECT is a valid XBM-type image specification. |
5621 A valid specification is a list starting with the symbol `image' | 5621 A valid specification is a list starting with the symbol `image' |
5622 The rest of the list is a property list which must contain an | 5622 The rest of the list is a property list which must contain an |
5623 entry `:type xbm.. | 5623 entry `:type xbm.. |
5624 | 5624 |
5645 static int | 5645 static int |
5646 xbm_image_p (object) | 5646 xbm_image_p (object) |
5647 Lisp_Object object; | 5647 Lisp_Object object; |
5648 { | 5648 { |
5649 struct image_keyword kw[XBM_LAST]; | 5649 struct image_keyword kw[XBM_LAST]; |
5650 | 5650 |
5651 bcopy (xbm_format, kw, sizeof kw); | 5651 bcopy (xbm_format, kw, sizeof kw); |
5652 if (!parse_image_spec (object, kw, XBM_LAST, Qxbm)) | 5652 if (!parse_image_spec (object, kw, XBM_LAST, Qxbm)) |
5653 return 0; | 5653 return 0; |
5654 | 5654 |
5655 xassert (EQ (kw[XBM_TYPE].value, Qxbm)); | 5655 xassert (EQ (kw[XBM_TYPE].value, Qxbm)); |
5671 return 0; | 5671 return 0; |
5672 | 5672 |
5673 data = kw[XBM_DATA].value; | 5673 data = kw[XBM_DATA].value; |
5674 width = XFASTINT (kw[XBM_WIDTH].value); | 5674 width = XFASTINT (kw[XBM_WIDTH].value); |
5675 height = XFASTINT (kw[XBM_HEIGHT].value); | 5675 height = XFASTINT (kw[XBM_HEIGHT].value); |
5676 | 5676 |
5677 /* Check type of data, and width and height against contents of | 5677 /* Check type of data, and width and height against contents of |
5678 data. */ | 5678 data. */ |
5679 if (VECTORP (data)) | 5679 if (VECTORP (data)) |
5680 { | 5680 { |
5681 int i; | 5681 int i; |
5682 | 5682 |
5683 /* Number of elements of the vector must be >= height. */ | 5683 /* Number of elements of the vector must be >= height. */ |
5684 if (XVECTOR (data)->size < height) | 5684 if (XVECTOR (data)->size < height) |
5685 return 0; | 5685 return 0; |
5686 | 5686 |
5687 /* Each string or bool-vector in data must be large enough | 5687 /* Each string or bool-vector in data must be large enough |
5722 | 5722 |
5723 /* Baseline must be a value between 0 and 100 (a percentage). */ | 5723 /* Baseline must be a value between 0 and 100 (a percentage). */ |
5724 if (kw[XBM_ASCENT].count | 5724 if (kw[XBM_ASCENT].count |
5725 && XFASTINT (kw[XBM_ASCENT].value) > 100) | 5725 && XFASTINT (kw[XBM_ASCENT].value) > 100) |
5726 return 0; | 5726 return 0; |
5727 | 5727 |
5728 return 1; | 5728 return 1; |
5729 } | 5729 } |
5730 | 5730 |
5731 | 5731 |
5732 /* Scan a bitmap file. FP is the stream to read from. Value is | 5732 /* Scan a bitmap file. FP is the stream to read from. Value is |
5740 FILE *fp; | 5740 FILE *fp; |
5741 char *sval; | 5741 char *sval; |
5742 int *ival; | 5742 int *ival; |
5743 { | 5743 { |
5744 int c; | 5744 int c; |
5745 | 5745 |
5746 /* Skip white space. */ | 5746 /* Skip white space. */ |
5747 while ((c = fgetc (fp)) != EOF && isspace (c)) | 5747 while ((c = fgetc (fp)) != EOF && isspace (c)) |
5748 ; | 5748 ; |
5749 | 5749 |
5750 if (c == EOF) | 5750 if (c == EOF) |
5751 c = 0; | 5751 c = 0; |
5752 else if (isdigit (c)) | 5752 else if (isdigit (c)) |
5753 { | 5753 { |
5754 int value = 0, digit; | 5754 int value = 0, digit; |
5755 | 5755 |
5756 if (c == '0') | 5756 if (c == '0') |
5757 { | 5757 { |
5758 c = fgetc (fp); | 5758 c = fgetc (fp); |
5759 if (c == 'x' || c == 'X') | 5759 if (c == 'x' || c == 'X') |
5760 { | 5760 { |
5834 | 5834 |
5835 #define expect(TOKEN) \ | 5835 #define expect(TOKEN) \ |
5836 if (LA1 != (TOKEN)) \ | 5836 if (LA1 != (TOKEN)) \ |
5837 goto failure; \ | 5837 goto failure; \ |
5838 else \ | 5838 else \ |
5839 match () | 5839 match () |
5840 | 5840 |
5841 #define expect_ident(IDENT) \ | 5841 #define expect_ident(IDENT) \ |
5842 if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0) \ | 5842 if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0) \ |
5843 match (); \ | 5843 match (); \ |
5844 else \ | 5844 else \ |
5878 expect_ident ("static"); | 5878 expect_ident ("static"); |
5879 if (LA1 == XBM_TK_IDENT) | 5879 if (LA1 == XBM_TK_IDENT) |
5880 { | 5880 { |
5881 if (strcmp (buffer, "unsigned") == 0) | 5881 if (strcmp (buffer, "unsigned") == 0) |
5882 { | 5882 { |
5883 match (); | 5883 match (); |
5884 expect_ident ("char"); | 5884 expect_ident ("char"); |
5885 } | 5885 } |
5886 else if (strcmp (buffer, "short") == 0) | 5886 else if (strcmp (buffer, "short") == 0) |
5887 { | 5887 { |
5888 match (); | 5888 match (); |
5893 else if (strcmp (buffer, "char") == 0) | 5893 else if (strcmp (buffer, "char") == 0) |
5894 match (); | 5894 match (); |
5895 else | 5895 else |
5896 goto failure; | 5896 goto failure; |
5897 } | 5897 } |
5898 else | 5898 else |
5899 goto failure; | 5899 goto failure; |
5900 | 5900 |
5901 expect (XBM_TK_IDENT); | 5901 expect (XBM_TK_IDENT); |
5902 expect ('['); | 5902 expect ('['); |
5903 expect (']'); | 5903 expect (']'); |
5908 nbytes = bytes_per_line * *height; | 5908 nbytes = bytes_per_line * *height; |
5909 p = *data = (char *) xmalloc (nbytes); | 5909 p = *data = (char *) xmalloc (nbytes); |
5910 | 5910 |
5911 if (v10) | 5911 if (v10) |
5912 { | 5912 { |
5913 | 5913 |
5914 for (i = 0; i < nbytes; i += 2) | 5914 for (i = 0; i < nbytes; i += 2) |
5915 { | 5915 { |
5916 int val = value; | 5916 int val = value; |
5917 expect (XBM_TK_NUMBER); | 5917 expect (XBM_TK_NUMBER); |
5918 | 5918 |
5919 *p++ = val; | 5919 *p++ = val; |
5920 if (!padding_p || ((i + 2) % bytes_per_line)) | 5920 if (!padding_p || ((i + 2) % bytes_per_line)) |
5921 *p++ = value >> 8; | 5921 *p++ = value >> 8; |
5922 | 5922 |
5923 if (LA1 == ',' || LA1 == '}') | 5923 if (LA1 == ',' || LA1 == '}') |
5924 match (); | 5924 match (); |
5925 else | 5925 else |
5926 goto failure; | 5926 goto failure; |
5927 } | 5927 } |
5930 { | 5930 { |
5931 for (i = 0; i < nbytes; ++i) | 5931 for (i = 0; i < nbytes; ++i) |
5932 { | 5932 { |
5933 int val = value; | 5933 int val = value; |
5934 expect (XBM_TK_NUMBER); | 5934 expect (XBM_TK_NUMBER); |
5935 | 5935 |
5936 *p++ = val; | 5936 *p++ = val; |
5937 | 5937 |
5938 if (LA1 == ',' || LA1 == '}') | 5938 if (LA1 == ',' || LA1 == '}') |
5939 match (); | 5939 match (); |
5940 else | 5940 else |
5941 goto failure; | 5941 goto failure; |
5942 } | 5942 } |
5944 | 5944 |
5945 fclose (fp); | 5945 fclose (fp); |
5946 return 1; | 5946 return 1; |
5947 | 5947 |
5948 failure: | 5948 failure: |
5949 | 5949 |
5950 fclose (fp); | 5950 fclose (fp); |
5951 if (*data) | 5951 if (*data) |
5952 { | 5952 { |
5953 xfree (*data); | 5953 xfree (*data); |
5954 *data = NULL; | 5954 *data = NULL; |
5973 int rc; | 5973 int rc; |
5974 unsigned char *data; | 5974 unsigned char *data; |
5975 int success_p = 0; | 5975 int success_p = 0; |
5976 Lisp_Object file; | 5976 Lisp_Object file; |
5977 struct gcpro gcpro1; | 5977 struct gcpro gcpro1; |
5978 | 5978 |
5979 xassert (STRINGP (specified_file)); | 5979 xassert (STRINGP (specified_file)); |
5980 file = Qnil; | 5980 file = Qnil; |
5981 GCPRO1 (file); | 5981 GCPRO1 (file); |
5982 | 5982 |
5983 file = x_find_image_file (specified_file); | 5983 file = x_find_image_file (specified_file); |
5985 { | 5985 { |
5986 image_error ("Cannot find image file `%s'", specified_file, Qnil); | 5986 image_error ("Cannot find image file `%s'", specified_file, Qnil); |
5987 UNGCPRO; | 5987 UNGCPRO; |
5988 return 0; | 5988 return 0; |
5989 } | 5989 } |
5990 | 5990 |
5991 rc = xbm_read_bitmap_file_data (SDATA (file), &img->width, | 5991 rc = xbm_read_bitmap_file_data (SDATA (file), &img->width, |
5992 &img->height, &data); | 5992 &img->height, &data); |
5993 if (rc) | 5993 if (rc) |
5994 { | 5994 { |
5995 int depth = one_mac_display_info.n_cbits; | 5995 int depth = one_mac_display_info.n_cbits; |
5996 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); | 5996 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); |
5997 unsigned long background = FRAME_BACKGROUND_PIXEL (f); | 5997 unsigned long background = FRAME_BACKGROUND_PIXEL (f); |
5998 Lisp_Object value; | 5998 Lisp_Object value; |
5999 | 5999 |
6000 xassert (img->width > 0 && img->height > 0); | 6000 xassert (img->width > 0 && img->height > 0); |
6001 | 6001 |
6002 /* Get foreground and background colors, maybe allocate colors. */ | 6002 /* Get foreground and background colors, maybe allocate colors. */ |
6003 value = image_spec_value (img->spec, QCforeground, NULL); | 6003 value = image_spec_value (img->spec, QCforeground, NULL); |
6004 if (!NILP (value)) | 6004 if (!NILP (value)) |
6005 foreground = x_alloc_image_color (f, img, value, foreground); | 6005 foreground = x_alloc_image_color (f, img, value, foreground); |
6006 | 6006 |
6007 value = image_spec_value (img->spec, QCbackground, NULL); | 6007 value = image_spec_value (img->spec, QCbackground, NULL); |
6008 if (!NILP (value)) | 6008 if (!NILP (value)) |
6009 background = x_alloc_image_color (f, img, value, background); | 6009 background = x_alloc_image_color (f, img, value, background); |
6010 | 6010 |
6011 #if 0 /* MAC_TODO : Port image display to Mac */ | 6011 #if 0 /* MAC_TODO : Port image display to Mac */ |
6024 x_clear_image (f, img); | 6024 x_clear_image (f, img); |
6025 image_error ("Unable to create X pixmap for `%s'", file, Qnil); | 6025 image_error ("Unable to create X pixmap for `%s'", file, Qnil); |
6026 } | 6026 } |
6027 else | 6027 else |
6028 success_p = 1; | 6028 success_p = 1; |
6029 | 6029 |
6030 UNBLOCK_INPUT; | 6030 UNBLOCK_INPUT; |
6031 #endif /* MAC_TODO */ | 6031 #endif /* MAC_TODO */ |
6032 } | 6032 } |
6033 else | 6033 else |
6034 image_error ("Error loading XBM image `%s'", img->spec, Qnil); | 6034 image_error ("Error loading XBM image `%s'", img->spec, Qnil); |
6074 img->width = XFASTINT (fmt[XBM_WIDTH].value); | 6074 img->width = XFASTINT (fmt[XBM_WIDTH].value); |
6075 img->height = XFASTINT (fmt[XBM_HEIGHT].value); | 6075 img->height = XFASTINT (fmt[XBM_HEIGHT].value); |
6076 xassert (img->width > 0 && img->height > 0); | 6076 xassert (img->width > 0 && img->height > 0); |
6077 | 6077 |
6078 BLOCK_INPUT; | 6078 BLOCK_INPUT; |
6079 | 6079 |
6080 if (fmt[XBM_ASCENT].count) | 6080 if (fmt[XBM_ASCENT].count) |
6081 img->ascent = XFASTINT (fmt[XBM_ASCENT].value); | 6081 img->ascent = XFASTINT (fmt[XBM_ASCENT].value); |
6082 | 6082 |
6083 /* Get foreground and background colors, maybe allocate colors. */ | 6083 /* Get foreground and background colors, maybe allocate colors. */ |
6084 if (fmt[XBM_FOREGROUND].count) | 6084 if (fmt[XBM_FOREGROUND].count) |
6093 if (VECTORP (data)) | 6093 if (VECTORP (data)) |
6094 { | 6094 { |
6095 int i; | 6095 int i; |
6096 char *p; | 6096 char *p; |
6097 int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR; | 6097 int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR; |
6098 | 6098 |
6099 p = bits = (char *) alloca (nbytes * img->height); | 6099 p = bits = (char *) alloca (nbytes * img->height); |
6100 for (i = 0; i < img->height; ++i, p += nbytes) | 6100 for (i = 0; i < img->height; ++i, p += nbytes) |
6101 { | 6101 { |
6102 Lisp_Object line = XVECTOR (data)->contents[i]; | 6102 Lisp_Object line = XVECTOR (data)->contents[i]; |
6103 if (STRINGP (line)) | 6103 if (STRINGP (line)) |
6135 UNBLOCK_INPUT; | 6135 UNBLOCK_INPUT; |
6136 } | 6136 } |
6137 | 6137 |
6138 return success_p; | 6138 return success_p; |
6139 } | 6139 } |
6140 | 6140 |
6141 | 6141 |
6142 | 6142 |
6143 /*********************************************************************** | 6143 /*********************************************************************** |
6144 XPM images | 6144 XPM images |
6145 ***********************************************************************/ | 6145 ***********************************************************************/ |
6146 | 6146 |
6147 #if HAVE_XPM | 6147 #if HAVE_XPM |
6148 | 6148 |
6149 static int xpm_image_p P_ ((Lisp_Object object)); | 6149 static int xpm_image_p P_ ((Lisp_Object object)); |
6150 static int xpm_load P_ ((struct frame *f, struct image *img)); | 6150 static int xpm_load P_ ((struct frame *f, struct image *img)); |
6151 static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); | 6151 static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); |
6152 | 6152 |
6276 if (CONSP (color_symbols)) | 6276 if (CONSP (color_symbols)) |
6277 { | 6277 { |
6278 Lisp_Object tail; | 6278 Lisp_Object tail; |
6279 XpmColorSymbol *xpm_syms; | 6279 XpmColorSymbol *xpm_syms; |
6280 int i, size; | 6280 int i, size; |
6281 | 6281 |
6282 attrs.valuemask |= XpmColorSymbols; | 6282 attrs.valuemask |= XpmColorSymbols; |
6283 | 6283 |
6284 /* Count number of symbols. */ | 6284 /* Count number of symbols. */ |
6285 attrs.numsymbols = 0; | 6285 attrs.numsymbols = 0; |
6286 for (tail = color_symbols; CONSP (tail); tail = XCDR (tail)) | 6286 for (tail = color_symbols; CONSP (tail); tail = XCDR (tail)) |
6317 { | 6317 { |
6318 image_error ("Cannot find image file `%s'", specified_file, Qnil); | 6318 image_error ("Cannot find image file `%s'", specified_file, Qnil); |
6319 UNBLOCK_INPUT; | 6319 UNBLOCK_INPUT; |
6320 return 0; | 6320 return 0; |
6321 } | 6321 } |
6322 | 6322 |
6323 rc = XpmReadFileToPixmap (NULL, FRAME_W32_WINDOW (f), | 6323 rc = XpmReadFileToPixmap (NULL, FRAME_W32_WINDOW (f), |
6324 SDATA (file), &img->pixmap, &img->mask, | 6324 SDATA (file), &img->pixmap, &img->mask, |
6325 &attrs); | 6325 &attrs); |
6326 } | 6326 } |
6327 else | 6327 else |
6357 switch (rc) | 6357 switch (rc) |
6358 { | 6358 { |
6359 case XpmOpenFailed: | 6359 case XpmOpenFailed: |
6360 image_error ("Error opening XPM file (%s)", img->spec, Qnil); | 6360 image_error ("Error opening XPM file (%s)", img->spec, Qnil); |
6361 break; | 6361 break; |
6362 | 6362 |
6363 case XpmFileInvalid: | 6363 case XpmFileInvalid: |
6364 image_error ("Invalid XPM file (%s)", img->spec, Qnil); | 6364 image_error ("Invalid XPM file (%s)", img->spec, Qnil); |
6365 break; | 6365 break; |
6366 | 6366 |
6367 case XpmNoMemory: | 6367 case XpmNoMemory: |
6368 image_error ("Out of memory (%s)", img->spec, Qnil); | 6368 image_error ("Out of memory (%s)", img->spec, Qnil); |
6369 break; | 6369 break; |
6370 | 6370 |
6371 case XpmColorFailed: | 6371 case XpmColorFailed: |
6372 image_error ("Color allocation error (%s)", img->spec, Qnil); | 6372 image_error ("Color allocation error (%s)", img->spec, Qnil); |
6373 break; | 6373 break; |
6374 | 6374 |
6375 default: | 6375 default: |
6376 image_error ("Unknown error (%s)", img->spec, Qnil); | 6376 image_error ("Unknown error (%s)", img->spec, Qnil); |
6377 break; | 6377 break; |
6378 } | 6378 } |
6379 } | 6379 } |
6518 XColor color; | 6518 XColor color; |
6519 Colormap cmap; | 6519 Colormap cmap; |
6520 int rc; | 6520 int rc; |
6521 | 6521 |
6522 BLOCK_INPUT; | 6522 BLOCK_INPUT; |
6523 | 6523 |
6524 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); | 6524 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); |
6525 color.pixel = pixel; | 6525 color.pixel = pixel; |
6526 XQueryColor (NULL, cmap, &color); | 6526 XQueryColor (NULL, cmap, &color); |
6527 rc = x_alloc_nearest_color (f, cmap, &color); | 6527 rc = x_alloc_nearest_color (f, cmap, &color); |
6528 UNBLOCK_INPUT; | 6528 UNBLOCK_INPUT; |
6529 | 6529 |
6530 if (rc) | 6530 if (rc) |
6531 { | 6531 { |
6532 ++ct_colors_allocated; | 6532 ++ct_colors_allocated; |
6533 | 6533 |
6534 p = (struct ct_color *) xmalloc (sizeof *p); | 6534 p = (struct ct_color *) xmalloc (sizeof *p); |
6535 p->r = color.red; | 6535 p->r = color.red; |
6536 p->g = color.green; | 6536 p->g = color.green; |
6537 p->b = color.blue; | 6537 p->b = color.blue; |
6538 p->pixel = pixel; | 6538 p->pixel = pixel; |
6565 else | 6565 else |
6566 { | 6566 { |
6567 colors = (unsigned long *) xmalloc (ct_colors_allocated | 6567 colors = (unsigned long *) xmalloc (ct_colors_allocated |
6568 * sizeof *colors); | 6568 * sizeof *colors); |
6569 *n = ct_colors_allocated; | 6569 *n = ct_colors_allocated; |
6570 | 6570 |
6571 for (i = j = 0; i < CT_SIZE; ++i) | 6571 for (i = j = 0; i < CT_SIZE; ++i) |
6572 for (p = ct_table[i]; p; p = p->next) | 6572 for (p = ct_table[i]; p; p = p->next) |
6573 colors[j++] = p->pixel; | 6573 colors[j++] = p->pixel; |
6574 } | 6574 } |
6575 | 6575 |
6623 int width; | 6623 int width; |
6624 XImage *ximg; | 6624 XImage *ximg; |
6625 int y; | 6625 int y; |
6626 { | 6626 { |
6627 int x; | 6627 int x; |
6628 | 6628 |
6629 for (x = 0; x < width; ++x) | 6629 for (x = 0; x < width; ++x) |
6630 XPutPixel (ximg, x, y, pixels[x]); | 6630 XPutPixel (ximg, x, y, pixels[x]); |
6631 } | 6631 } |
6632 #endif /* MAC_TODO */ | 6632 #endif /* MAC_TODO */ |
6633 | 6633 |
6689 for (x = 0; x < img->width - 2; ++x) | 6689 for (x = 0; x < img->width - 2; ++x) |
6690 { | 6690 { |
6691 int r = in[rowa][x].red + mv2 - in[rowb][x + 2].red; | 6691 int r = in[rowa][x].red + mv2 - in[rowb][x + 2].red; |
6692 int g = in[rowa][x].green + mv2 - in[rowb][x + 2].green; | 6692 int g = in[rowa][x].green + mv2 - in[rowb][x + 2].green; |
6693 int b = in[rowa][x].blue + mv2 - in[rowb][x + 2].blue; | 6693 int b = in[rowa][x].blue + mv2 - in[rowb][x + 2].blue; |
6694 | 6694 |
6695 out[x + 1] = lookup_rgb_color (f, r & 0xffff, g & 0xffff, | 6695 out[x + 1] = lookup_rgb_color (f, r & 0xffff, g & 0xffff, |
6696 b & 0xffff); | 6696 b & 0xffff); |
6697 } | 6697 } |
6698 | 6698 |
6699 x_laplace_write_row (f, out, img->width, oimg, out_y++); | 6699 x_laplace_write_row (f, out, img->width, oimg, out_y++); |
6705 x_laplace_write_row (f, out, img->width, oimg, out_y); | 6705 x_laplace_write_row (f, out, img->width, oimg, out_y); |
6706 | 6706 |
6707 /* Free the input image, and free resources of IMG. */ | 6707 /* Free the input image, and free resources of IMG. */ |
6708 XDestroyImage (ximg); | 6708 XDestroyImage (ximg); |
6709 x_clear_image (f, img); | 6709 x_clear_image (f, img); |
6710 | 6710 |
6711 /* Put the output image into pixmap, and destroy it. */ | 6711 /* Put the output image into pixmap, and destroy it. */ |
6712 x_put_x_image (f, oimg, pixmap, img->width, img->height); | 6712 x_put_x_image (f, oimg, pixmap, img->width, img->height); |
6713 x_destroy_x_image (oimg); | 6713 x_destroy_x_image (oimg); |
6714 | 6714 |
6715 /* Remember new pixmap and colors in IMG. */ | 6715 /* Remember new pixmap and colors in IMG. */ |
6740 XImage *ximg, *mask_img; | 6740 XImage *ximg, *mask_img; |
6741 int x, y, rc, look_at_corners_p; | 6741 int x, y, rc, look_at_corners_p; |
6742 unsigned long bg; | 6742 unsigned long bg; |
6743 | 6743 |
6744 BLOCK_INPUT; | 6744 BLOCK_INPUT; |
6745 | 6745 |
6746 /* Create an image and pixmap serving as mask. */ | 6746 /* Create an image and pixmap serving as mask. */ |
6747 rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1, | 6747 rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1, |
6748 &mask_img, &img->mask); | 6748 &mask_img, &img->mask); |
6749 if (!rc) | 6749 if (!rc) |
6750 { | 6750 { |
6758 | 6758 |
6759 /* Determine the background color of ximg. If HOW is `(R G B)' | 6759 /* Determine the background color of ximg. If HOW is `(R G B)' |
6760 take that as color. Otherwise, try to determine the color | 6760 take that as color. Otherwise, try to determine the color |
6761 heuristically. */ | 6761 heuristically. */ |
6762 look_at_corners_p = 1; | 6762 look_at_corners_p = 1; |
6763 | 6763 |
6764 if (CONSP (how)) | 6764 if (CONSP (how)) |
6765 { | 6765 { |
6766 int rgb[3], i = 0; | 6766 int rgb[3], i = 0; |
6767 | 6767 |
6768 while (i < 3 | 6768 while (i < 3 |
6778 char color_name[30]; | 6778 char color_name[30]; |
6779 XColor exact, color; | 6779 XColor exact, color; |
6780 Colormap cmap; | 6780 Colormap cmap; |
6781 | 6781 |
6782 sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]); | 6782 sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]); |
6783 | 6783 |
6784 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); | 6784 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); |
6785 if (XLookupColor (dpy, cmap, color_name, &exact, &color)) | 6785 if (XLookupColor (dpy, cmap, color_name, &exact, &color)) |
6786 { | 6786 { |
6787 bg = color.pixel; | 6787 bg = color.pixel; |
6788 look_at_corners_p = 0; | 6788 look_at_corners_p = 0; |
6789 } | 6789 } |
6790 } | 6790 } |
6791 } | 6791 } |
6792 | 6792 |
6793 if (look_at_corners_p) | 6793 if (look_at_corners_p) |
6794 { | 6794 { |
6795 unsigned long corners[4]; | 6795 unsigned long corners[4]; |
6796 int i, best_count; | 6796 int i, best_count; |
6797 | 6797 |
6803 | 6803 |
6804 /* Choose the most frequently found color as background. */ | 6804 /* Choose the most frequently found color as background. */ |
6805 for (i = best_count = 0; i < 4; ++i) | 6805 for (i = best_count = 0; i < 4; ++i) |
6806 { | 6806 { |
6807 int j, n; | 6807 int j, n; |
6808 | 6808 |
6809 for (j = n = 0; j < 4; ++j) | 6809 for (j = n = 0; j < 4; ++j) |
6810 if (corners[i] == corners[j]) | 6810 if (corners[i] == corners[j]) |
6811 ++n; | 6811 ++n; |
6812 | 6812 |
6813 if (n > best_count) | 6813 if (n > best_count) |
6823 | 6823 |
6824 /* Put mask_img into img->mask. */ | 6824 /* Put mask_img into img->mask. */ |
6825 x_put_x_image (f, mask_img, img->mask, img->width, img->height); | 6825 x_put_x_image (f, mask_img, img->mask, img->width, img->height); |
6826 x_destroy_x_image (mask_img); | 6826 x_destroy_x_image (mask_img); |
6827 XDestroyImage (ximg); | 6827 XDestroyImage (ximg); |
6828 | 6828 |
6829 UNBLOCK_INPUT; | 6829 UNBLOCK_INPUT; |
6830 #endif /* MAC_TODO */ | 6830 #endif /* MAC_TODO */ |
6831 | 6831 |
6832 return 1; | 6832 return 1; |
6833 } | 6833 } |
6894 static int | 6894 static int |
6895 pbm_image_p (object) | 6895 pbm_image_p (object) |
6896 Lisp_Object object; | 6896 Lisp_Object object; |
6897 { | 6897 { |
6898 struct image_keyword fmt[PBM_LAST]; | 6898 struct image_keyword fmt[PBM_LAST]; |
6899 | 6899 |
6900 bcopy (pbm_format, fmt, sizeof fmt); | 6900 bcopy (pbm_format, fmt, sizeof fmt); |
6901 | 6901 |
6902 if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm) | 6902 if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm) |
6903 || (fmt[PBM_ASCENT].count | 6903 || (fmt[PBM_ASCENT].count |
6904 && XFASTINT (fmt[PBM_ASCENT].value) > 100)) | 6904 && XFASTINT (fmt[PBM_ASCENT].value) > 100)) |
6905 return 0; | 6905 return 0; |
6906 | 6906 |
6907 /* Must specify either :data or :file. */ | 6907 /* Must specify either :data or :file. */ |
6908 return fmt[PBM_DATA].count + fmt[PBM_FILE].count == 1; | 6908 return fmt[PBM_DATA].count + fmt[PBM_FILE].count == 1; |
6976 { | 6976 { |
6977 xfree (buf); | 6977 xfree (buf); |
6978 buf = NULL; | 6978 buf = NULL; |
6979 } | 6979 } |
6980 } | 6980 } |
6981 | 6981 |
6982 return buf; | 6982 return buf; |
6983 } | 6983 } |
6984 | 6984 |
6985 | 6985 |
6986 /* Load PBM image IMG for use on frame F. */ | 6986 /* Load PBM image IMG for use on frame F. */ |
6987 | 6987 |
6988 static int | 6988 static int |
6989 pbm_load (f, img) | 6989 pbm_load (f, img) |
6990 struct frame *f; | 6990 struct frame *f; |
6991 struct image *img; | 6991 struct image *img; |
6992 { | 6992 { |
6993 int raw_p, x, y; | 6993 int raw_p, x, y; |
7046 switch (*p++) | 7046 switch (*p++) |
7047 { | 7047 { |
7048 case '1': | 7048 case '1': |
7049 raw_p = 0, type = PBM_MONO; | 7049 raw_p = 0, type = PBM_MONO; |
7050 break; | 7050 break; |
7051 | 7051 |
7052 case '2': | 7052 case '2': |
7053 raw_p = 0, type = PBM_GRAY; | 7053 raw_p = 0, type = PBM_GRAY; |
7054 break; | 7054 break; |
7055 | 7055 |
7056 case '3': | 7056 case '3': |
7058 break; | 7058 break; |
7059 | 7059 |
7060 case '4': | 7060 case '4': |
7061 raw_p = 1, type = PBM_MONO; | 7061 raw_p = 1, type = PBM_MONO; |
7062 break; | 7062 break; |
7063 | 7063 |
7064 case '5': | 7064 case '5': |
7065 raw_p = 1, type = PBM_GRAY; | 7065 raw_p = 1, type = PBM_GRAY; |
7066 break; | 7066 break; |
7067 | 7067 |
7068 case '6': | 7068 case '6': |
7069 raw_p = 1, type = PBM_COLOR; | 7069 raw_p = 1, type = PBM_COLOR; |
7070 break; | 7070 break; |
7071 | 7071 |
7072 default: | 7072 default: |
7083 { | 7083 { |
7084 max_color_idx = pbm_scan_number (&p, end); | 7084 max_color_idx = pbm_scan_number (&p, end); |
7085 if (raw_p && max_color_idx > 255) | 7085 if (raw_p && max_color_idx > 255) |
7086 max_color_idx = 255; | 7086 max_color_idx = 255; |
7087 } | 7087 } |
7088 | 7088 |
7089 if (width < 0 | 7089 if (width < 0 |
7090 || height < 0 | 7090 || height < 0 |
7091 || (type != PBM_MONO && max_color_idx < 0)) | 7091 || (type != PBM_MONO && max_color_idx < 0)) |
7092 goto error; | 7092 goto error; |
7093 | 7093 |
7096 &ximg, &img->pixmap)) | 7096 &ximg, &img->pixmap)) |
7097 { | 7097 { |
7098 UNBLOCK_INPUT; | 7098 UNBLOCK_INPUT; |
7099 goto error; | 7099 goto error; |
7100 } | 7100 } |
7101 | 7101 |
7102 /* Initialize the color hash table. */ | 7102 /* Initialize the color hash table. */ |
7103 init_color_table (); | 7103 init_color_table (); |
7104 | 7104 |
7105 if (type == PBM_MONO) | 7105 if (type == PBM_MONO) |
7106 { | 7106 { |
7107 int c = 0, g; | 7107 int c = 0, g; |
7108 | 7108 |
7109 for (y = 0; y < height; ++y) | 7109 for (y = 0; y < height; ++y) |
7110 for (x = 0; x < width; ++x) | 7110 for (x = 0; x < width; ++x) |
7111 { | 7111 { |
7112 if (raw_p) | 7112 if (raw_p) |
7113 { | 7113 { |
7128 { | 7128 { |
7129 for (y = 0; y < height; ++y) | 7129 for (y = 0; y < height; ++y) |
7130 for (x = 0; x < width; ++x) | 7130 for (x = 0; x < width; ++x) |
7131 { | 7131 { |
7132 int r, g, b; | 7132 int r, g, b; |
7133 | 7133 |
7134 if (type == PBM_GRAY) | 7134 if (type == PBM_GRAY) |
7135 r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end); | 7135 r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end); |
7136 else if (raw_p) | 7136 else if (raw_p) |
7137 { | 7137 { |
7138 r = *p++; | 7138 r = *p++; |
7143 { | 7143 { |
7144 r = pbm_scan_number (&p, end); | 7144 r = pbm_scan_number (&p, end); |
7145 g = pbm_scan_number (&p, end); | 7145 g = pbm_scan_number (&p, end); |
7146 b = pbm_scan_number (&p, end); | 7146 b = pbm_scan_number (&p, end); |
7147 } | 7147 } |
7148 | 7148 |
7149 if (r < 0 || g < 0 || b < 0) | 7149 if (r < 0 || g < 0 || b < 0) |
7150 { | 7150 { |
7151 xfree (ximg->data); | 7151 xfree (ximg->data); |
7152 ximg->data = NULL; | 7152 ximg->data = NULL; |
7153 XDestroyImage (ximg); | 7153 XDestroyImage (ximg); |
7154 UNBLOCK_INPUT; | 7154 UNBLOCK_INPUT; |
7155 image_error ("Invalid pixel value in image `%s'", | 7155 image_error ("Invalid pixel value in image `%s'", |
7156 img->spec, Qnil); | 7156 img->spec, Qnil); |
7157 goto error; | 7157 goto error; |
7158 } | 7158 } |
7159 | 7159 |
7160 /* RGB values are now in the range 0..max_color_idx. | 7160 /* RGB values are now in the range 0..max_color_idx. |
7161 Scale this to the range 0..0xffff supported by X. */ | 7161 Scale this to the range 0..0xffff supported by X. */ |
7162 r = (double) r * 65535 / max_color_idx; | 7162 r = (double) r * 65535 / max_color_idx; |
7163 g = (double) g * 65535 / max_color_idx; | 7163 g = (double) g * 65535 / max_color_idx; |
7164 b = (double) b * 65535 / max_color_idx; | 7164 b = (double) b * 65535 / max_color_idx; |
7165 XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b)); | 7165 XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b)); |
7166 } | 7166 } |
7167 } | 7167 } |
7168 | 7168 |
7169 /* Store in IMG->colors the colors allocated for the image, and | 7169 /* Store in IMG->colors the colors allocated for the image, and |
7170 free the color table. */ | 7170 free the color table. */ |
7171 img->colors = colors_in_color_table (&img->ncolors); | 7171 img->colors = colors_in_color_table (&img->ncolors); |
7172 free_color_table (); | 7172 free_color_table (); |
7173 | 7173 |
7174 /* Put the image into a pixmap. */ | 7174 /* Put the image into a pixmap. */ |
7175 x_put_x_image (f, ximg, img->pixmap, width, height); | 7175 x_put_x_image (f, ximg, img->pixmap, width, height); |
7176 x_destroy_x_image (ximg); | 7176 x_destroy_x_image (ximg); |
7177 UNBLOCK_INPUT; | 7177 UNBLOCK_INPUT; |
7178 | 7178 |
7179 img->width = width; | 7179 img->width = width; |
7180 img->height = height; | 7180 img->height = height; |
7181 | 7181 |
7182 UNGCPRO; | 7182 UNGCPRO; |
7183 xfree (contents); | 7183 xfree (contents); |
7251 png_image_p (object) | 7251 png_image_p (object) |
7252 Lisp_Object object; | 7252 Lisp_Object object; |
7253 { | 7253 { |
7254 struct image_keyword fmt[PNG_LAST]; | 7254 struct image_keyword fmt[PNG_LAST]; |
7255 bcopy (png_format, fmt, sizeof fmt); | 7255 bcopy (png_format, fmt, sizeof fmt); |
7256 | 7256 |
7257 if (!parse_image_spec (object, fmt, PNG_LAST, Qpng) | 7257 if (!parse_image_spec (object, fmt, PNG_LAST, Qpng) |
7258 || (fmt[PNG_ASCENT].count | 7258 || (fmt[PNG_ASCENT].count |
7259 && XFASTINT (fmt[PNG_ASCENT].value) > 100)) | 7259 && XFASTINT (fmt[PNG_ASCENT].value) > 100)) |
7260 return 0; | 7260 return 0; |
7261 | 7261 |
7262 /* Must specify either the :data or :file keyword. */ | 7262 /* Must specify either the :data or :file keyword. */ |
7263 return fmt[PNG_FILE].count + fmt[PNG_DATA].count == 1; | 7263 return fmt[PNG_FILE].count + fmt[PNG_DATA].count == 1; |
7310 struct png_memory_storage *tbr | 7310 struct png_memory_storage *tbr |
7311 = (struct png_memory_storage *) png_get_io_ptr (png_ptr); | 7311 = (struct png_memory_storage *) png_get_io_ptr (png_ptr); |
7312 | 7312 |
7313 if (length > tbr->len - tbr->index) | 7313 if (length > tbr->len - tbr->index) |
7314 png_error (png_ptr, "Read error"); | 7314 png_error (png_ptr, "Read error"); |
7315 | 7315 |
7316 bcopy (tbr->bytes + tbr->index, data, length); | 7316 bcopy (tbr->bytes + tbr->index, data, length); |
7317 tbr->index = tbr->index + length; | 7317 tbr->index = tbr->index + length; |
7318 } | 7318 } |
7319 | 7319 |
7320 /* Load PNG image IMG for use on frame F. Value is non-zero if | 7320 /* Load PNG image IMG for use on frame F. Value is non-zero if |
7453 png_set_sig_bytes (png_ptr, sizeof sig); | 7453 png_set_sig_bytes (png_ptr, sizeof sig); |
7454 png_read_info (png_ptr, info_ptr); | 7454 png_read_info (png_ptr, info_ptr); |
7455 png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, | 7455 png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, |
7456 &interlace_type, NULL, NULL); | 7456 &interlace_type, NULL, NULL); |
7457 | 7457 |
7458 /* If image contains simply transparency data, we prefer to | 7458 /* If image contains simply transparency data, we prefer to |
7459 construct a clipping mask. */ | 7459 construct a clipping mask. */ |
7460 if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) | 7460 if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) |
7461 transparent_p = 1; | 7461 transparent_p = 1; |
7462 else | 7462 else |
7463 transparent_p = 0; | 7463 transparent_p = 0; |
7464 | 7464 |
7465 /* This function is easier to write if we only have to handle | 7465 /* This function is easier to write if we only have to handle |
7466 one data format: RGB or RGBA with 8 bits per channel. Let's | 7466 one data format: RGB or RGBA with 8 bits per channel. Let's |
7467 transform other formats into that format. */ | 7467 transform other formats into that format. */ |
7468 | 7468 |
7469 /* Strip more than 8 bits per channel. */ | 7469 /* Strip more than 8 bits per channel. */ |
7470 if (bit_depth == 16) | 7470 if (bit_depth == 16) |
7473 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel | 7473 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel |
7474 if available. */ | 7474 if available. */ |
7475 png_set_expand (png_ptr); | 7475 png_set_expand (png_ptr); |
7476 | 7476 |
7477 /* Convert grayscale images to RGB. */ | 7477 /* Convert grayscale images to RGB. */ |
7478 if (color_type == PNG_COLOR_TYPE_GRAY | 7478 if (color_type == PNG_COLOR_TYPE_GRAY |
7479 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) | 7479 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) |
7480 png_set_gray_to_rgb (png_ptr); | 7480 png_set_gray_to_rgb (png_ptr); |
7481 | 7481 |
7482 /* The value 2.2 is a guess for PC monitors from PNG example.c. */ | 7482 /* The value 2.2 is a guess for PC monitors from PNG example.c. */ |
7483 gamma_str = getenv ("SCREEN_GAMMA"); | 7483 gamma_str = getenv ("SCREEN_GAMMA"); |
7504 if (!transparent_p) | 7504 if (!transparent_p) |
7505 { | 7505 { |
7506 png_color_16 *image_background; | 7506 png_color_16 *image_background; |
7507 | 7507 |
7508 if (png_get_bKGD (png_ptr, info_ptr, &image_background)) | 7508 if (png_get_bKGD (png_ptr, info_ptr, &image_background)) |
7509 /* Image contains a background color with which to | 7509 /* Image contains a background color with which to |
7510 combine the image. */ | 7510 combine the image. */ |
7511 png_set_background (png_ptr, image_background, | 7511 png_set_background (png_ptr, image_background, |
7512 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); | 7512 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); |
7513 else | 7513 else |
7514 { | 7514 { |
7515 /* Image does not contain a background color with which | 7515 /* Image does not contain a background color with which |
7516 to combine the image data via an alpha channel. Use | 7516 to combine the image data via an alpha channel. Use |
7517 the frame's background instead. */ | 7517 the frame's background instead. */ |
7518 XColor color; | 7518 XColor color; |
7519 Colormap cmap; | 7519 Colormap cmap; |
7520 png_color_16 frame_background; | 7520 png_color_16 frame_background; |
7521 | 7521 |
7571 &img->pixmap)) | 7571 &img->pixmap)) |
7572 { | 7572 { |
7573 UNBLOCK_INPUT; | 7573 UNBLOCK_INPUT; |
7574 goto error; | 7574 goto error; |
7575 } | 7575 } |
7576 | 7576 |
7577 /* Create an image and pixmap serving as mask if the PNG image | 7577 /* Create an image and pixmap serving as mask if the PNG image |
7578 contains an alpha channel. */ | 7578 contains an alpha channel. */ |
7579 if (channels == 4 | 7579 if (channels == 4 |
7580 && !transparent_p | 7580 && !transparent_p |
7581 && !x_create_x_image_and_pixmap (f, width, height, 1, | 7581 && !x_create_x_image_and_pixmap (f, width, height, 1, |
7603 g = *p++ << 8; | 7603 g = *p++ << 8; |
7604 b = *p++ << 8; | 7604 b = *p++ << 8; |
7605 XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b)); | 7605 XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b)); |
7606 | 7606 |
7607 /* An alpha channel, aka mask channel, associates variable | 7607 /* An alpha channel, aka mask channel, associates variable |
7608 transparency with an image. Where other image formats | 7608 transparency with an image. Where other image formats |
7609 support binary transparency---fully transparent or fully | 7609 support binary transparency---fully transparent or fully |
7610 opaque---PNG allows up to 254 levels of partial transparency. | 7610 opaque---PNG allows up to 254 levels of partial transparency. |
7611 The PNG library implements partial transparency by combining | 7611 The PNG library implements partial transparency by combining |
7612 the image with a specified background color. | 7612 the image with a specified background color. |
7613 | 7613 |
7614 I'm not sure how to handle this here nicely: because the | 7614 I'm not sure how to handle this here nicely: because the |
7615 background on which the image is displayed may change, for | 7615 background on which the image is displayed may change, for |
7616 real alpha channel support, it would be necessary to create | 7616 real alpha channel support, it would be necessary to create |
7617 a new image for each possible background. | 7617 a new image for each possible background. |
7618 | 7618 |
7619 What I'm doing now is that a mask is created if we have | 7619 What I'm doing now is that a mask is created if we have |
7620 boolean transparency information. Otherwise I'm using | 7620 boolean transparency information. Otherwise I'm using |
7621 the frame's background color to combine the image with. */ | 7621 the frame's background color to combine the image with. */ |
7622 | 7622 |
7736 static int | 7736 static int |
7737 jpeg_image_p (object) | 7737 jpeg_image_p (object) |
7738 Lisp_Object object; | 7738 Lisp_Object object; |
7739 { | 7739 { |
7740 struct image_keyword fmt[JPEG_LAST]; | 7740 struct image_keyword fmt[JPEG_LAST]; |
7741 | 7741 |
7742 bcopy (jpeg_format, fmt, sizeof fmt); | 7742 bcopy (jpeg_format, fmt, sizeof fmt); |
7743 | 7743 |
7744 if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg) | 7744 if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg) |
7745 || (fmt[JPEG_ASCENT].count | 7745 || (fmt[JPEG_ASCENT].count |
7746 && XFASTINT (fmt[JPEG_ASCENT].value) > 100)) | 7746 && XFASTINT (fmt[JPEG_ASCENT].value) > 100)) |
7747 return 0; | 7747 return 0; |
7748 | 7748 |
7749 /* Must specify either the :data or :file keyword. */ | 7749 /* Must specify either the :data or :file keyword. */ |
7750 return fmt[JPEG_FILE].count + fmt[JPEG_DATA].count == 1; | 7750 return fmt[JPEG_FILE].count + fmt[JPEG_DATA].count == 1; |
7809 | 7809 |
7810 if (src) | 7810 if (src) |
7811 { | 7811 { |
7812 if (num_bytes > src->bytes_in_buffer) | 7812 if (num_bytes > src->bytes_in_buffer) |
7813 ERREXIT (cinfo, JERR_INPUT_EOF); | 7813 ERREXIT (cinfo, JERR_INPUT_EOF); |
7814 | 7814 |
7815 src->bytes_in_buffer -= num_bytes; | 7815 src->bytes_in_buffer -= num_bytes; |
7816 src->next_input_byte += num_bytes; | 7816 src->next_input_byte += num_bytes; |
7817 } | 7817 } |
7818 } | 7818 } |
7819 | 7819 |
7847 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, | 7847 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, |
7848 sizeof (struct jpeg_source_mgr)); | 7848 sizeof (struct jpeg_source_mgr)); |
7849 src = (struct jpeg_source_mgr *) cinfo->src; | 7849 src = (struct jpeg_source_mgr *) cinfo->src; |
7850 src->next_input_byte = data; | 7850 src->next_input_byte = data; |
7851 } | 7851 } |
7852 | 7852 |
7853 src = (struct jpeg_source_mgr *) cinfo->src; | 7853 src = (struct jpeg_source_mgr *) cinfo->src; |
7854 src->init_source = our_init_source; | 7854 src->init_source = our_init_source; |
7855 src->fill_input_buffer = our_fill_input_buffer; | 7855 src->fill_input_buffer = our_fill_input_buffer; |
7856 src->skip_input_data = our_skip_input_data; | 7856 src->skip_input_data = our_skip_input_data; |
7857 src->resync_to_restart = jpeg_resync_to_restart; /* Use default method. */ | 7857 src->resync_to_restart = jpeg_resync_to_restart; /* Use default method. */ |
7862 | 7862 |
7863 | 7863 |
7864 /* Load image IMG for use on frame F. Patterned after example.c | 7864 /* Load image IMG for use on frame F. Patterned after example.c |
7865 from the JPEG lib. */ | 7865 from the JPEG lib. */ |
7866 | 7866 |
7867 static int | 7867 static int |
7868 jpeg_load (f, img) | 7868 jpeg_load (f, img) |
7869 struct frame *f; | 7869 struct frame *f; |
7870 struct image *img; | 7870 struct image *img; |
7871 { | 7871 { |
7872 struct jpeg_decompress_struct cinfo; | 7872 struct jpeg_decompress_struct cinfo; |
7895 { | 7895 { |
7896 image_error ("Cannot find image file `%s'", specified_file, Qnil); | 7896 image_error ("Cannot find image file `%s'", specified_file, Qnil); |
7897 UNGCPRO; | 7897 UNGCPRO; |
7898 return 0; | 7898 return 0; |
7899 } | 7899 } |
7900 | 7900 |
7901 fp = fopen (SDATA (file), "r"); | 7901 fp = fopen (SDATA (file), "r"); |
7902 if (fp == NULL) | 7902 if (fp == NULL) |
7903 { | 7903 { |
7904 image_error ("Cannot open `%s'", file, Qnil); | 7904 image_error ("Cannot open `%s'", file, Qnil); |
7905 UNGCPRO; | 7905 UNGCPRO; |
7906 return 0; | 7906 return 0; |
7907 } | 7907 } |
7908 } | 7908 } |
7909 | 7909 |
7910 /* Customize libjpeg's error handling to call my_error_exit when an | 7910 /* Customize libjpeg's error handling to call my_error_exit when an |
7911 error is detected. This function will perform a longjmp. */ | 7911 error is detected. This function will perform a longjmp. */ |
7912 mgr.pub.error_exit = my_error_exit; | 7912 mgr.pub.error_exit = my_error_exit; |
7913 cinfo.err = jpeg_std_error (&mgr.pub); | 7913 cinfo.err = jpeg_std_error (&mgr.pub); |
7914 | 7914 |
7915 if ((rc = setjmp (mgr.setjmp_buffer)) != 0) | 7915 if ((rc = setjmp (mgr.setjmp_buffer)) != 0) |
7916 { | 7916 { |
7917 if (rc == 1) | 7917 if (rc == 1) |
7918 { | 7918 { |
7919 /* Called from my_error_exit. Display a JPEG error. */ | 7919 /* Called from my_error_exit. Display a JPEG error. */ |
7920 char buffer[JMSG_LENGTH_MAX]; | 7920 char buffer[JMSG_LENGTH_MAX]; |
7921 cinfo.err->format_message ((j_common_ptr) &cinfo, buffer); | 7921 cinfo.err->format_message ((j_common_ptr) &cinfo, buffer); |
7922 image_error ("Error reading JPEG image `%s': %s", img->spec, | 7922 image_error ("Error reading JPEG image `%s': %s", img->spec, |
7923 build_string (buffer)); | 7923 build_string (buffer)); |
7924 } | 7924 } |
7925 | 7925 |
7926 /* Close the input file and destroy the JPEG object. */ | 7926 /* Close the input file and destroy the JPEG object. */ |
7927 if (fp) | 7927 if (fp) |
7928 fclose (fp); | 7928 fclose (fp); |
7929 jpeg_destroy_decompress (&cinfo); | 7929 jpeg_destroy_decompress (&cinfo); |
7930 | 7930 |
7931 BLOCK_INPUT; | 7931 BLOCK_INPUT; |
7932 | 7932 |
7933 /* If we already have an XImage, free that. */ | 7933 /* If we already have an XImage, free that. */ |
7934 x_destroy_x_image (ximg); | 7934 x_destroy_x_image (ximg); |
7935 | 7935 |
7936 /* Free pixmap and colors. */ | 7936 /* Free pixmap and colors. */ |
7937 x_clear_image (f, img); | 7937 x_clear_image (f, img); |
7938 | 7938 |
7939 UNBLOCK_INPUT; | 7939 UNBLOCK_INPUT; |
7940 UNGCPRO; | 7940 UNGCPRO; |
7941 return 0; | 7941 return 0; |
7942 } | 7942 } |
7943 | 7943 |
7990 a default color, and we don't have to care about which colors | 7990 a default color, and we don't have to care about which colors |
7991 can be freed safely, and which can't. */ | 7991 can be freed safely, and which can't. */ |
7992 init_color_table (); | 7992 init_color_table (); |
7993 colors = (unsigned long *) alloca (cinfo.actual_number_of_colors | 7993 colors = (unsigned long *) alloca (cinfo.actual_number_of_colors |
7994 * sizeof *colors); | 7994 * sizeof *colors); |
7995 | 7995 |
7996 for (i = 0; i < cinfo.actual_number_of_colors; ++i) | 7996 for (i = 0; i < cinfo.actual_number_of_colors; ++i) |
7997 { | 7997 { |
7998 /* Multiply RGB values with 255 because X expects RGB values | 7998 /* Multiply RGB values with 255 because X expects RGB values |
7999 in the range 0..0xffff. */ | 7999 in the range 0..0xffff. */ |
8000 int r = cinfo.colormap[ir][i] << 8; | 8000 int r = cinfo.colormap[ir][i] << 8; |
8022 /* Clean up. */ | 8022 /* Clean up. */ |
8023 jpeg_finish_decompress (&cinfo); | 8023 jpeg_finish_decompress (&cinfo); |
8024 jpeg_destroy_decompress (&cinfo); | 8024 jpeg_destroy_decompress (&cinfo); |
8025 if (fp) | 8025 if (fp) |
8026 fclose (fp); | 8026 fclose (fp); |
8027 | 8027 |
8028 /* Put the image into the pixmap. */ | 8028 /* Put the image into the pixmap. */ |
8029 x_put_x_image (f, ximg, img->pixmap, width, height); | 8029 x_put_x_image (f, ximg, img->pixmap, width, height); |
8030 x_destroy_x_image (ximg); | 8030 x_destroy_x_image (ximg); |
8031 UNBLOCK_INPUT; | 8031 UNBLOCK_INPUT; |
8032 UNGCPRO; | 8032 UNGCPRO; |
8100 tiff_image_p (object) | 8100 tiff_image_p (object) |
8101 Lisp_Object object; | 8101 Lisp_Object object; |
8102 { | 8102 { |
8103 struct image_keyword fmt[TIFF_LAST]; | 8103 struct image_keyword fmt[TIFF_LAST]; |
8104 bcopy (tiff_format, fmt, sizeof fmt); | 8104 bcopy (tiff_format, fmt, sizeof fmt); |
8105 | 8105 |
8106 if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff) | 8106 if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff) |
8107 || (fmt[TIFF_ASCENT].count | 8107 || (fmt[TIFF_ASCENT].count |
8108 && XFASTINT (fmt[TIFF_ASCENT].value) > 100)) | 8108 && XFASTINT (fmt[TIFF_ASCENT].value) > 100)) |
8109 return 0; | 8109 return 0; |
8110 | 8110 |
8111 /* Must specify either the :data or :file keyword. */ | 8111 /* Must specify either the :data or :file keyword. */ |
8112 return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1; | 8112 return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1; |
8113 } | 8113 } |
8114 | 8114 |
8115 | 8115 |
8166 switch (whence) | 8166 switch (whence) |
8167 { | 8167 { |
8168 case SEEK_SET: /* Go from beginning of source. */ | 8168 case SEEK_SET: /* Go from beginning of source. */ |
8169 idx = off; | 8169 idx = off; |
8170 break; | 8170 break; |
8171 | 8171 |
8172 case SEEK_END: /* Go from end of source. */ | 8172 case SEEK_END: /* Go from end of source. */ |
8173 idx = src->len + off; | 8173 idx = src->len + off; |
8174 break; | 8174 break; |
8175 | 8175 |
8176 case SEEK_CUR: /* Go from current position. */ | 8176 case SEEK_CUR: /* Go from current position. */ |
8177 idx = src->index + off; | 8177 idx = src->index + off; |
8178 break; | 8178 break; |
8179 | 8179 |
8180 default: /* Invalid `whence'. */ | 8180 default: /* Invalid `whence'. */ |
8181 return -1; | 8181 return -1; |
8182 } | 8182 } |
8183 | 8183 |
8184 if (idx > src->len || idx < 0) | 8184 if (idx > src->len || idx < 0) |
8185 return -1; | 8185 return -1; |
8186 | 8186 |
8187 src->index = idx; | 8187 src->index = idx; |
8188 return src->index; | 8188 return src->index; |
8189 } | 8189 } |
8190 | 8190 |
8191 static int | 8191 static int |
8253 { | 8253 { |
8254 image_error ("Cannot find image file `%s'", file, Qnil); | 8254 image_error ("Cannot find image file `%s'", file, Qnil); |
8255 UNGCPRO; | 8255 UNGCPRO; |
8256 return 0; | 8256 return 0; |
8257 } | 8257 } |
8258 | 8258 |
8259 /* Try to open the image file. */ | 8259 /* Try to open the image file. */ |
8260 tiff = TIFFOpen (SDATA (file), "r"); | 8260 tiff = TIFFOpen (SDATA (file), "r"); |
8261 if (tiff == NULL) | 8261 if (tiff == NULL) |
8262 { | 8262 { |
8263 image_error ("Cannot open `%s'", file, Qnil); | 8263 image_error ("Cannot open `%s'", file, Qnil); |
8292 /* Get width and height of the image, and allocate a raster buffer | 8292 /* Get width and height of the image, and allocate a raster buffer |
8293 of width x height 32-bit values. */ | 8293 of width x height 32-bit values. */ |
8294 TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); | 8294 TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); |
8295 TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height); | 8295 TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height); |
8296 buf = (uint32 *) xmalloc (width * height * sizeof *buf); | 8296 buf = (uint32 *) xmalloc (width * height * sizeof *buf); |
8297 | 8297 |
8298 rc = TIFFReadRGBAImage (tiff, width, height, buf, 0); | 8298 rc = TIFFReadRGBAImage (tiff, width, height, buf, 0); |
8299 TIFFClose (tiff); | 8299 TIFFClose (tiff); |
8300 if (!rc) | 8300 if (!rc) |
8301 { | 8301 { |
8302 image_error ("Error reading TIFF image `%s'", img->spec, Qnil); | 8302 image_error ("Error reading TIFF image `%s'", img->spec, Qnil); |
8321 | 8321 |
8322 /* Process the pixel raster. Origin is in the lower-left corner. */ | 8322 /* Process the pixel raster. Origin is in the lower-left corner. */ |
8323 for (y = 0; y < height; ++y) | 8323 for (y = 0; y < height; ++y) |
8324 { | 8324 { |
8325 uint32 *row = buf + y * width; | 8325 uint32 *row = buf + y * width; |
8326 | 8326 |
8327 for (x = 0; x < width; ++x) | 8327 for (x = 0; x < width; ++x) |
8328 { | 8328 { |
8329 uint32 abgr = row[x]; | 8329 uint32 abgr = row[x]; |
8330 int r = TIFFGetR (abgr) << 8; | 8330 int r = TIFFGetR (abgr) << 8; |
8331 int g = TIFFGetG (abgr) << 8; | 8331 int g = TIFFGetG (abgr) << 8; |
8332 int b = TIFFGetB (abgr) << 8; | 8332 int b = TIFFGetB (abgr) << 8; |
8333 XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b)); | 8333 XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b)); |
8334 } | 8334 } |
8335 } | 8335 } |
8336 | 8336 |
8337 /* Remember the colors allocated for the image. Free the color table. */ | 8337 /* Remember the colors allocated for the image. Free the color table. */ |
8338 img->colors = colors_in_color_table (&img->ncolors); | 8338 img->colors = colors_in_color_table (&img->ncolors); |
8341 /* Put the image into the pixmap, then free the X image and its buffer. */ | 8341 /* Put the image into the pixmap, then free the X image and its buffer. */ |
8342 x_put_x_image (f, ximg, img->pixmap, width, height); | 8342 x_put_x_image (f, ximg, img->pixmap, width, height); |
8343 x_destroy_x_image (ximg); | 8343 x_destroy_x_image (ximg); |
8344 xfree (buf); | 8344 xfree (buf); |
8345 UNBLOCK_INPUT; | 8345 UNBLOCK_INPUT; |
8346 | 8346 |
8347 img->width = width; | 8347 img->width = width; |
8348 img->height = height; | 8348 img->height = height; |
8349 | 8349 |
8350 UNGCPRO; | 8350 UNGCPRO; |
8351 return 1; | 8351 return 1; |
8419 gif_image_p (object) | 8419 gif_image_p (object) |
8420 Lisp_Object object; | 8420 Lisp_Object object; |
8421 { | 8421 { |
8422 struct image_keyword fmt[GIF_LAST]; | 8422 struct image_keyword fmt[GIF_LAST]; |
8423 bcopy (gif_format, fmt, sizeof fmt); | 8423 bcopy (gif_format, fmt, sizeof fmt); |
8424 | 8424 |
8425 if (!parse_image_spec (object, fmt, GIF_LAST, Qgif) | 8425 if (!parse_image_spec (object, fmt, GIF_LAST, Qgif) |
8426 || (fmt[GIF_ASCENT].count | 8426 || (fmt[GIF_ASCENT].count |
8427 && XFASTINT (fmt[GIF_ASCENT].value) > 100)) | 8427 && XFASTINT (fmt[GIF_ASCENT].value) > 100)) |
8428 return 0; | 8428 return 0; |
8429 | 8429 |
8430 /* Must specify either the :data or :file keyword. */ | 8430 /* Must specify either the :data or :file keyword. */ |
8431 return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1; | 8431 return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1; |
8432 } | 8432 } |
8433 | 8433 |
8434 /* Reading a GIF image from memory | 8434 /* Reading a GIF image from memory |
8497 { | 8497 { |
8498 image_error ("Cannot find image file `%s'", specified_file, Qnil); | 8498 image_error ("Cannot find image file `%s'", specified_file, Qnil); |
8499 UNGCPRO; | 8499 UNGCPRO; |
8500 return 0; | 8500 return 0; |
8501 } | 8501 } |
8502 | 8502 |
8503 /* Open the GIF file. */ | 8503 /* Open the GIF file. */ |
8504 gif = DGifOpenFileName (SDATA (file)); | 8504 gif = DGifOpenFileName (SDATA (file)); |
8505 if (gif == NULL) | 8505 if (gif == NULL) |
8506 { | 8506 { |
8507 image_error ("Cannot open `%s'", file, Qnil); | 8507 image_error ("Cannot open `%s'", file, Qnil); |
8558 UNBLOCK_INPUT; | 8558 UNBLOCK_INPUT; |
8559 DGifCloseFile (gif); | 8559 DGifCloseFile (gif); |
8560 UNGCPRO; | 8560 UNGCPRO; |
8561 return 0; | 8561 return 0; |
8562 } | 8562 } |
8563 | 8563 |
8564 /* Allocate colors. */ | 8564 /* Allocate colors. */ |
8565 gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap; | 8565 gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap; |
8566 if (!gif_color_map) | 8566 if (!gif_color_map) |
8567 gif_color_map = gif->SColorMap; | 8567 gif_color_map = gif->SColorMap; |
8568 init_color_table (); | 8568 init_color_table (); |
8569 bzero (pixel_colors, sizeof pixel_colors); | 8569 bzero (pixel_colors, sizeof pixel_colors); |
8570 | 8570 |
8571 for (i = 0; i < gif_color_map->ColorCount; ++i) | 8571 for (i = 0; i < gif_color_map->ColorCount; ++i) |
8572 { | 8572 { |
8573 int r = gif_color_map->Colors[i].Red << 8; | 8573 int r = gif_color_map->Colors[i].Red << 8; |
8574 int g = gif_color_map->Colors[i].Green << 8; | 8574 int g = gif_color_map->Colors[i].Green << 8; |
8575 int b = gif_color_map->Colors[i].Blue << 8; | 8575 int b = gif_color_map->Colors[i].Blue << 8; |
8578 | 8578 |
8579 img->colors = colors_in_color_table (&img->ncolors); | 8579 img->colors = colors_in_color_table (&img->ncolors); |
8580 free_color_table (); | 8580 free_color_table (); |
8581 | 8581 |
8582 /* Clear the part of the screen image that are not covered by | 8582 /* Clear the part of the screen image that are not covered by |
8583 the image from the GIF file. Full animated GIF support | 8583 the image from the GIF file. Full animated GIF support |
8584 requires more than can be done here (see the gif89 spec, | 8584 requires more than can be done here (see the gif89 spec, |
8585 disposal methods). Let's simply assume that the part | 8585 disposal methods). Let's simply assume that the part |
8586 not covered by a sub-image is in the frame's background color. */ | 8586 not covered by a sub-image is in the frame's background color. */ |
8587 image_top = gif->SavedImages[ino].ImageDesc.Top; | 8587 image_top = gif->SavedImages[ino].ImageDesc.Top; |
8588 image_left = gif->SavedImages[ino].ImageDesc.Left; | 8588 image_left = gif->SavedImages[ino].ImageDesc.Left; |
8625 { | 8625 { |
8626 row = interlace_start[++pass]; | 8626 row = interlace_start[++pass]; |
8627 while (row >= image_height) | 8627 while (row >= image_height) |
8628 row = interlace_start[++pass]; | 8628 row = interlace_start[++pass]; |
8629 } | 8629 } |
8630 | 8630 |
8631 for (x = 0; x < image_width; x++) | 8631 for (x = 0; x < image_width; x++) |
8632 { | 8632 { |
8633 int i = raster[(y * image_width) + x]; | 8633 int i = raster[(y * image_width) + x]; |
8634 XPutPixel (ximg, x + image_left, row + image_top, | 8634 XPutPixel (ximg, x + image_left, row + image_top, |
8635 pixel_colors[i]); | 8635 pixel_colors[i]); |
8636 } | 8636 } |
8637 | 8637 |
8638 row += interlace_increment[pass]; | 8638 row += interlace_increment[pass]; |
8639 } | 8639 } |
8640 } | 8640 } |
8641 else | 8641 else |
8642 { | 8642 { |
8645 { | 8645 { |
8646 int i = raster[y* image_width + x]; | 8646 int i = raster[y* image_width + x]; |
8647 XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]); | 8647 XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]); |
8648 } | 8648 } |
8649 } | 8649 } |
8650 | 8650 |
8651 DGifCloseFile (gif); | 8651 DGifCloseFile (gif); |
8652 | 8652 |
8653 /* Put the image into the pixmap, then free the X image and its buffer. */ | 8653 /* Put the image into the pixmap, then free the X image and its buffer. */ |
8654 x_put_x_image (f, ximg, img->pixmap, width, height); | 8654 x_put_x_image (f, ximg, img->pixmap, width, height); |
8655 x_destroy_x_image (ximg); | 8655 x_destroy_x_image (ximg); |
8656 UNBLOCK_INPUT; | 8656 UNBLOCK_INPUT; |
8657 | 8657 |
8658 UNGCPRO; | 8658 UNGCPRO; |
8659 return 1; | 8659 return 1; |
8660 } | 8660 } |
8661 | 8661 |
8662 #endif /* HAVE_GIF != 0 */ | 8662 #endif /* HAVE_GIF != 0 */ |
8749 Lisp_Object object; | 8749 Lisp_Object object; |
8750 { | 8750 { |
8751 struct image_keyword fmt[GS_LAST]; | 8751 struct image_keyword fmt[GS_LAST]; |
8752 Lisp_Object tem; | 8752 Lisp_Object tem; |
8753 int i; | 8753 int i; |
8754 | 8754 |
8755 bcopy (gs_format, fmt, sizeof fmt); | 8755 bcopy (gs_format, fmt, sizeof fmt); |
8756 | 8756 |
8757 if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript) | 8757 if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript) |
8758 || (fmt[GS_ASCENT].count | 8758 || (fmt[GS_ASCENT].count |
8759 && XFASTINT (fmt[GS_ASCENT].value) > 100)) | 8759 && XFASTINT (fmt[GS_ASCENT].value) > 100)) |
8760 return 0; | 8760 return 0; |
8761 | 8761 |
8762 /* Bounding box must be a list or vector containing 4 integers. */ | 8762 /* Bounding box must be a list or vector containing 4 integers. */ |
8763 tem = fmt[GS_BOUNDING_BOX].value; | 8763 tem = fmt[GS_BOUNDING_BOX].value; |
8821 if (!img->pixmap) | 8821 if (!img->pixmap) |
8822 { | 8822 { |
8823 image_error ("Unable to create pixmap for `%s'", img->spec, Qnil); | 8823 image_error ("Unable to create pixmap for `%s'", img->spec, Qnil); |
8824 return 0; | 8824 return 0; |
8825 } | 8825 } |
8826 | 8826 |
8827 /* Call the loader to fill the pixmap. It returns a process object | 8827 /* Call the loader to fill the pixmap. It returns a process object |
8828 if successful. We do not record_unwind_protect here because | 8828 if successful. We do not record_unwind_protect here because |
8829 other places in redisplay like calling window scroll functions | 8829 other places in redisplay like calling window scroll functions |
8830 don't either. Let the Lisp loader use `unwind-protect' instead. */ | 8830 don't either. Let the Lisp loader use `unwind-protect' instead. */ |
8831 GCPRO2 (window_and_pixmap_id, pixel_colors); | 8831 GCPRO2 (window_and_pixmap_id, pixel_colors); |
8832 | 8832 |
8833 sprintf (buffer, "%lu %lu", | 8833 sprintf (buffer, "%lu %lu", |
8834 (unsigned long) FRAME_W32_WINDOW (f), | 8834 (unsigned long) FRAME_W32_WINDOW (f), |
8835 (unsigned long) img->pixmap); | 8835 (unsigned long) img->pixmap); |
8836 window_and_pixmap_id = build_string (buffer); | 8836 window_and_pixmap_id = build_string (buffer); |
8837 | 8837 |
8838 sprintf (buffer, "%lu %lu", | 8838 sprintf (buffer, "%lu %lu", |
8839 FRAME_FOREGROUND_PIXEL (f), | 8839 FRAME_FOREGROUND_PIXEL (f), |
8840 FRAME_BACKGROUND_PIXEL (f)); | 8840 FRAME_BACKGROUND_PIXEL (f)); |
8841 pixel_colors = build_string (buffer); | 8841 pixel_colors = build_string (buffer); |
8842 | 8842 |
8843 XSETFRAME (frame, f); | 8843 XSETFRAME (frame, f); |
8844 loader = image_spec_value (img->spec, QCloader, NULL); | 8844 loader = image_spec_value (img->spec, QCloader, NULL); |
8845 if (NILP (loader)) | 8845 if (NILP (loader)) |
8846 loader = intern ("gs-load-image"); | 8846 loader = intern ("gs-load-image"); |
8847 | 8847 |
8895 ximg = XGetImage (FRAME_W32_DISPLAY (f), img->pixmap, | 8895 ximg = XGetImage (FRAME_W32_DISPLAY (f), img->pixmap, |
8896 0, 0, img->width, img->height, ~0, ZPixmap); | 8896 0, 0, img->width, img->height, ~0, ZPixmap); |
8897 if (ximg) | 8897 if (ximg) |
8898 { | 8898 { |
8899 int x, y; | 8899 int x, y; |
8900 | 8900 |
8901 /* Initialize the color table. */ | 8901 /* Initialize the color table. */ |
8902 init_color_table (); | 8902 init_color_table (); |
8903 | 8903 |
8904 /* For each pixel of the image, look its color up in the | 8904 /* For each pixel of the image, look its color up in the |
8905 color table. After having done so, the color table will | 8905 color table. After having done so, the color table will |
8906 contain an entry for each color used by the image. */ | 8906 contain an entry for each color used by the image. */ |
8907 for (y = 0; y < img->height; ++y) | 8907 for (y = 0; y < img->height; ++y) |
8908 for (x = 0; x < img->width; ++x) | 8908 for (x = 0; x < img->width; ++x) |
8931 #endif | 8931 #endif |
8932 } | 8932 } |
8933 else | 8933 else |
8934 image_error ("Cannot get X image of `%s'; colors will not be freed", | 8934 image_error ("Cannot get X image of `%s'; colors will not be freed", |
8935 img->spec, Qnil); | 8935 img->spec, Qnil); |
8936 | 8936 |
8937 UNBLOCK_INPUT; | 8937 UNBLOCK_INPUT; |
8938 } | 8938 } |
8939 } | 8939 } |
8940 | 8940 |
8941 #endif /* HAVE_GHOSTSCRIPT */ | 8941 #endif /* HAVE_GHOSTSCRIPT */ |
9037 tmp_data = NULL; | 9037 tmp_data = NULL; |
9038 | 9038 |
9039 rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), | 9039 rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), |
9040 prop_atom, 0, bytes_remaining, | 9040 prop_atom, 0, bytes_remaining, |
9041 False, XA_STRING, | 9041 False, XA_STRING, |
9042 &actual_type, &actual_format, | 9042 &actual_type, &actual_format, |
9043 &actual_size, &bytes_remaining, | 9043 &actual_size, &bytes_remaining, |
9044 (unsigned char **) &tmp_data); | 9044 (unsigned char **) &tmp_data); |
9045 if (rc == Success) | 9045 if (rc == Success) |
9046 prop_value = make_string (tmp_data, size); | 9046 prop_value = make_string (tmp_data, size); |
9047 | 9047 |
9048 XFree (tmp_data); | 9048 XFree (tmp_data); |
9092 start_hourglass () | 9092 start_hourglass () |
9093 { | 9093 { |
9094 #if 0 /* MAC_TODO: cursor shape changes. */ | 9094 #if 0 /* MAC_TODO: cursor shape changes. */ |
9095 EMACS_TIME delay; | 9095 EMACS_TIME delay; |
9096 int secs, usecs = 0; | 9096 int secs, usecs = 0; |
9097 | 9097 |
9098 cancel_hourglass (); | 9098 cancel_hourglass (); |
9099 | 9099 |
9100 if (INTEGERP (Vhourglass_delay) | 9100 if (INTEGERP (Vhourglass_delay) |
9101 && XINT (Vhourglass_delay) > 0) | 9101 && XINT (Vhourglass_delay) > 0) |
9102 secs = XFASTINT (Vhourglass_delay); | 9102 secs = XFASTINT (Vhourglass_delay); |
9108 secs = XFASTINT (tem); | 9108 secs = XFASTINT (tem); |
9109 usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000; | 9109 usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000; |
9110 } | 9110 } |
9111 else | 9111 else |
9112 secs = DEFAULT_HOURGLASS_DELAY; | 9112 secs = DEFAULT_HOURGLASS_DELAY; |
9113 | 9113 |
9114 EMACS_SET_SECS_USECS (delay, secs, usecs); | 9114 EMACS_SET_SECS_USECS (delay, secs, usecs); |
9115 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay, | 9115 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay, |
9116 show_hourglass, NULL); | 9116 show_hourglass, NULL); |
9117 #endif /* MAC_TODO */ | 9117 #endif /* MAC_TODO */ |
9118 } | 9118 } |
9127 if (hourglass_atimer) | 9127 if (hourglass_atimer) |
9128 { | 9128 { |
9129 cancel_atimer (hourglass_atimer); | 9129 cancel_atimer (hourglass_atimer); |
9130 hourglass_atimer = NULL; | 9130 hourglass_atimer = NULL; |
9131 } | 9131 } |
9132 | 9132 |
9133 if (hourglass_shown_p) | 9133 if (hourglass_shown_p) |
9134 hide_hourglass (); | 9134 hide_hourglass (); |
9135 } | 9135 } |
9136 | 9136 |
9137 | 9137 |
9154 hourglass_atimer = NULL; | 9154 hourglass_atimer = NULL; |
9155 | 9155 |
9156 if (!hourglass_shown_p) | 9156 if (!hourglass_shown_p) |
9157 { | 9157 { |
9158 Lisp_Object rest, frame; | 9158 Lisp_Object rest, frame; |
9159 | 9159 |
9160 BLOCK_INPUT; | 9160 BLOCK_INPUT; |
9161 | 9161 |
9162 FOR_EACH_FRAME (rest, frame) | 9162 FOR_EACH_FRAME (rest, frame) |
9163 if (FRAME_W32_P (XFRAME (frame))) | 9163 if (FRAME_W32_P (XFRAME (frame))) |
9164 { | 9164 { |
9165 struct frame *f = XFRAME (frame); | 9165 struct frame *f = XFRAME (frame); |
9166 | 9166 |
9167 f->output_data.w32->hourglass_p = 1; | 9167 f->output_data.w32->hourglass_p = 1; |
9168 | 9168 |
9169 if (!f->output_data.w32->hourglass_window) | 9169 if (!f->output_data.w32->hourglass_window) |
9170 { | 9170 { |
9171 unsigned long mask = CWCursor; | 9171 unsigned long mask = CWCursor; |
9172 XSetWindowAttributes attrs; | 9172 XSetWindowAttributes attrs; |
9173 | 9173 |
9174 attrs.cursor = f->output_data.w32->hourglass_cursor; | 9174 attrs.cursor = f->output_data.w32->hourglass_cursor; |
9175 | 9175 |
9176 f->output_data.w32->hourglass_window | 9176 f->output_data.w32->hourglass_window |
9177 = XCreateWindow (FRAME_X_DISPLAY (f), | 9177 = XCreateWindow (FRAME_X_DISPLAY (f), |
9178 FRAME_OUTER_WINDOW (f), | 9178 FRAME_OUTER_WINDOW (f), |
9179 0, 0, 32000, 32000, 0, 0, | 9179 0, 0, 32000, 32000, 0, 0, |
9180 InputOnly, | 9180 InputOnly, |
9181 CopyFromParent, | 9181 CopyFromParent, |
9182 mask, &attrs); | 9182 mask, &attrs); |
9183 } | 9183 } |
9184 | 9184 |
9185 XMapRaised (FRAME_X_DISPLAY (f), | 9185 XMapRaised (FRAME_X_DISPLAY (f), |
9186 f->output_data.w32->hourglass_window); | 9186 f->output_data.w32->hourglass_window); |
9187 XFlush (FRAME_X_DISPLAY (f)); | 9187 XFlush (FRAME_X_DISPLAY (f)); |
9188 } | 9188 } |
9189 | 9189 |
9206 | 9206 |
9207 BLOCK_INPUT; | 9207 BLOCK_INPUT; |
9208 FOR_EACH_FRAME (rest, frame) | 9208 FOR_EACH_FRAME (rest, frame) |
9209 { | 9209 { |
9210 struct frame *f = XFRAME (frame); | 9210 struct frame *f = XFRAME (frame); |
9211 | 9211 |
9212 if (FRAME_W32_P (f) | 9212 if (FRAME_W32_P (f) |
9213 /* Watch out for newly created frames. */ | 9213 /* Watch out for newly created frames. */ |
9214 && f->output_data.x->hourglass_window) | 9214 && f->output_data.x->hourglass_window) |
9215 { | 9215 { |
9216 XUnmapWindow (FRAME_X_DISPLAY (f), | 9216 XUnmapWindow (FRAME_X_DISPLAY (f), |
9234 Tool tips | 9234 Tool tips |
9235 ***********************************************************************/ | 9235 ***********************************************************************/ |
9236 | 9236 |
9237 static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *, | 9237 static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *, |
9238 Lisp_Object)); | 9238 Lisp_Object)); |
9239 | 9239 |
9240 /* The frame of a currently visible tooltip, or null. */ | 9240 /* The frame of a currently visible tooltip, or null. */ |
9241 | 9241 |
9242 Lisp_Object tip_frame; | 9242 Lisp_Object tip_frame; |
9243 | 9243 |
9244 /* If non-nil, a timer started that hides the last tooltip when it | 9244 /* If non-nil, a timer started that hides the last tooltip when it |
9342 if (STRINGP (tem)) | 9342 if (STRINGP (tem)) |
9343 font = x_new_fontset (f, SDATA (tem)); | 9343 font = x_new_fontset (f, SDATA (tem)); |
9344 else | 9344 else |
9345 font = x_new_font (f, SDATA (font)); | 9345 font = x_new_font (f, SDATA (font)); |
9346 } | 9346 } |
9347 | 9347 |
9348 /* Try out a font which we hope has bold and italic variations. */ | 9348 /* Try out a font which we hope has bold and italic variations. */ |
9349 if (!STRINGP (font)) | 9349 if (!STRINGP (font)) |
9350 font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1"); | 9350 font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1"); |
9351 if (!STRINGP (font)) | 9351 if (!STRINGP (font)) |
9352 font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1"); | 9352 font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1"); |
9367 "font", "Font", RES_TYPE_STRING); | 9367 "font", "Font", RES_TYPE_STRING); |
9368 } | 9368 } |
9369 | 9369 |
9370 x_default_parameter (f, parms, Qborder_width, make_number (2), | 9370 x_default_parameter (f, parms, Qborder_width, make_number (2), |
9371 "borderWidth", "BorderWidth", RES_TYPE_NUMBER); | 9371 "borderWidth", "BorderWidth", RES_TYPE_NUMBER); |
9372 | 9372 |
9373 /* This defaults to 2 in order to match xterm. We recognize either | 9373 /* This defaults to 2 in order to match xterm. We recognize either |
9374 internalBorderWidth or internalBorder (which is what xterm calls | 9374 internalBorderWidth or internalBorder (which is what xterm calls |
9375 it). */ | 9375 it). */ |
9376 if (NILP (Fassq (Qinternal_border_width, parms))) | 9376 if (NILP (Fassq (Qinternal_border_width, parms))) |
9377 { | 9377 { |
9405 which calls change_frame_size, which calls Fset_window_buffer, | 9405 which calls change_frame_size, which calls Fset_window_buffer, |
9406 which runs hooks, which call Fvertical_motion. At the end, we | 9406 which runs hooks, which call Fvertical_motion. At the end, we |
9407 end up in init_iterator with a null face cache, which should not | 9407 end up in init_iterator with a null face cache, which should not |
9408 happen. */ | 9408 happen. */ |
9409 init_frame_faces (f); | 9409 init_frame_faces (f); |
9410 | 9410 |
9411 f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window; | 9411 f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window; |
9412 window_prompting = x_figure_window_size (f, parms); | 9412 window_prompting = x_figure_window_size (f, parms); |
9413 | 9413 |
9414 if (window_prompting & XNegative) | 9414 if (window_prompting & XNegative) |
9415 { | 9415 { |
9428 | 9428 |
9429 f->output_data.w32->size_hint_flags = window_prompting; | 9429 f->output_data.w32->size_hint_flags = window_prompting; |
9430 { | 9430 { |
9431 XSetWindowAttributes attrs; | 9431 XSetWindowAttributes attrs; |
9432 unsigned long mask; | 9432 unsigned long mask; |
9433 | 9433 |
9434 BLOCK_INPUT; | 9434 BLOCK_INPUT; |
9435 mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask; | 9435 mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask; |
9436 /* Window managers looks at the override-redirect flag to | 9436 /* Window managers looks at the override-redirect flag to |
9437 determine whether or net to give windows a decoration (Xlib | 9437 determine whether or net to give windows a decoration (Xlib |
9438 3.2.8). */ | 9438 3.2.8). */ |
9523 int root_x, root_y, win_x, win_y; | 9523 int root_x, root_y, win_x, win_y; |
9524 unsigned pmask; | 9524 unsigned pmask; |
9525 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 9525 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
9526 int old_windows_or_buffers_changed = windows_or_buffers_changed; | 9526 int old_windows_or_buffers_changed = windows_or_buffers_changed; |
9527 int count = SPECPDL_INDEX (); | 9527 int count = SPECPDL_INDEX (); |
9528 | 9528 |
9529 specbind (Qinhibit_redisplay, Qt); | 9529 specbind (Qinhibit_redisplay, Qt); |
9530 | 9530 |
9531 GCPRO4 (string, parms, frame, timeout); | 9531 GCPRO4 (string, parms, frame, timeout); |
9532 | 9532 |
9533 CHECK_STRING (string); | 9533 CHECK_STRING (string); |
9539 | 9539 |
9540 if (NILP (dx)) | 9540 if (NILP (dx)) |
9541 dx = make_number (5); | 9541 dx = make_number (5); |
9542 else | 9542 else |
9543 CHECK_NUMBER (dx); | 9543 CHECK_NUMBER (dx); |
9544 | 9544 |
9545 if (NILP (dy)) | 9545 if (NILP (dy)) |
9546 dy = make_number (-10); | 9546 dy = make_number (-10); |
9547 else | 9547 else |
9548 CHECK_NUMBER (dy); | 9548 CHECK_NUMBER (dy); |
9549 | 9549 |
9559 if (EQ (frame, last_frame) | 9559 if (EQ (frame, last_frame) |
9560 && !NILP (Fequal (last_string, string)) | 9560 && !NILP (Fequal (last_string, string)) |
9561 && !NILP (Fequal (last_parms, parms))) | 9561 && !NILP (Fequal (last_parms, parms))) |
9562 { | 9562 { |
9563 struct frame *f = XFRAME (tip_frame); | 9563 struct frame *f = XFRAME (tip_frame); |
9564 | 9564 |
9565 /* Only DX and DY have changed. */ | 9565 /* Only DX and DY have changed. */ |
9566 if (!NILP (tip_timer)) | 9566 if (!NILP (tip_timer)) |
9567 { | 9567 { |
9568 Lisp_Object timer = tip_timer; | 9568 Lisp_Object timer = tip_timer; |
9569 tip_timer = Qnil; | 9569 tip_timer = Qnil; |
9650 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; | 9650 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; |
9651 row_width = row->pixel_width - last->pixel_width; | 9651 row_width = row->pixel_width - last->pixel_width; |
9652 } | 9652 } |
9653 else | 9653 else |
9654 row_width = row->pixel_width; | 9654 row_width = row->pixel_width; |
9655 | 9655 |
9656 height += row->height; | 9656 height += row->height; |
9657 width = max (width, row_width); | 9657 width = max (width, row_width); |
9658 } | 9658 } |
9659 | 9659 |
9660 /* Add the frame's internal border to the width and height the X | 9660 /* Add the frame's internal border to the width and height the X |
9704 struct gcpro gcpro1, gcpro2; | 9704 struct gcpro gcpro1, gcpro2; |
9705 | 9705 |
9706 /* Return quickly if nothing to do. */ | 9706 /* Return quickly if nothing to do. */ |
9707 if (NILP (tip_timer) && NILP (tip_frame)) | 9707 if (NILP (tip_timer) && NILP (tip_frame)) |
9708 return Qnil; | 9708 return Qnil; |
9709 | 9709 |
9710 frame = tip_frame; | 9710 frame = tip_frame; |
9711 timer = tip_timer; | 9711 timer = tip_timer; |
9712 GCPRO2 (frame, timer); | 9712 GCPRO2 (frame, timer); |
9713 tip_frame = tip_timer = deleted = Qnil; | 9713 tip_frame = tip_timer = deleted = Qnil; |
9714 | 9714 |
9715 count = SPECPDL_INDEX (); | 9715 count = SPECPDL_INDEX (); |
9716 specbind (Qinhibit_redisplay, Qt); | 9716 specbind (Qinhibit_redisplay, Qt); |
9717 specbind (Qinhibit_quit, Qt); | 9717 specbind (Qinhibit_quit, Qt); |
9718 | 9718 |
9719 if (!NILP (timer)) | 9719 if (!NILP (timer)) |
9720 call1 (Qcancel_timer, timer); | 9720 call1 (Qcancel_timer, timer); |
9721 | 9721 |
9722 if (FRAMEP (frame)) | 9722 if (FRAMEP (frame)) |
9723 { | 9723 { |
9862 DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "") | 9862 DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "") |
9863 (spec) | 9863 (spec) |
9864 Lisp_Object spec; | 9864 Lisp_Object spec; |
9865 { | 9865 { |
9866 int id = -1; | 9866 int id = -1; |
9867 | 9867 |
9868 if (valid_image_p (spec)) | 9868 if (valid_image_p (spec)) |
9869 id = lookup_image (SELECTED_FRAME (), spec); | 9869 id = lookup_image (SELECTED_FRAME (), spec); |
9870 | 9870 |
9871 debug_print (spec); | 9871 debug_print (spec); |
9872 return make_number (id); | 9872 return make_number (id); |
10010 Vx_hourglass_pointer_shape = Qnil; | 10010 Vx_hourglass_pointer_shape = Qnil; |
10011 | 10011 |
10012 DEFVAR_BOOL ("display-hourglass", &display_hourglass_p, | 10012 DEFVAR_BOOL ("display-hourglass", &display_hourglass_p, |
10013 doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */); | 10013 doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */); |
10014 display_hourglass_p = 1; | 10014 display_hourglass_p = 1; |
10015 | 10015 |
10016 DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay, | 10016 DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay, |
10017 doc: /* *Seconds to wait before displaying an hourglass pointer. | 10017 doc: /* *Seconds to wait before displaying an hourglass pointer. |
10018 Value must be an integer or float. */); | 10018 Value must be an integer or float. */); |
10019 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY); | 10019 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY); |
10020 | 10020 |
10137 | 10137 |
10138 #if HAVE_XPM | 10138 #if HAVE_XPM |
10139 Qxpm = intern ("xpm"); | 10139 Qxpm = intern ("xpm"); |
10140 staticpro (&Qxpm); | 10140 staticpro (&Qxpm); |
10141 #endif | 10141 #endif |
10142 | 10142 |
10143 #if HAVE_JPEG | 10143 #if HAVE_JPEG |
10144 Qjpeg = intern ("jpeg"); | 10144 Qjpeg = intern ("jpeg"); |
10145 staticpro (&Qjpeg); | 10145 staticpro (&Qjpeg); |
10146 #endif | 10146 #endif |
10147 | 10147 |
10148 #if HAVE_TIFF | 10148 #if HAVE_TIFF |
10149 Qtiff = intern ("tiff"); | 10149 Qtiff = intern ("tiff"); |
10150 staticpro (&Qtiff); | 10150 staticpro (&Qtiff); |
10151 #endif | 10151 #endif |
10152 | 10152 |
10153 #if HAVE_GIF | 10153 #if HAVE_GIF |
10154 Qgif = intern ("gif"); | 10154 Qgif = intern ("gif"); |
10155 staticpro (&Qgif); | 10155 staticpro (&Qgif); |
10156 #endif | 10156 #endif |
10190 | 10190 |
10191 define_image_type (&xbm_type); | 10191 define_image_type (&xbm_type); |
10192 #if 0 /* NTEMACS_TODO : Image support for W32 */ | 10192 #if 0 /* NTEMACS_TODO : Image support for W32 */ |
10193 define_image_type (&gs_type); | 10193 define_image_type (&gs_type); |
10194 define_image_type (&pbm_type); | 10194 define_image_type (&pbm_type); |
10195 | 10195 |
10196 #if HAVE_XPM | 10196 #if HAVE_XPM |
10197 define_image_type (&xpm_type); | 10197 define_image_type (&xpm_type); |
10198 #endif | 10198 #endif |
10199 | 10199 |
10200 #if HAVE_JPEG | 10200 #if HAVE_JPEG |
10201 define_image_type (&jpeg_type); | 10201 define_image_type (&jpeg_type); |
10202 #endif | 10202 #endif |
10203 | 10203 |
10204 #if HAVE_TIFF | 10204 #if HAVE_TIFF |
10205 define_image_type (&tiff_type); | 10205 define_image_type (&tiff_type); |
10206 #endif | 10206 #endif |
10207 | 10207 |
10208 #if HAVE_GIF | 10208 #if HAVE_GIF |
10209 define_image_type (&gif_type); | 10209 define_image_type (&gif_type); |
10210 #endif | 10210 #endif |
10211 | 10211 |
10212 #if HAVE_PNG | 10212 #if HAVE_PNG |
10213 define_image_type (&png_type); | 10213 define_image_type (&png_type); |
10214 #endif | 10214 #endif |
10215 #endif /* NTEMACS_TODO */ | 10215 #endif /* NTEMACS_TODO */ |
10216 } | 10216 } |