pattersw@cs.rpi.edu (William Patterson) (07/10/90)
twm seems to be intercepting XDraw... calls on my sparc. I've created a single window, created a GC for it, and called XDrawRectangle. If the window attribute override_redirect is set to true, the window appears and the rectangle is drawn. If override_redirect is set to false, twm draws an outline of the window, waits for me to place it, and then maps the window. The rectangle, however, never appears. Anybody know why this is happening? ------------------- relevant code --------------------------- Code to create window: XSetWindowAttributes theWindowAttributes; XSizeHints theSizeHints; unsigned long theWindowMask; Window theNewWindow; XWMHints theWMHints; theWindowAttributes.border_pixel = theBlackPixel; theWindowAttributes.background_pixel = theWhitePixel; theWindowAttributes.override_redirect = True; theWindowMask = CWBackPixel | CWBorderPixel | CWOverrideRedirect; theNewWindow = XCreateWindow(display, RootWindow(display, screen), x, y, width, height, BORDER_WIDTH, depth, InputOutput, CopyFromParent, theWindowMask, &theWindowAttributes); <...set size hints parameters...> XSetNormalHints ( display, theNewWindow, &theSizeHints); Code to draw rectangle: theGC = createGC( window ); XDrawRectangle( display, window, theGC, 5, 5, 50, 50 ); XFlush(display); Code to create GC: theGCValues.foreground = theBlackPixel; theGCValues.background = theWhitePixel; theGCValues.line_width = 2; GCmask = GCForeground | GCBackground | GCLineWidth; theGC = XCreateGC( display, window, GCmask, &theGCValues ); MAIN: window = openWindow (0,0, 200, 200); XMapWindow( display, window); XFlush( display); draw (window); XFlush(display); XDestroyWindow( display, window); ------------------------ END -------------------------- Email, please. I'll sumarize if other people are having the same problem (or soln isn`t obvious). Bill Patterson pattersw@turing.cs.rpi.edu -- ----------------------------------- Bill Patterson pattersw@turing.cs.rpi.edu Computer Science Department Rensselaer Polytechnic Institute Troy, NY. -----------------------------------
ekberg@ti-csl.csc.ti.COM (07/10/90)
This looks like the common problem one encounters when running X. If one tries to draw something after the window is created and mapped, it most likely will get thrown away. The correct thing to do is, after the mapwindow request, to wait for the expose event from the server. It is only after the initial expose event that drawing can be done. This probably explains why you are not seeing the rectangle being drawn. If you single-step it in the debugger, it will probably work since the expose event will be sent before you perform the drawing operation. -- tom (aisle C-4Q), ekberg@csc.ti.com