comparison src/glyphs-x.c @ 2959:4eb2a8c07cb3

[xemacs-hg @ 2005-09-27 05:48:22 by ben] Implement color pixmap cursors glyphs.c, glyphs-eimage.c, glyphs-x.c, glyphs-gtk.c, glyphs-msw.c, console-impl.h: Allow all kinds of color images (GIF, JPEG, ...) to be mouse pointers. new -> new_, 'foo -> `foo'.
author ben
date Tue, 27 Sep 2005 05:48:27 +0000
parents 3d8143fc88e1
children ad2f4ae9895b
comparison
equal deleted inserted replaced
2958:9e04ad6a1ac6 2959:4eb2a8c07cb3
1 /* X-specific Lisp objects. 1 /* X-specific Lisp objects.
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc. 2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
3 Copyright (C) 1995 Board of Trustees, University of Illinois. 3 Copyright (C) 1995 Board of Trustees, University of Illinois.
4 Copyright (C) 1995 Tinker Systems 4 Copyright (C) 1995 Tinker Systems
5 Copyright (C) 1995, 1996, 2001, 2002, 2003, 2004 Ben Wing 5 Copyright (C) 1995, 1996, 2001, 2002, 2003, 2004, 2005 Ben Wing
6 Copyright (C) 1995 Sun Microsystems 6 Copyright (C) 1995 Sun Microsystems
7 Copyright (C) 1999, 2000, 2002 Andy Piper 7 Copyright (C) 1999, 2000, 2002 Andy Piper
8 8
9 This file is part of XEmacs. 9 This file is part of XEmacs.
10 10
722 722
723 /************************************************************************/ 723 /************************************************************************/
724 /* color pixmap functions */ 724 /* color pixmap functions */
725 /************************************************************************/ 725 /************************************************************************/
726 726
727 /* Create a pointer from a color pixmap. */
728
729 static void
730 image_instance_convert_to_pointer (Lisp_Image_Instance *ii,
731 Lisp_Object instantiator,
732 Lisp_Object pointer_fg,
733 Lisp_Object pointer_bg)
734 {
735 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
736 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (device));
737 Screen *xs = DefaultScreenOfDisplay (dpy);
738 int npixels = IMAGE_INSTANCE_X_NPIXELS (ii);
739 unsigned long *pixels = IMAGE_INSTANCE_X_PIXELS (ii);
740 Pixmap pixmap = IMAGE_INSTANCE_X_PIXMAP (ii);
741 Pixmap mask = (Pixmap) IMAGE_INSTANCE_PIXMAP_MASK (ii);
742 Colormap cmap;
743 XColor fg, bg;
744 int i;
745 int xhot = 0, yhot = 0;
746 int w, h;
747
748 if (INTP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii)))
749 xhot = XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii));
750 if (INTP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii)))
751 yhot = XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii));
752 w = IMAGE_INSTANCE_PIXMAP_WIDTH (ii);
753 h = IMAGE_INSTANCE_PIXMAP_HEIGHT (ii);
754
755 #if 1
756 /* Although I haven't found it documented yet, it appears that pointers are
757 always colored via the default window colormap... Sigh. */
758 cmap = DefaultColormap (dpy, DefaultScreen (dpy));
759 IMAGE_INSTANCE_X_COLORMAP (ii) = cmap;
760 #else
761 cmap = IMAGE_INSTANCE_X_COLORMAP (ii);
762 #endif
763
764 check_pointer_sizes (xs, w, h, instantiator);
765
766 /* If the loaded pixmap has colors allocated (meaning it came from an
767 XPM file), then use those as the default colors for the cursor we
768 create. Otherwise, default to pointer_fg and pointer_bg.
769 */
770 if (npixels >= 2)
771 {
772 /* With an XBM file, it's obvious which bit is foreground
773 and which is background, or rather, it's implicit: in
774 an XBM file, a 1 bit is foreground, and a 0 bit is
775 background.
776
777 XCreatePixmapCursor() assumes this property of the
778 pixmap it is called with as well; the `foreground'
779 color argument is used for the 1 bits.
780
781 With an XPM file, it's tricker, since the elements of
782 the pixmap don't represent FG and BG, but are actual
783 pixel values. So we need to figure out which of those
784 pixels is the foreground color and which is the
785 background. We do it by comparing RGB and assuming
786 that the darker color is the foreground. This works
787 with the result of xbmtopbm|ppmtoxpm, at least.
788
789 It might be nice if there was some way to tag the
790 colors in the XPM file with whether they are the
791 foreground - perhaps with logical color names somehow?
792
793 Once we have decided which color is the foreground, we
794 need to ensure that that color corresponds to a `1' bit
795 in the Pixmap. The XPM library wrote into the (1-bit)
796 pixmap with XPutPixel, which will ignore all but the
797 least significant bit.
798
799 This means that a 1 bit in the image corresponds to
800 `fg' only if `fg.pixel' is odd.
801
802 (This also means that the image will be all the same
803 color if both `fg' and `bg' are odd or even, but we can
804 safely assume that that won't happen if the XPM file is
805 sensible I think.)
806
807 The desired result is that the image use `1' to
808 represent the foreground color, and `0' to represent
809 the background color. So, we may need to invert the
810 image to accomplish this; we invert if fg is
811 odd. (Remember that WhitePixel and BlackPixel are not
812 necessarily 1 and 0 respectively, though I think it
813 might be safe to assume that one of them is always 1
814 and the other is always 0. We also pretty much need to
815 assume that one is even and the other is odd.)
816 */
817
818 fg.pixel = pixels[0]; /* pick a pixel at random. */
819 bg.pixel = fg.pixel;
820 for (i = 1; i < npixels; i++) /* Look for an "other" pixel value.*/
821 {
822 bg.pixel = pixels[i];
823 if (fg.pixel != bg.pixel)
824 break;
825 }
826
827 /* If (fg.pixel == bg.pixel) then probably something has
828 gone wrong, but I don't think signalling an error would
829 be appropriate. */
830
831 XQueryColor (dpy, cmap, &fg);
832 XQueryColor (dpy, cmap, &bg);
833
834 /* If the foreground is lighter than the background, swap them.
835 (This occurs semi-randomly, depending on the ordering of the
836 color list in the XPM file.)
837 */
838 {
839 unsigned short fg_total = ((fg.red / 3) + (fg.green / 3)
840 + (fg.blue / 3));
841 unsigned short bg_total = ((bg.red / 3) + (bg.green / 3)
842 + (bg.blue / 3));
843 if (fg_total > bg_total)
844 {
845 XColor swap;
846 swap = fg;
847 fg = bg;
848 bg = swap;
849 }
850 }
851
852 /* If the fg pixel corresponds to a `0' in the bitmap, invert it.
853 (This occurs (only?) on servers with Black=0, White=1.)
854 */
855 if ((fg.pixel & 1) == 0)
856 {
857 XGCValues gcv;
858 GC gc;
859 gcv.function = GXxor;
860 gcv.foreground = 1;
861 gc = XCreateGC (dpy, pixmap, (GCFunction | GCForeground),
862 &gcv);
863 XFillRectangle (dpy, pixmap, gc, 0, 0, w, h);
864 XFreeGC (dpy, gc);
865 }
866 }
867 else
868 {
869 generate_cursor_fg_bg (device, &pointer_fg, &pointer_bg,
870 &fg, &bg);
871 IMAGE_INSTANCE_PIXMAP_FG (ii) = pointer_fg;
872 IMAGE_INSTANCE_PIXMAP_BG (ii) = pointer_bg;
873 }
874
875 IMAGE_INSTANCE_X_CURSOR (ii) =
876 XCreatePixmapCursor
877 (dpy, pixmap, mask, &fg, &bg, xhot, yhot);
878 }
879
727 /* Initialize an image instance from an XImage. 880 /* Initialize an image instance from an XImage.
728 881
729 DEST_MASK specifies the mask of allowed image types. 882 DEST_MASK specifies the mask of allowed image types.
730 883
731 PIXELS and NPIXELS specify an array of pixels that are used in 884 PIXELS and NPIXELS specify an array of pixels that are used in
738 It will be freed using xfree() when the image instance is 891 It will be freed using xfree() when the image instance is
739 destroyed. 892 destroyed.
740 893
741 If this fails, signal an error. INSTANTIATOR is only used 894 If this fails, signal an error. INSTANTIATOR is only used
742 in the error message. 895 in the error message.
743 896 */
744 #### This should be able to handle conversion into `pointer'.
745 Use the same code as for `xpm'. */
746 897
747 static void 898 static void
748 init_image_instance_from_x_image (Lisp_Image_Instance *ii, 899 init_image_instance_from_x_image (Lisp_Image_Instance *ii,
749 XImage *ximage, 900 XImage *ximage,
750 int dest_mask, 901 int dest_mask,
751 Colormap cmap, 902 Colormap cmap,
752 unsigned long *pixels, 903 unsigned long *pixels,
753 int npixels, 904 int npixels,
754 int slices, 905 int slices,
755 Lisp_Object instantiator) 906 Lisp_Object instantiator,
907 Lisp_Object pointer_fg,
908 Lisp_Object pointer_bg)
756 { 909 {
757 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 910 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
758 Display *dpy; 911 Display *dpy;
759 GC gc; 912 GC gc;
760 Drawable d; 913 Drawable d;
761 Pixmap pixmap; 914 Pixmap pixmap;
915 enum image_instance_type type;
762 916
763 if (!DEVICE_X_P (XDEVICE (device))) 917 if (!DEVICE_X_P (XDEVICE (device)))
764 gui_error ("Not an X device", device); 918 gui_error ("Not an X device", device);
765 919
766 dpy = DEVICE_X_DISPLAY (XDEVICE (device)); 920 dpy = DEVICE_X_DISPLAY (XDEVICE (device));
767 d = XtWindow(DEVICE_XT_APP_SHELL (XDEVICE (device))); 921 d = XtWindow (DEVICE_XT_APP_SHELL (XDEVICE (device)));
768 922
769 if (!(dest_mask & IMAGE_COLOR_PIXMAP_MASK)) 923 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
924 type = IMAGE_COLOR_PIXMAP;
925 else if (dest_mask & IMAGE_POINTER_MASK)
926 type = IMAGE_POINTER;
927 else
770 incompatible_image_types (instantiator, dest_mask, 928 incompatible_image_types (instantiator, dest_mask,
771 IMAGE_COLOR_PIXMAP_MASK); 929 IMAGE_COLOR_PIXMAP_MASK
930 | IMAGE_POINTER_MASK);
772 931
773 pixmap = XCreatePixmap (dpy, d, ximage->width, 932 pixmap = XCreatePixmap (dpy, d, ximage->width,
774 ximage->height, ximage->depth); 933 ximage->height, ximage->depth);
775 if (!pixmap) 934 if (!pixmap)
776 gui_error ("Unable to create pixmap", instantiator); 935 gui_error ("Unable to create pixmap", instantiator);
800 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = ximage->height; 959 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = ximage->height;
801 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = ximage->depth; 960 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = ximage->depth;
802 IMAGE_INSTANCE_X_COLORMAP (ii) = cmap; 961 IMAGE_INSTANCE_X_COLORMAP (ii) = cmap;
803 IMAGE_INSTANCE_X_PIXELS (ii) = pixels; 962 IMAGE_INSTANCE_X_PIXELS (ii) = pixels;
804 IMAGE_INSTANCE_X_NPIXELS (ii) = npixels; 963 IMAGE_INSTANCE_X_NPIXELS (ii) = npixels;
964
965 if (type == IMAGE_POINTER)
966 image_instance_convert_to_pointer (ii, instantiator, pointer_fg,
967 pointer_bg);
805 } 968 }
806 969
807 static void 970 static void
808 image_instance_add_x_image (Lisp_Image_Instance *ii, 971 image_instance_add_x_image (Lisp_Image_Instance *ii,
809 XImage *ximage, 972 XImage *ximage,
844 int width, int height, 1007 int width, int height,
845 int slices, 1008 int slices,
846 Binbyte *eimage, 1009 Binbyte *eimage,
847 int dest_mask, 1010 int dest_mask,
848 Lisp_Object instantiator, 1011 Lisp_Object instantiator,
1012 Lisp_Object pointer_fg,
1013 Lisp_Object pointer_bg,
849 Lisp_Object UNUSED (domain)) 1014 Lisp_Object UNUSED (domain))
850 { 1015 {
851 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 1016 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
852 Colormap cmap = DEVICE_X_COLORMAP (XDEVICE(device)); 1017 Colormap cmap = DEVICE_X_COLORMAP (XDEVICE(device));
853 unsigned long *pixtbl = NULL; 1018 unsigned long *pixtbl = NULL;
862 &pixtbl, &npixels); 1027 &pixtbl, &npixels);
863 if (!ximage) 1028 if (!ximage)
864 { 1029 {
865 if (pixtbl) 1030 if (pixtbl)
866 xfree (pixtbl, unsigned long *); 1031 xfree (pixtbl, unsigned long *);
867 signal_image_error("EImage to XImage conversion failed", instantiator); 1032 signal_image_error ("EImage to XImage conversion failed",
1033 instantiator);
868 } 1034 }
869 1035
870 /* Now create the pixmap and set up the image instance */ 1036 /* Now create the pixmap and set up the image instance */
871 if (slice == 0) 1037 if (slice == 0)
872 init_image_instance_from_x_image (ii, ximage, dest_mask, 1038 init_image_instance_from_x_image (ii, ximage, dest_mask,
873 cmap, pixtbl, npixels, slices, 1039 cmap, pixtbl, npixels, slices,
874 instantiator); 1040 instantiator, pointer_fg,
1041 pointer_bg);
875 else 1042 else
876 image_instance_add_x_image (ii, ximage, slice, instantiator); 1043 image_instance_add_x_image (ii, ximage, slice, instantiator);
877 1044
878 if (ximage) 1045 if (ximage)
879 { 1046 {
1234 #if 1 1401 #if 1
1235 /* Although I haven't found it documented yet, it appears that pointers are 1402 /* Although I haven't found it documented yet, it appears that pointers are
1236 always colored via the default window colormap... Sigh. */ 1403 always colored via the default window colormap... Sigh. */
1237 if (type == IMAGE_POINTER) 1404 if (type == IMAGE_POINTER)
1238 { 1405 {
1239 cmap = DefaultColormap(dpy, DefaultScreen(dpy)); 1406 cmap = DefaultColormap (dpy, DefaultScreen (dpy));
1240 depth = DefaultDepthOfScreen (xs); 1407 depth = DefaultDepthOfScreen (xs);
1241 visual = DefaultVisualOfScreen (xs); 1408 visual = DefaultVisualOfScreen (xs);
1242 } 1409 }
1243 else 1410 else
1244 { 1411 {
1245 cmap = DEVICE_X_COLORMAP (XDEVICE(device)); 1412 cmap = DEVICE_X_COLORMAP (XDEVICE (device));
1246 depth = DEVICE_X_DEPTH (XDEVICE(device)); 1413 depth = DEVICE_X_DEPTH (XDEVICE (device));
1247 visual = DEVICE_X_VISUAL (XDEVICE(device)); 1414 visual = DEVICE_X_VISUAL (XDEVICE (device));
1248 } 1415 }
1249 #else 1416 #else
1250 cmap = DEVICE_X_COLORMAP (XDEVICE(device)); 1417 cmap = DEVICE_X_COLORMAP (XDEVICE (device));
1251 depth = DEVICE_X_DEPTH (XDEVICE(device)); 1418 depth = DEVICE_X_DEPTH (XDEVICE (device));
1252 visual = DEVICE_X_VISUAL (XDEVICE(device)); 1419 visual = DEVICE_X_VISUAL (XDEVICE (device));
1253 #endif 1420 #endif
1254 1421
1255 x_initialize_pixmap_image_instance (ii, 1, type); 1422 x_initialize_pixmap_image_instance (ii, 1, type);
1256 1423
1257 assert (!NILP (data)); 1424 assert (!NILP (data));
1380 { 1547 {
1381 case IMAGE_MONO_PIXMAP: 1548 case IMAGE_MONO_PIXMAP:
1382 break; 1549 break;
1383 1550
1384 case IMAGE_COLOR_PIXMAP: 1551 case IMAGE_COLOR_PIXMAP:
1385 { 1552 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = depth;
1386 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = depth;
1387 }
1388 break; 1553 break;
1389 1554
1390 case IMAGE_POINTER: 1555 case IMAGE_POINTER:
1391 { 1556 if (xpmattrs.valuemask & XpmHotspot)
1392 int npixels = xpmattrs.npixels; 1557 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = make_int (xpmattrs.x_hotspot);
1393 Pixel *pixels = xpmattrs.pixels; 1558 if (xpmattrs.valuemask & XpmHotspot)
1394 XColor fg, bg; 1559 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = make_int (xpmattrs.y_hotspot);
1395 int i; 1560
1396 int xhot = 0, yhot = 0; 1561 image_instance_convert_to_pointer (ii, instantiator, pointer_fg,
1397 1562 pointer_bg);
1398 if (xpmattrs.valuemask & XpmHotspot)
1399 {
1400 xhot = xpmattrs.x_hotspot;
1401 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = make_int (xpmattrs.x_hotspot);
1402 }
1403 if (xpmattrs.valuemask & XpmHotspot)
1404 {
1405 yhot = xpmattrs.y_hotspot;
1406 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = make_int (xpmattrs.y_hotspot);
1407 }
1408 check_pointer_sizes (xs, w, h, instantiator);
1409
1410 /* If the loaded pixmap has colors allocated (meaning it came from an
1411 XPM file), then use those as the default colors for the cursor we
1412 create. Otherwise, default to pointer_fg and pointer_bg.
1413 */
1414 if (npixels >= 2)
1415 {
1416 /* With an XBM file, it's obvious which bit is foreground
1417 and which is background, or rather, it's implicit: in
1418 an XBM file, a 1 bit is foreground, and a 0 bit is
1419 background.
1420
1421 XCreatePixmapCursor() assumes this property of the
1422 pixmap it is called with as well; the `foreground'
1423 color argument is used for the 1 bits.
1424
1425 With an XPM file, it's tricker, since the elements of
1426 the pixmap don't represent FG and BG, but are actual
1427 pixel values. So we need to figure out which of those
1428 pixels is the foreground color and which is the
1429 background. We do it by comparing RGB and assuming
1430 that the darker color is the foreground. This works
1431 with the result of xbmtopbm|ppmtoxpm, at least.
1432
1433 It might be nice if there was some way to tag the
1434 colors in the XPM file with whether they are the
1435 foreground - perhaps with logical color names somehow?
1436
1437 Once we have decided which color is the foreground, we
1438 need to ensure that that color corresponds to a `1' bit
1439 in the Pixmap. The XPM library wrote into the (1-bit)
1440 pixmap with XPutPixel, which will ignore all but the
1441 least significant bit.
1442
1443 This means that a 1 bit in the image corresponds to
1444 `fg' only if `fg.pixel' is odd.
1445
1446 (This also means that the image will be all the same
1447 color if both `fg' and `bg' are odd or even, but we can
1448 safely assume that that won't happen if the XPM file is
1449 sensible I think.)
1450
1451 The desired result is that the image use `1' to
1452 represent the foreground color, and `0' to represent
1453 the background color. So, we may need to invert the
1454 image to accomplish this; we invert if fg is
1455 odd. (Remember that WhitePixel and BlackPixel are not
1456 necessarily 1 and 0 respectively, though I think it
1457 might be safe to assume that one of them is always 1
1458 and the other is always 0. We also pretty much need to
1459 assume that one is even and the other is odd.)
1460 */
1461
1462 fg.pixel = pixels[0]; /* pick a pixel at random. */
1463 bg.pixel = fg.pixel;
1464 for (i = 1; i < npixels; i++) /* Look for an "other" pixel value.*/
1465 {
1466 bg.pixel = pixels[i];
1467 if (fg.pixel != bg.pixel)
1468 break;
1469 }
1470
1471 /* If (fg.pixel == bg.pixel) then probably something has
1472 gone wrong, but I don't think signalling an error would
1473 be appropriate. */
1474
1475 XQueryColor (dpy, cmap, &fg);
1476 XQueryColor (dpy, cmap, &bg);
1477
1478 /* If the foreground is lighter than the background, swap them.
1479 (This occurs semi-randomly, depending on the ordering of the
1480 color list in the XPM file.)
1481 */
1482 {
1483 unsigned short fg_total = ((fg.red / 3) + (fg.green / 3)
1484 + (fg.blue / 3));
1485 unsigned short bg_total = ((bg.red / 3) + (bg.green / 3)
1486 + (bg.blue / 3));
1487 if (fg_total > bg_total)
1488 {
1489 XColor swap;
1490 swap = fg;
1491 fg = bg;
1492 bg = swap;
1493 }
1494 }
1495
1496 /* If the fg pixel corresponds to a `0' in the bitmap, invert it.
1497 (This occurs (only?) on servers with Black=0, White=1.)
1498 */
1499 if ((fg.pixel & 1) == 0)
1500 {
1501 XGCValues gcv;
1502 GC gc;
1503 gcv.function = GXxor;
1504 gcv.foreground = 1;
1505 gc = XCreateGC (dpy, pixmap, (GCFunction | GCForeground),
1506 &gcv);
1507 XFillRectangle (dpy, pixmap, gc, 0, 0, w, h);
1508 XFreeGC (dpy, gc);
1509 }
1510 }
1511 else
1512 {
1513 generate_cursor_fg_bg (device, &pointer_fg, &pointer_bg,
1514 &fg, &bg);
1515 IMAGE_INSTANCE_PIXMAP_FG (ii) = pointer_fg;
1516 IMAGE_INSTANCE_PIXMAP_BG (ii) = pointer_bg;
1517 }
1518
1519 IMAGE_INSTANCE_X_CURSOR (ii) =
1520 XCreatePixmapCursor
1521 (dpy, pixmap, mask, &fg, &bg, xhot, yhot);
1522 }
1523
1524 break; 1563 break;
1525 1564
1526 default: 1565 default:
1527 ABORT (); 1566 ABORT ();
1528 } 1567 }
1984 2023
1985 { 2024 {
1986 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (IMAGE_INSTANCE_DEVICE (p))); 2025 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (IMAGE_INSTANCE_DEVICE (p)));
1987 Drawable draw = XtWindow(DEVICE_XT_APP_SHELL (XDEVICE (IMAGE_INSTANCE_DEVICE (p)))); 2026 Drawable draw = XtWindow(DEVICE_XT_APP_SHELL (XDEVICE (IMAGE_INSTANCE_DEVICE (p))));
1988 Dimension d = DEVICE_X_DEPTH (XDEVICE (IMAGE_INSTANCE_DEVICE (p))); 2027 Dimension d = DEVICE_X_DEPTH (XDEVICE (IMAGE_INSTANCE_DEVICE (p)));
1989 Pixmap new = XCreatePixmap (dpy, draw, 2028 Pixmap new_ = XCreatePixmap (dpy, draw,
1990 IMAGE_INSTANCE_PIXMAP_WIDTH (p), 2029 IMAGE_INSTANCE_PIXMAP_WIDTH (p),
1991 IMAGE_INSTANCE_PIXMAP_HEIGHT (p), d); 2030 IMAGE_INSTANCE_PIXMAP_HEIGHT (p), d);
1992 XColor color; 2031 XColor color;
1993 XGCValues gcv; 2032 XGCValues gcv;
1994 GC gc; 2033 GC gc;
1995 color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (foreground)); 2034 color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (foreground));
1996 gcv.foreground = color.pixel; 2035 gcv.foreground = color.pixel;
1997 color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (background)); 2036 color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (background));
1998 gcv.background = color.pixel; 2037 gcv.background = color.pixel;
1999 gc = XCreateGC (dpy, new, GCBackground|GCForeground, &gcv); 2038 gc = XCreateGC (dpy, new_, GCBackground|GCForeground, &gcv);
2000 XCopyPlane (dpy, IMAGE_INSTANCE_X_PIXMAP (p), new, gc, 0, 0, 2039 XCopyPlane (dpy, IMAGE_INSTANCE_X_PIXMAP (p), new_, gc, 0, 0,
2001 IMAGE_INSTANCE_PIXMAP_WIDTH (p), 2040 IMAGE_INSTANCE_PIXMAP_WIDTH (p),
2002 IMAGE_INSTANCE_PIXMAP_HEIGHT (p), 2041 IMAGE_INSTANCE_PIXMAP_HEIGHT (p),
2003 0, 0, 1); 2042 0, 0, 1);
2004 XFreeGC (dpy, gc); 2043 XFreeGC (dpy, gc);
2005 IMAGE_INSTANCE_X_PIXMAP (p) = new; 2044 IMAGE_INSTANCE_X_PIXMAP (p) = new_;
2006 IMAGE_INSTANCE_PIXMAP_DEPTH (p) = d; 2045 IMAGE_INSTANCE_PIXMAP_DEPTH (p) = d;
2007 IMAGE_INSTANCE_PIXMAP_FG (p) = foreground; 2046 IMAGE_INSTANCE_PIXMAP_FG (p) = foreground;
2008 IMAGE_INSTANCE_PIXMAP_BG (p) = background; 2047 IMAGE_INSTANCE_PIXMAP_BG (p) = background;
2009 return 1; 2048 return 1;
2010 } 2049 }