From: s8923098@macnab.mqcs.mq.oz.au (Josef WIDJAJA)
Subject: HELP! XSetWindowAttributes and XSetWMHints
Summary: problems with override_redirect field of XSetWindowAttributes 
Organization: Macquarie University, School of Mathematics, Physics, Computing and Electronics
Date: Fri, 4 Sep 1992 01:56:32 GMT


I am a novice trying to do some simple X Window programming.

I am trying to put an image (using XPutImage) or a drawing
(eg. using XFillRectangle) into a Window. So far, the image/
drawing can be displayed if I set the override_redirect field
in the XSetWindowAttributes structure for my window to True.
When this is set to True, however, the Window Manager cannot
put decorations and borders around that window. 

When I set the override_redirect to False, which means that the 
Window Manager can now sorround the window with borders and 
decorations, the image/drawing is not displayed.

Is there an Xpert out there who can give me some leads as to 
why this is so? I have been trying to find out the reason why
this happens in various books and am still puzzled.

The following is the routine I use to open a Window and send 
hints to the Window Manager. I copied it from a book.

Thanks in advance.
-------------------------------------------------------
Window
openWindow( x, y, width, height, flag, theNewGC)

int    x, y;
int    width, height;
int    flag;
GC     *theNewGC;

{
    XSetWindowAttributes   theWindowAttributes;
    XSizeHints             theSizeHints;
    unsigned   long        theWindowMask;
    Window                 theNewWindow;
    Pixmap                 theIconPixmap;
    XWMHints               theWMHints;


    theWindowAttributes.border_pixel =
                BlackPixel( theDisplay, theScreen);
    theWindowAttributes.background_pixel = 
                WhitePixel(theDisplay, theScreen);
    theWindowAttributes.override_redirect = False; /* or True */

    theWindowMask = CWBackPixel | CWBorderPixel | CWOverrideRedirect;

   /*
    **  Open  a window on the display
    */
    theNewWindow = XCreateWindow( theDisplay,
                       RootWindow (theDisplay, theScreen),
                       x, y,
                       width, height,
                       BORDER_WIDTH,
                       theDepth,
                       InputOutput,
                       CopyFromParent,
                       theWindowMask,
                       &theWindowAttributes );
   /*
   ** set up icon for window
   */
    theIconPixmap = XCreateBitmapFromData (theDisplay,
                          theNewWindow,
                          theIcon_bits,
                          theIcon_width,
                          theIcon_height );
    /*
    ** Sending "Hints" to the Window Manager
    */
    theWMHints.icon_pixmap  = theIconPixmap;
    theWMHints.initial_state = NormalState;
    theWMHints.flags = IconPixmapHint|StateHint;

    XSetWMHints(theDisplay, theNewWindow, &theWMHints);

    /*
    ** tell the window manager about the size and location
    */
    theSizeHints.flags = PPosition |PSize;
    theSizeHints.x = x;
    theSizeHints.y = y;
    theSizeHints.width = width;
    theSizeHints.height = height;

    XSetNormalHints( theDisplay, theNewWindow, &theSizeHints);

    /*
    **   Create a graphics Context
    **   createGC is my own routine
    */
    if (createGC(theNewWindow, theNewGC) == 0)
      { XDestroyWindow(theDisplay, theNewWindow);
        return (Window) 0;
      }

    /*
    **    Ask X to place Window visible on screen
    */
    XMapWindow(theDisplay, theNewWindow);
    XFlush(theDisplay);
    return (theNewWindow);
}
------------------------------------------------------------------


--
 _________Josef Widjaja____________  
|  s8923098@mackay.mpce.mq.edu.au  |
|  Macquarie University, Australia | 
|__________________________________| 
Newsgroups: comp.windows.x