[comp.windows.x] some proble writing text after XMapWindow

Francois.Bitz@SAM.CS.CMU.EDU (08/05/88)

I seem to have some trouble in the following simple statements:


	XMapWindow(display,window);

	XDrawImagestring(display,window,mygc,20,20,string,strlen(string);


most of the times (when the window is previously unmappped) 
 these statements get executed the text DOES NOT show up on the
window, whereas a second call to the same lines when the window is already
MAPPED prints text in the window correctly.

I tried doing a XFlush(), but nothing seems to help...

Any suggestions ?

thanks
    

diamant@hpfclp.SDE.HP.COM (John Diamant) (08/06/88)

> I seem to have some trouble in the following simple statements:
> 
> 	XMapWindow(display,window);
> 
> 	XDrawImagestring(display,window,mygc,20,20,string,strlen(string);
> 
> 
> most of the times (when the window is previously unmappped) 
>  these statements get executed the text DOES NOT show up on the
> window, whereas a second call to the same lines when the window is already
> MAPPED prints text in the window correctly.

You need to do your XDrawImagestring in response to an expose event, not
immediately following the XMapWindow.  Windows take a finite amount of time
to map (especially under a reparenting window manager) and doing what you
are doing is time-dependent.  Also, your way, the window can't refresh itself
if it gets obscured and exposed.  You need to put the draw command inside
your event loop as specified above (response to expose).


John Diamant
Software Development Environments
Hewlett-Packard Co.		ARPA Internet: diamant@hpfclp.sde.hp.com
Fort Collins, CO		UUCP:  {hplabs,hpfcla}!hpfclp!diamant