jef@well.sf.ca.us (Jef Poskanzer) (06/22/91)
I've got this program which works fine on monochrome screens, but when I try running it on a PseudoColor screen I get BadMatch errors from innocuous calls like XDrawPoint and XFillRectangle. So I was just wondering if anyone has any tricks for finding out what the server thinks doesn't match. I suppose I could run the server in a debugger, but that's a hassle. More details: I'm drawing to an off-screen Pixmap created with XCreatePixmapFromBitmapData( display, root, data, width, height, 1L, 0L, 1 ). The GC's I use have foreground and background set to 1L and 0L, and planemask set to 1L. --- Jef Jef Poskanzer jef@well.sf.ca.us {apple, ucbvax, hplabs}!well!jef "The chain which can be yanked is not the eternal chain." -- G. Fitch
mouse@lightning.mcrcim.mcgill.EDU (der Mouse) (06/22/91)
> I've got this program which works fine on monochrome screens, but > when I try running it on a PseudoColor screen I get BadMatch errors > from innocuous calls like XDrawPoint and XFillRectangle. So I was > just wondering if anyone has any tricks for finding out what the > server thinks doesn't match. I suppose I could run the server in a > debugger, but that's a hassle. Run it under xscope, that's what I find is generally best. That way you can see precisely what requests are being sent.... > More details: I'm drawing to an off-screen Pixmap created with > XCreatePixmapFromBitmapData(display,root,data,width,height,1L,0L,1). > The GC's I use have foreground and background set to 1L and 0L, and > planemask set to 1L. Aha. I bet the GC was created with a depth equal to the default depth of the screen, and you're trying to use it with a pixmap that's always of depth 1. (Also, with those arguments, XCreatePixmapFromBitmapData is overkill; just use XCreateBitmapFromData instead.) der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu
klee@wsl.dec.com (Ken Lee) (06/24/91)
In article <25584@well.sf.ca.us>, jef@well.sf.ca.us (Jef Poskanzer) writes: |> I've got this program which works fine on monochrome screens, but |> when I try running it on a PseudoColor screen I get BadMatch errors |> from innocuous calls like XDrawPoint and XFillRectangle. So I was |> just wondering if anyone has any tricks for finding out what the |> server thinks doesn't match. I suppose I could run the server in |> a debugger, but that's a hassle. |> |> More details: I'm drawing to an off-screen Pixmap created with |> XCreatePixmapFromBitmapData( display, root, data, width, height, 1L, 0L, 1 ). |> The GC's I use have foreground and background set to 1L and 0L, and |> planemask set to 1L. Sounds like you've got depth mis-match problems. Are you GCs created with the same depth as the target drawable? See "Error 14" in the paper "Behind Curtain X" in this month's *UNIX Review* magazine :-) -- Ken Lee DEC Western Software Laboratory, Palo Alto, Calif. Internet: klee@wsl.dec.com uucp: uunet!decwrl!klee
hill@luke.lanl.GOV (Jeff Hill) (06/25/91)
>> I've got this program which works fine on monochrome screens, but >> when I try running it on a PseudoColor screen I get BadMatch errors >> from innocuous calls like XDrawPoint and XFillRectangle. So I was >> just wondering if anyone has any tricks for finding out what the >> server thinks doesn't match. I suppose I could run the server in a >> debugger, but that's a hassle. > >Run it under xscope, that's what I find is generally best. That way >you can see precisely what requests are being sent.... Another (perhaps easier) way to track down what call caused the bad match is to use XSynchronize(). Many X applications and most Xt applications have this as a command line option. This works even better if you have installed your own X exception handler which dumps core. You can then investigate the cause from a debugger (the default X exception handler calls exit() leaving no trace of what happened). Jeff PS: An example code follows: #include <Xlib.h> main() { /* * install an error handler that makes a core file when * an X Error occurs. This can be usefull if XSync is on. * */ XSetErrorHandler(opi_x_error_handler); } /* * * X Error Handler * (with core dump) * */ int x_error_handler(d, pev) Display *d; XErrorEvent *pev; { char message[256]; XGetErrorText(d, pev->error_code, message, sizeof(message)); printf("Sorry a fatal X Window System error has occured\n"); printf("\tThe cause: %s\n", message); printf("\tResource Id. %x\n", pev->resourceid); printf("Core Dumped\n"); abort(); }
jef@well.sf.ca.us (Jef Poskanzer) (06/25/91)
In the referenced message, klee@wsl.dec.com wrote: }Sounds like you've got depth mis-match problems. Are you GCs created }with the same depth as the target drawable? Yes, that's the consensus. Apparently GC's have depth as an invisible attribute. You can't query it, you can't change it, it's only documented in the protocol spec, but if it doesn't match your program aborts. God I love X. I'll try this fix next time I'm in front of a color screen. On the broader question of how to figure out what the server is complaining about in cases like this, I have received one suggestion to use xscope. I tried it, it doesn't work, and I don't see how it would help anyway since I already know what X request is failing. --- Jef Jef Poskanzer jef@well.sf.ca.us {apple, ucbvax, hplabs}!well!jef "Youth doesn't excuse everything." -- Dr. Janice Lester
converse@expo.lcs.mit.EDU (Donna Converse) (06/25/91)
> Apparently GC's have depth as an invisible > attribute. You can't query it, you can't change it, it's only documented > in the protocol spec, but if it doesn't match your program aborts. Come on, get a good reference manual. You couldn't be using the Xlib reference manual of Scheifler and Gettys "X Window System", or you wouldn't be so frustrated. The description of the XCreateGC interface makes it clear that using a GC with a drawable of different depth results in a BadMatch error.
mouse@lightning.mcrcim.mcgill.EDU (der Mouse) (06/26/91)
> Apparently GC's have depth as an invisible attribute. You can't > query it, you can't change it, it's only documented in the protocol > spec, but if it doesn't match your program aborts. The Xlib manual states: GC XCreateGC(display, d, valuemask, values) Display *display; Drawable d; unsigned long valuemask; XGCValues *values; display Specifies the connection to the X server. d Specifies the drawable. [descriptions of valuemask and values deleted] The XCreateGC function creates a graphics context and returns a GC. The GC can be used with any destination drawable having the same root and depth as the specified drawable. Use with other drawables results in a BadMatch error. Is that explicit enough for you? der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu
jef@well.sf.ca.us (Jef Poskanzer) (06/26/91)
Yep, segregating the GC's fixed the problem. Cool, now xpaint works on color screens, although it still only edits b&w bitmaps. Undo works now too. In case you missed the previous mention, xpaint is a a bitmap editor similar in functionality to bitmap(1), but with radically improved performance. You can fetch it from ftp.ee.lbl.gov, xpaint.tar.Z. It's got lots of rough edges, but even so it is preferable in every respect to bitmap. I'd be interested in a comparison with the R5 version of bitmap, if that doesn't violate any rules. --- Jef Jef Poskanzer jef@well.sf.ca.us {apple, ucbvax, hplabs}!well!jef "Conceptual integrity in turn dictates that the design must proceed from one mind, or from a very small number of agreeing resonant minds." -- Frederick Brooks Jr., "The Mythical Man Month"