[comp.sys.mac.programmer] Windows and backgrounding.

jboser@cs.fau.edu (Jeff Boser) (06/14/91)

I have an application that I want to run in the background.

It has a small loop that executes upon null events that starts with
FrontWindow(), and performs a procedure based upon the windowKind and
refCon fields of each window, until it hits the end of the window list.

this is the code:
WindowPeek v, w = FrontWindow();
while (w != nil) {
	v = w->nextwindow; /*the next call could get rid of w*/
	/*the call is here*/
	w = v;
	}

It runs fine in the foreground, but I think the problem is this:

Each application/layer has its own list of windows, ending in null.
FrontWindow() returns the front window of the *TOP* layer, not the
 calling layer.

I cant grab the front window on suspend, as the calling loop may
dispose of it.  What I need is a way to get the front window of my
layer while it is in the background.  I might be missing something
really stupid, as I am currently wired and tired.

If anybody has any ideas, please send me them, it would be most appreciated.

.....jeff
jboser@tuna.cs.fau.edu

-- 
"Make something an idiot can use, and only an idiot will use it." - RAH
Like a bible, maybe? - me

REEKES@applelink.apple.com (Jim Reekes) (06/18/91)

In article <1991Jun14.165011.7929@cs.fau.edu>, jboser@cs.fau.edu (Jeff Boser) writes:
> 
> I have an application that I want to run in the background.
> 
> It has a small loop that executes upon null events that starts with
> FrontWindow(), and performs a procedure based upon the windowKind and
> refCon fields of each window, until it hits the end of the window list.
> 
> this is the code:
> WindowPeek v, w = FrontWindow();
> while (w != nil) {
> 	v = w->nextwindow; /*the next call could get rid of w*/
> 	/*the call is here*/
> 	w = v;
> 	}
> 
> It runs fine in the foreground, but I think the problem is this:
> 
> Each application/layer has its own list of windows, ending in null.
> FrontWindow() returns the front window of the *TOP* layer, not the
>  calling layer.
> 
> I cant grab the front window on suspend, as the calling loop may
> dispose of it.  What I need is a way to get the front window of my
> layer while it is in the background.  I might be missing something
> really stupid, as I am currently wired and tired.


FrontWindow only returns the top most window of *your* layer.  While
your application is running, it will only get the windows in its layer.
The Process Manager swaps all of the applications low memory globals
at suspend and resume time.  The window list is kept as one of these
low memory globals.  I don't know how your appliation could be reading
from another application's low memory globals, unless you are running
from an INIT or at interrupt time.  But if you're calling FrontWindow
within your event loop then you're only getting your windows.


-----------------------------------------------------------------------
Jim Reekes, E.O.             |     Macintosh Toolbox Engineering
                             |          Sound Manger Expert
Apple Computer, Inc.         | "All opinions expressed are mine, and do
20525 Mariani Ave. MS: 81-EQ |   not necessarily represent those of my
Cupertino, CA 95014          |       employer, Apple Computer Inc."