diff options
| author | Gerd Moellmann | 1999-09-10 16:19:34 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 1999-09-10 16:19:34 +0000 |
| commit | fcf431dc3ff9e8cb47135b050fc56a4852e38a28 (patch) | |
| tree | 57dec3cabd6ae76bfa9f9697e73fdc3a85beb03c /src | |
| parent | 61e59c1dd1122656d9bbfc6892ad40c693318224 (diff) | |
| download | emacs-fcf431dc3ff9e8cb47135b050fc56a4852e38a28.tar.gz emacs-fcf431dc3ff9e8cb47135b050fc56a4852e38a28.zip | |
(x_build_heuristic_mask): Accept a list `(R G B)'
as background color specification instead of an integer.
(image-cache-eviction-delay): Replaces image-eviction-seconds.
(Vimage_cache_eviction_delay): Replaces Vimage_eviction_seconds.
(clear_image_cache, syms_of_xfns): Use it.
(Qpostscript): Replaces Qghostscript.
(gs_type): Use it.
(gs_image_p): Ditto.
(syms_of_xfns): Initialize Qpostscript.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 73 |
1 files changed, 51 insertions, 22 deletions
diff --git a/src/xfns.c b/src/xfns.c index 2eddd37f17e..f994598ad1a 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -5460,7 +5460,7 @@ Lisp_Object Qlaplace; | |||
| 5460 | /* Time in seconds after which images should be removed from the cache | 5460 | /* Time in seconds after which images should be removed from the cache |
| 5461 | if not displayed. */ | 5461 | if not displayed. */ |
| 5462 | 5462 | ||
| 5463 | Lisp_Object Vimage_eviction_seconds; | 5463 | Lisp_Object Vimage_cache_eviction_delay; |
| 5464 | 5464 | ||
| 5465 | /* Function prototypes. */ | 5465 | /* Function prototypes. */ |
| 5466 | 5466 | ||
| @@ -5989,14 +5989,14 @@ clear_image_cache (f, force_p) | |||
| 5989 | { | 5989 | { |
| 5990 | struct image_cache *c = FRAME_X_IMAGE_CACHE (f); | 5990 | struct image_cache *c = FRAME_X_IMAGE_CACHE (f); |
| 5991 | 5991 | ||
| 5992 | if (c && INTEGERP (Vimage_eviction_seconds)) | 5992 | if (c && INTEGERP (Vimage_cache_eviction_delay)) |
| 5993 | { | 5993 | { |
| 5994 | EMACS_TIME t; | 5994 | EMACS_TIME t; |
| 5995 | unsigned long old; | 5995 | unsigned long old; |
| 5996 | int i, any_freed_p = 0; | 5996 | int i, any_freed_p = 0; |
| 5997 | 5997 | ||
| 5998 | EMACS_GET_TIME (t); | 5998 | EMACS_GET_TIME (t); |
| 5999 | old = EMACS_SECS (t) - XFASTINT (Vimage_eviction_seconds); | 5999 | old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay); |
| 6000 | 6000 | ||
| 6001 | for (i = 0; i < c->used; ++i) | 6001 | for (i = 0; i < c->used; ++i) |
| 6002 | { | 6002 | { |
| @@ -7516,10 +7516,10 @@ x_laplace (f, img) | |||
| 7516 | 7516 | ||
| 7517 | /* Build a mask for image IMG which is used on frame F. FILE is the | 7517 | /* Build a mask for image IMG which is used on frame F. FILE is the |
| 7518 | name of an image file, for error messages. HOW determines how to | 7518 | name of an image file, for error messages. HOW determines how to |
| 7519 | determine the background color of IMG. If it is an integer, take | 7519 | determine the background color of IMG. If it is a list '(R G B)', |
| 7520 | that as the pixel value of the background. Otherwise, determine | 7520 | with R, G, and B being integers >= 0, take that as the color of the |
| 7521 | the background color of IMG heuristically. Value is non-zero | 7521 | background. Otherwise, determine the background color of IMG |
| 7522 | if successful. */ | 7522 | heuristically. Value is non-zero if successful. */ |
| 7523 | 7523 | ||
| 7524 | static int | 7524 | static int |
| 7525 | x_build_heuristic_mask (f, file, img, how) | 7525 | x_build_heuristic_mask (f, file, img, how) |
| @@ -7531,7 +7531,7 @@ x_build_heuristic_mask (f, file, img, how) | |||
| 7531 | Display *dpy = FRAME_X_DISPLAY (f); | 7531 | Display *dpy = FRAME_X_DISPLAY (f); |
| 7532 | Window win = FRAME_X_WINDOW (f); | 7532 | Window win = FRAME_X_WINDOW (f); |
| 7533 | XImage *ximg, *mask_img; | 7533 | XImage *ximg, *mask_img; |
| 7534 | int x, y, rc; | 7534 | int x, y, rc, look_at_corners_p; |
| 7535 | unsigned long bg; | 7535 | unsigned long bg; |
| 7536 | 7536 | ||
| 7537 | BLOCK_INPUT; | 7537 | BLOCK_INPUT; |
| @@ -7549,12 +7549,41 @@ x_build_heuristic_mask (f, file, img, how) | |||
| 7549 | ximg = XGetImage (dpy, img->pixmap, 0, 0, img->width, img->height, | 7549 | ximg = XGetImage (dpy, img->pixmap, 0, 0, img->width, img->height, |
| 7550 | ~0, ZPixmap); | 7550 | ~0, ZPixmap); |
| 7551 | 7551 | ||
| 7552 | /* Determine the background color of ximg. If HOW is an integer, | 7552 | /* Determine the background color of ximg. If HOW is `(R G B)' |
| 7553 | take that as a pixel color. Otherwise, try to determine the | 7553 | take that as color. Otherwise, try to determine the color |
| 7554 | color heuristically. */ | 7554 | heuristically. */ |
| 7555 | if (NATNUMP (how)) | 7555 | look_at_corners_p = 1; |
| 7556 | bg = XFASTINT (how); | 7556 | |
| 7557 | else | 7557 | if (CONSP (how)) |
| 7558 | { | ||
| 7559 | int rgb[3], i = 0; | ||
| 7560 | |||
| 7561 | while (i < 3 | ||
| 7562 | && CONSP (how) | ||
| 7563 | && NATNUMP (XCAR (how))) | ||
| 7564 | { | ||
| 7565 | rgb[i] = XFASTINT (XCAR (how)) & 0xffff; | ||
| 7566 | how = XCDR (how); | ||
| 7567 | } | ||
| 7568 | |||
| 7569 | if (i == 3 && NILP (how)) | ||
| 7570 | { | ||
| 7571 | char color_name[30]; | ||
| 7572 | XColor exact, color; | ||
| 7573 | Colormap cmap; | ||
| 7574 | |||
| 7575 | sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]); | ||
| 7576 | |||
| 7577 | cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); | ||
| 7578 | if (XLookupColor (dpy, cmap, color_name, &exact, &color)) | ||
| 7579 | { | ||
| 7580 | bg = color.pixel; | ||
| 7581 | look_at_corners_p = 0; | ||
| 7582 | } | ||
| 7583 | } | ||
| 7584 | } | ||
| 7585 | |||
| 7586 | if (look_at_corners_p) | ||
| 7558 | { | 7587 | { |
| 7559 | unsigned long corners[4]; | 7588 | unsigned long corners[4]; |
| 7560 | int i, best_count; | 7589 | int i, best_count; |
| @@ -8990,9 +9019,9 @@ static int gs_image_p P_ ((Lisp_Object object)); | |||
| 8990 | static int gs_load P_ ((struct frame *f, struct image *img)); | 9019 | static int gs_load P_ ((struct frame *f, struct image *img)); |
| 8991 | static void gs_clear_image P_ ((struct frame *f, struct image *img)); | 9020 | static void gs_clear_image P_ ((struct frame *f, struct image *img)); |
| 8992 | 9021 | ||
| 8993 | /* The symbol `ghostscript' identifying images of this type. */ | 9022 | /* The symbol `postscript' identifying images of this type. */ |
| 8994 | 9023 | ||
| 8995 | Lisp_Object Qghostscript; | 9024 | Lisp_Object Qpostscript; |
| 8996 | 9025 | ||
| 8997 | /* Keyword symbols. */ | 9026 | /* Keyword symbols. */ |
| 8998 | 9027 | ||
| @@ -9038,7 +9067,7 @@ static struct image_keyword gs_format[GS_LAST] = | |||
| 9038 | 9067 | ||
| 9039 | static struct image_type gs_type = | 9068 | static struct image_type gs_type = |
| 9040 | { | 9069 | { |
| 9041 | &Qghostscript, | 9070 | &Qpostscript, |
| 9042 | gs_image_p, | 9071 | gs_image_p, |
| 9043 | gs_load, | 9072 | gs_load, |
| 9044 | gs_clear_image, | 9073 | gs_clear_image, |
| @@ -9072,7 +9101,7 @@ gs_image_p (object) | |||
| 9072 | 9101 | ||
| 9073 | bcopy (gs_format, fmt, sizeof fmt); | 9102 | bcopy (gs_format, fmt, sizeof fmt); |
| 9074 | 9103 | ||
| 9075 | if (!parse_image_spec (object, fmt, GS_LAST, Qghostscript, 1) | 9104 | if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript, 1) |
| 9076 | || (fmt[GS_ASCENT].count | 9105 | || (fmt[GS_ASCENT].count |
| 9077 | && XFASTINT (fmt[GS_ASCENT].value) > 100)) | 9106 | && XFASTINT (fmt[GS_ASCENT].value) > 100)) |
| 9078 | return 0; | 9107 | return 0; |
| @@ -10289,12 +10318,12 @@ such a font. This is especially effective for such large fonts as\n\ | |||
| 10289 | Chinese, Japanese, and Korean."); | 10318 | Chinese, Japanese, and Korean."); |
| 10290 | Vx_pixel_size_width_font_regexp = Qnil; | 10319 | Vx_pixel_size_width_font_regexp = Qnil; |
| 10291 | 10320 | ||
| 10292 | DEFVAR_LISP ("image-eviction-seconds", &Vimage_eviction_seconds, | 10321 | DEFVAR_LISP ("image-cache-eviction-delay", &Vimage_cache_eviction_delay, |
| 10293 | "Time after which cached images are removed from the cache.\n\ | 10322 | "Time after which cached images are removed from the cache.\n\ |
| 10294 | When an image has not been displayed this many seconds, remove it\n\ | 10323 | When an image has not been displayed this many seconds, remove it\n\ |
| 10295 | from the image cache. Value must be an integer or nil with nil\n\ | 10324 | from the image cache. Value must be an integer or nil with nil\n\ |
| 10296 | meaning don't clear the cache."); | 10325 | meaning don't clear the cache."); |
| 10297 | Vimage_eviction_seconds = make_number (30 * 60); | 10326 | Vimage_cache_eviction_delay = make_number (30 * 60); |
| 10298 | 10327 | ||
| 10299 | DEFVAR_LISP ("image-types", &Vimage_types, | 10328 | DEFVAR_LISP ("image-types", &Vimage_types, |
| 10300 | "List of supported image types.\n\ | 10329 | "List of supported image types.\n\ |
| @@ -10390,8 +10419,8 @@ Each element of the list is a symbol for a supported image type."); | |||
| 10390 | staticpro (&QCmargin); | 10419 | staticpro (&QCmargin); |
| 10391 | QCrelief = intern (":relief"); | 10420 | QCrelief = intern (":relief"); |
| 10392 | staticpro (&QCrelief); | 10421 | staticpro (&QCrelief); |
| 10393 | Qghostscript = intern ("ghostscript"); | 10422 | Qpostscript = intern ("postscript"); |
| 10394 | staticpro (&Qghostscript); | 10423 | staticpro (&Qpostscript); |
| 10395 | QCloader = intern (":loader"); | 10424 | QCloader = intern (":loader"); |
| 10396 | staticpro (&QCloader); | 10425 | staticpro (&QCloader); |
| 10397 | QCbounding_box = intern (":bounding-box"); | 10426 | QCbounding_box = intern (":bounding-box"); |