[comp.windows.x] Invisible foreground

jgb@ektools.UUCP (Blose) (06/07/90)

I have been struggling with an annoying problem in getting anything in
my windows to display with X.  I am writing an application program which
writes objects to a pixmap.  I then attempt an XCopyArea from the pixmap
to the window, followed by a MapRaised of the window.  It seems that
only the background is visible.  I cannot get the foreground visible at
all.

I've got around this by using XSetWindowBackgroundPixmap and having my
pixmap serve as the background.  However this approach is very limited
(for ex. what if you really do want a background AND a foregound? (not
unreasonable, right?).

Is there some attribute perhaps in the window which could be suppressing
the foreground from being displayed?  I'm using XCreateSimpleWindow to
create my window.  It's parent is root.

Thanks to anyone who can shed some light here!

-Joanne Greene-Blose

mimperatore@watcgl.waterloo.edu (Marco Imperatore) (06/08/90)

In article <2687@ektools.UUCP> Joanne writes:
>I have been struggling with an annoying problem in getting anything in
>my windows to display with X.  I am writing an application program which
>writes objects to a pixmap.  I then attempt an XCopyArea from the pixmap
>to the window, followed by a MapRaised of the window.  It seems that
>only the background is visible.  I cannot get the foreground visible at
>all.

I had similar problems when I was first learning X (not that I know it now!!).
I think the problem is that you must FIRST map the window and THEN try to
display objects on it.  Furthermore, I think it is a sound idea (if not
entirely necessary) to wait for the Expose event associated with the mapping
of the window before proceeding to draw anything.

-cheers
-- 
Marco Imperatore
Computer Graphics Lab, University of Waterloo, Waterloo, Ontario, Canada
cdn: mimperatore@cgl.waterloo
uucp: mimperatore@watcgl

mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) (06/09/90)

>> I have been struggling with an annoying problem in getting anything
>> in my windows to display with X.  I am writing an application
>> program which writes objects to a pixmap.  I then attempt an
>> XCopyArea from the pixmap to the window, followed by a MapRaised of
>> the window.  It seems that only the background is visible.

> I had similar problems when I was first learning X (not that I know
> it now!!).  I think the problem is that you must FIRST map the window
> and THEN try to display objects on it.

This is true, as far as it goes.  To be more precise...

If the server is not maintaining backing-store (which most servers
won't be, if the window isn't even mapped), drawing into a part of the
window that's not visible on the screen (ie, the entire window, if it's
not mapped) has no effect.

> Furthermore, I think it is a sound idea (if not entirely necessary)
> to wait for the Expose event associated with the mapping of the
> window before proceeding to draw anything.

Possibly events, plural, if the window isn't entirely visible.  (This
*is* possible, even after a MapRaised - the window manager may have
done something you're not expecting).

It is definitely a sound idea.  In many environments (typically when a
reparenting window manager is running), it's necessary.

A simplistic strategy for handling Expose events is to redraw
everything when you get one.  A simple improvement is to redraw
everything when you get an Expose event with a count field of zero.
Most "serious" programs (whatever that means), though, take care to
redraw only the damaged area of the window, or at least only those
"objects" that at least partially overlap the damaged area.  (A
terminal emulator, for example, may mark characters as "damaged", but
redraw them only when it gets to an Expose event with with a count of
zero.)

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu