[comp.windows.x] bug?

net@TUB.BITNET (Oliver Laumann) (05/30/88)

Maybe I'm just dumb today, but it seems the result returned by
XGetWindowAttributes() is not deterministic.

The small program attached to this letter demonstrates the problem.
After having invoked the program under uwm, I position the window
to a non-zero x-coordinate (say, 600).  The printf near the end of
the program sometimes (one out of ten times) prints the old x value
(600 in this case), although the window has been repositioned by
the call to XConfigureWindow().

I'm using X Windows Version 11 Release 2; the server is running on
a Sun 3/50 and the client on a Sun 3/260.

Here is the offending program:

#include <X11/X.h>
#include <X11/Xlib.h>

main () $
    Display *d;
    Window w;
    XSetWindowAttributes swa;
    XWindowChanges wc;
    XWindowAttributes wa;
    XEvent e;

    if ((d = XOpenDisplay ((char *)0)) == 0)
        exit (1);
    swa.background_pixel = WhitePixel (d, DefaultScreen (d));
    swa.border_pixel = BlackPixel (d, DefaultScreen (d));
    swa.event_mask = ExposureMask|EnterWindowMask|LeaveWindowMask;
    w = XCreateWindow (d, DefaultRootWindow (d), 0, 0, 400, 400, 2,
        CopyFromParent, CopyFromParent, CopyFromParent,
        CWBackPixel|CWBorderPixel|CWEventMask, &swa);
    XMapWindow (d, w);
    do $
        XNextEvent (d, &e);
     while (e.type != Expose);
    wc.x = 0;
    XConfigureWindow (d, w, CWX, &wc);
    XGetWindowAttributes (d, w, &wa);
    printf ("x = %d\n", wa.x);
    pause ();


Thanks in advance for any help.
--
Regards,
    Oliver Laumann, Technical University of Berlin, Germany.
    ...!pyramid!tub!net   or   net@TUB.BITNET
    ...!mcvax!unido!tub!net

oj@apollo.uucp (Ellis Oliver Jones) (06/02/88)

In article <8805291924.AA16344@tub.UUCP> net@TUB.BITNET (Oliver Laumann) writes:
>Maybe I'm just dumb today, but it seems the result returned by
>XGetWindowAttributes() is not deterministic.

In addition to RWS's point about the window manager taking time to process
the XConfigureWindow request, it's worth pointing out that some window
managers (not uwm) reparent a client's top level window.
Therefore,  the x and y positions returned by
XGetWindowAttributes may not be relative 
to the root window, but rather to the window
manager's decoration window.
/oj

cwilson@NISC.SRI.COM (Chan Wilson) (11/08/89)

While mucking around with X windows, I telneted over to one of the 
SparcStations and did a 'xinit -display mymachine:0'  This didn't work. 
Moreever, the display on the sparcstation was locked (unbeknownst to me) so 
I couldn't check the display out.  When the user of the workstation came in 
the following morning, she was quite distressed to see the display unlock, 
have my default x setup appear, and then slowly, messily, crash and burn. 

Is this a bug?  I mean, shouldn't xinit check to see if the display it is
going to be using is locked. (or is this even possible?)


--Chan Wilson
	     `and now for something completely different.'
	Flamingo coloured penguins and banana coloured grapes.
              cwilson@nisc.sri.com or cwilson@nic.ddn.mil