[comp.sys.amiga] How do you find out if your window is active *now*?

hadeishi@husc7.UUCP (02/25/87)

	How does one find out whether your window is active *now*?
That is, not through the use of the ACTIVEWINDOW IDCMP message,
but through some other, independent means.
	The problem is that after I call ActivateWindow() I want to
wait until the window is actually active before proceeding.  However,
the ACTIVEWINDOW IDCMP message will work unless the user hits the left
mouse button on one of my application's other windows that shares the
same IDCMP at the wrong moment.  In this case, for some reason, no ACTIVEWINDOW
is ever generated and my application hangs, waiting for the never-to-arrive
message.
	This would be no problem if Intuition wasn't so flaky about
sending messages to windows in a state of flux.  For example if I close
the window before ActivateWindow() has finished, it seems that Intuition
doesn't realize this and tries to activate the closed window, causing
a crash (usually 3, odd address exception).  Or, if the user is madly clicking
mouse events and the window closes by putting a NULL into UserPort and
then closing the window the application will often GURU (with a 3 again.)
This is speculation, but in any case when my windows are opening and
closing and there are a lot of InputEvents going on the application will
frequently crash.
	In any case, I am trying to stabilize the environment by deactivating
windows before closing them (by ActivateWindow()ing another window) and
so forth.  It turns out that if I just wait long enough (a second or so)
after each operation, the crashes go away.  (i.e., wait at a second
after I open a window and ActivateWindow() it, before closing it).
Yes, I tried just using the ACTIVATE flag, but then Intuition causes a
crash when the window receives an event before I've pointed the window
to the proper IDCMP port and ModifyIDCMP'ed it.
	HELP!!!?!?!  I KNOW (after months of debugging various aspects
of the program) that the last holes in the program are Intuition-caused
crashes; I've plugged every single memory leak and possible bug in
the program.  The fact is that the program runs without a hitch if I
put these weird delays into the program, and it is very flaky if I do not.
Thus the only thing that could be causing these mysterious 00000003
crashes is Intuition itself.  Help, please, C-A!

			-Mitsu

dillon@CORY.BERKELEY.EDU.UUCP (02/26/87)

	Simply look at the Flags variable in the Window structure:

	if (Win->Flags & WINDOWACTIVE)
		blah blah blah

	But since the user can activate/deactivate a window at any time,
	I don't know what use it will be.  If you leave the Window's
	User Port alone, then Intuition will clear any pending messages
	when you call CloseWindow(). 

						-Matt