Path: utzoo!attcan!uunet!pmafire!uudell!milano.sw.mcc.com!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!ispd-newsserver!kodak!dixel!lrul00 From: lrul00@dixel.Kodak.COM (Richard C. Dempsey) Newsgroups: comp.windows.x Subject: Re: Extra Expose event from Window Manager Message-ID: <1991Jan25.140847.24250@kodak.kodak.com> Date: 25 Jan 91 14:08:47 GMT References: <1673@eastman.UUCP> Sender: news@kodak.kodak.com Distribution: na Organization: Eastman Kodak Co. Lines: 72 In summary: an Xlib program depends on receiving precisely one expose event to know that the window has been successfully created. olwm and twm deliver an extra expose event and break it. mwm swallows all expose events and break it. What's the best way for an Xlib program to know that its window has been successfully created, under a variety of window managers? Let's be more specific about the problem that Ilia Levi and I have. We are trying to run PLTMG [1] on a variety of platforms. The X11 driver is written using Xlib calls only. It works on the Silicon Graphics Personal Iris using Foresight (SG's version of NeWS, which includes an X server without a window manager) but breaks under the Open Look Window Manager, the Motif Window Manager, and twm (BTW, what's the full name of twm?). dpy= XOpenDisplay(""); scr = DefaultScreenOfDisplay(dpy); winX = XWidthOfScreen(scr); winY = XHeightOfScreen(scr); scale_xy =((( winX*2 < winY*3 ) ? (winX*2)/3 : winY )*95)/100 ; winW = (scale_xy*3)/2 ; winH = scale_xy ; winX = (winX - winW) / 2 ; winY = (winY - winH) / 2 ; bwidth=5; xswa.event_mask = ExposureMask | KeyPressMask | ButtonPressMask; xswa.backing_store = Always; xswa.background_pixel = WhitePixelOfScreen(scr); win = XCreateWindow(dpy, RootWindowOfScreen(scr), winX, winY, winW, winH, bwidth, DefaultDepthOfScreen(scr), InputOutput, DefaultVisualOfScreen(scr), CWBackingStore | CWBackPixel | CWEventMask , &xswa); /* * ... deleted code that set's the window name, allocates color cells * and stores colors in them ... */ XMapRaised(dpy, win); XFlush(dpy); do { XNextEvent(dpy, &xev); } while (xev.type != Expose); XSetForeground(dpy, DefaultGCOfScreen(scr), ( status = 0 ) ? WhitePixelOfScreen(scr) : pixels[ *icolor - 1 ] ); XFillPolygon( dpy, win, DefaultGCOfScreen(scr), pts, *np, Nonconvex, CoordModeOrigin ); If no expose event is ever delivered (Motif case on AIX 3.1, 3002), then we never get to XSetForeground(). If an extra expose event is delivered (olwm and twm on SunOS 4.1.1), then XSetForeground seems to block. When an extra call to XNextEvent is inserted after the do - while, then the code will work on olwm and twm, but not, of course, on mwm. What's the correct way to do this for maximum portability? I don't want to write a new driver for each window manager. [1] PLTMG: A Software Package for Solving Elliptic Partial Differential Equations: User's Guide 6.0. by Randolph E. Bank, (Frontiers in Applied Mathematics, vol. 7), SIAM, 1990. ISBN 0-89871-255-6 Source code (about 1/2 MB) is available by anonymous ftp from research.att.com and from the netlib mail servers: netlib@ornl.gov or netlib@research.att.com. This is considered large by netlib standards. Please do not fetch it unless you need it. If you want full copies of the routines involved in this problem (a very minor part of PLTMG), send email and I will forward them to you. Thanks! -- Richard C. Dempsey, Computational Science Lab | dempsey@Kodak.COM 10th Floor, Bldg 83, RL | KODAKR(DEMPSEY) Eastman Kodak Company | (716) 477-3457 Rochester, NY 14650-2205 |