Path: utzoo!utgpu!attcan!uunet!lll-winken!csd4.milw.wisc.edu!dogie.macc.wisc.edu!uwvax!romano.cs.wisc.edu!dave From: dave@romano.cs.wisc.edu (Dave Cohrs) Newsgroups: comp.windows.x Subject: bug in XCopyArea() of X11R3 Xsun server Keywords: X11R3, Xsun, bw2 Message-ID: <7438@spool.cs.wisc.edu> Date: 21 Apr 89 20:19:43 GMT Sender: news@spool.cs.wisc.edu Reply-To: dave@romano.cs.wisc.edu (Dave Cohrs) Organization: U of Wisconsin CS Dept Lines: 192 Environment: Sun4/110 SunOS 4.0.1 bw2 monitor (1 bit display) X11R3 w/-DPURDUE speedups (compiled with cc) Description: XCopyArea() in the above environment fails when copying a pixmap on top of itself, when the destination is a positive multiple of 32 bits *to the right* of the source. Repeat-By: compile the following program: cc -o test test.c -lX11 and run it. With no args, it copies the pixmap 64 bits to the right on each mouse click. On a broken implementation, this causes every other 32 bit group to be copied backward over the bits already copied. With a single numeric ARG, it copies the pixmap ARG bits to the right on each click. It works fine for all values when ARG%32 != 0, or whenever ARG is negative. Any hints??? Is this a bug in the -DPURDUE code, or something else? ------------------------------------Cut Here-------------------------------- #include #include #include #include #include #define spool_width 48 #define spool_height 48 static char spool_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x80, 0x07, 0xc0, 0x03, 0x00, 0x00, 0x70, 0x80, 0x07, 0x1c, 0x00, 0x00, 0x0c, 0xf0, 0x3f, 0x60, 0x00, 0x00, 0x02, 0xf8, 0x7f, 0x80, 0x00, 0x00, 0x02, 0xf0, 0x3f, 0x80, 0x00, 0x00, 0x0e, 0x80, 0x07, 0xe0, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x7c, 0x00, 0x00, 0xf0, 0x07, 0xc0, 0x1f, 0x00, 0x00, 0x80, 0xff, 0xff, 0x03, 0x00, 0x00, 0x70, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0xd0, 0xff, 0x40, 0x00, 0x00, 0x00, 0x1c, 0x04, 0xff, 0x00, 0x00, 0x00, 0x0f, 0xfe, 0x40, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x40, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x40, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x40, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x40, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x40, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0x70, 0x00, 0x00, 0x00, 0xfe, 0x40, 0x08, 0x00, 0x00, 0x80, 0x07, 0xff, 0x0b, 0x00, 0x00, 0x70, 0xfe, 0x40, 0x1c, 0x00, 0x00, 0x0c, 0x04, 0xff, 0x6e, 0x00, 0x00, 0x02, 0xfe, 0x40, 0x82, 0x00, 0x00, 0x02, 0x0c, 0xff, 0x83, 0x00, 0x00, 0x0e, 0x30, 0x18, 0xe0, 0x00, 0x00, 0x7c, 0xc0, 0x07, 0x7c, 0x00, 0x00, 0xf0, 0x07, 0xc0, 0x1f, 0x00, 0x00, 0x80, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; GC gc; Window show_window; Pixmap pixmap; Pixmap spool_pixmap; Pixmap bg_pixmap; Display *display; Window root; int screen; unsigned long fg, bg; int border_wid = 2; XGCValues gcv; XSetWindowAttributes attrs; XSizeHints hints; XEvent event; main(argc, argv) int argc; char *argv[]; { int bg_width = 64; int i, j; unsigned short buf[256] ; /* For background pattern. */ int movewid = 64; if(argc > 1 && (i = atoi(argv[1])) != 0) movewid = i; /* initialization */ if (!(display = XOpenDisplay(NULL))) { fprintf(stderr, "unable to open display\n"); exit (1); } screen = DefaultScreen(display); root = RootWindow(display, screen); bg = WhitePixel (display, screen); fg = BlackPixel (display, screen); /* allocate pixmaps: pixmap is the "backing store" spool_pixmap holds the picture bg_pixmap holds a gray pattern */ pixmap = XCreatePixmap(display, root, bg_width*4, spool_height, DefaultDepth(display, screen)); spool_pixmap = XCreatePixmapFromBitmapData(display, root, spool_bits, spool_width, spool_height, fg, bg, DefaultDepth(display, screen)); for (i = 0; i < 16; i++) { /* Load default gray background. */ for (j = 0; j < 4; j++) buf[i*16+j] = 0x7777 ; for (j = 0; j < 4; j++) buf[i*16+4+j] = 0xdddd ; for (j = 0; j < 4; j++) buf[i*16+8+j] = 0xbbbb ; for (j = 0; j < 4; j++) buf[i*16+12+j] = 0xeeee ; } bg_pixmap = XCreatePixmapFromBitmapData(display, root, buf, 64, 64, fg, bg, DefaultDepth(display, screen)); /* finish initialization */ gcv.function = GXcopy; gcv.background = bg; gcv.foreground = fg; gcv.graphics_exposures = False; gc = XCreateGC(display, root, GCFunction | GCForeground | GCBackground | GCGraphicsExposures, &gcv); hints.x = 0; hints.y = 0; hints.width = bg_width*4; hints.height = spool_height; hints.min_width = bg_width*4; hints.min_height = spool_height; hints.flags = PMinSize|PSize; attrs.background_pixel = bg; attrs.border_pixel = fg; attrs.cursor = XCreateFontCursor(display, XC_top_left_arrow); /* create a window big enough to hold 4 copies of spool_bits (plus slop) */ show_window = XCreateWindow( display, root, hints.x, hints.y, hints.width, hints.height, border_wid, CopyFromParent, CopyFromParent, CopyFromParent, CWBorderPixel | CWBackPixel | CWCursor, &attrs); XSetStandardProperties (display, show_window, "test", "test", None, argv, argc, &hints); XSelectInput(display, show_window, ExposureMask|ButtonPressMask); XMapWindow(display, show_window); /* initially fill the window */ for(i=0; i<4; i++) XCopyArea(display, bg_pixmap, pixmap, gc, 0, 0, bg_width, spool_height, bg_width*i, 0); /* process events: expose: copy backing store to screen buttonPress: move pixmap 64bits right, copy a new spool into leftmost position, then expose the pixmap */ for(;;) { XNextEvent(display, &event); if (event.type == Expose) { refresh: XCopyArea(display, pixmap, show_window, gc, 0, 0, bg_width*4, spool_height, 0, 0); XFlush(display); } else if (event.type == ButtonPress) { if(movewid > 0) { XCopyArea(display, pixmap, pixmap, gc, 0, 0, bg_width*4-movewid, spool_height, movewid, 0) ; XCopyArea(display, spool_pixmap, pixmap, gc, 0, 0, movewid, spool_height, 0, 0) ; } else { XCopyArea(display, pixmap, pixmap, gc, -movewid, 0, bg_width*4+movewid, spool_height, 0, 0) ; XCopyArea(display, spool_pixmap, pixmap, gc, 0, 0, -movewid, spool_height, bg_width*4+movewid, 0) ; } goto refresh; } } } -- Dave Cohrs +1 608 262-6617 UW-Madison Computer Sciences Department dave@cs.wisc.edu ...!{harvard,rutgers,ucbvax}!uwvax!dave