[comp.windows.x] XCopyPlane bug?

grady@fxgrp (Steven Grady) (09/29/88)

I've come across a bug (I believe) in XV11R2 (running on Ultrix 2.2
on a VAXStation II/GPX).  The following code creates two windows
(not following any of the standard ICC, sorry), each 16x16.
In each it draws a bitmap of 3 concentric circles, or at
least is supposed to.  In the first window, it uses XCopyPlane()
to copy the image directly from a bitmap to a window (depth 8).
In the second window, it uses XCopyPlane() to copy to a depth 8
pixmap, then uses XCopyArea() to draw the image in the window.
The 2nd method works, but the first draw something strange,
which appears to be the upper left of the image in a random
color, expanded to fill the window.  Am I doing something wrong?
Is this a bug in the server?

	Steven
	...!ucbvax!grady
	grady@postgres.berkeley.edu

#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

/* three concentric circles */
#define bar_width 16
#define bar_height 16
static char bar_bits[] = {
   0xe0, 0x03, 0x18, 0x0c, 0x04, 0x10, 0xe2, 0x23, 0x12, 0x24, 0x09, 0x48,
   0xc9, 0x49, 0x49, 0x49, 0xc9, 0x49, 0x09, 0x48, 0x12, 0x24, 0xe2, 0x23,
   0x04, 0x10, 0x18, 0x0c, 0xe0, 0x03, 0x00, 0x00};

main()
{
    Display *dpy;
    Window root,  w1, w2;
    unsigned long scr;
    Pixmap bm;
    unsigned long bl, wh;
    XColor col;
    Colormap cmap;
    unsigned long xgcvMask;
    XGCValues xgcv;
    GC gc;
    XEvent ev;
    int x_hot, y_hot;
    Pixmap pm;

    dpy = XOpenDisplay(NULL);
    root = RootWindow(dpy, scr);
    cmap = DefaultColormap(dpy, scr);
    bl = BlackPixel(dpy, scr);
    wh = WhitePixel(dpy, scr);

    if (!XAllocNamedColor(dpy, cmap, "red", &col, &col)) {
	printf("Couldn't allocate red pixel\n");
	exit(1);
    }

    bm = XCreateBitmapFromData(dpy, root, bar_bits, bar_width, bar_height);
    w1 = XCreateSimpleWindow(dpy, root, 0, 0, bar_width, bar_height,
	    1, bl, wh);

    w2 = XCreateSimpleWindow(dpy, root, 0, 0, bar_width, bar_height,
	    1, bl, wh);

    XSelectInput(dpy, w1, ExposureMask);
    XSelectInput(dpy, w2, ExposureMask);

    printf("Mapping window 1\n");
    XMapWindow(dpy, w1);
    /* wait for the mapping by waiting for the expose */
    XNextEvent(dpy, &ev);

    printf("Mapping window 2\n");
    XMapWindow(dpy, w2);
    /* ditto */
    XNextEvent(dpy, &ev);

    xgcvMask = GCForeground | GCBackground;
    xgcv.foreground = col.pixel;
    xgcv.background = wh;
    gc = XCreateGC(dpy, w1, xgcvMask, &xgcv);

    pm = XCreatePixmap(dpy, root, bar_width, bar_height, 
	    DefaultDepth(dpy, scr));
    XCopyPlane(dpy, bm, w1, gc, 0, 0, bar_width, bar_height, 0, 0, 
	    (unsigned long) 1);

    XCopyPlane(dpy, bm, pm, gc, 0, 0, bar_width, bar_height, 0, 0, 
	    (unsigned long) 1);
    
    XCopyArea(dpy, pm, w2, gc, 0, 0, bar_width, bar_height, 0, 0);

    XFlush(dpy);
    pause();
}

RWS@ZERMATT.LCS.MIT.EDU (Robert Scheifler) (09/30/88)

CopyPlane basically does not work in the R2 QDSS server.
At this point it's unlikely to work in the R3 server.
There are a number of serious bugs in the QDSS server,
but we at MIT don't have the resources to fix them.
If there are QDSS hackers out there willing to lend a
hand, we'd welcome the help.