[comp.sys.mac.programmer] MultiFinder questions

fmodwyer@csvax1.cs.tcd.ie (Frank O'Dwyer, Dept. of Computer Science, TCD, Dublin 2, IRELAND) (04/10/89)

I'm sure that these questions are answered in some
tech note or other - but since I don't have the notes I'm
going to ask them anyway.

1. When can an application background under MF?  i.e., when is it
O.K. to set the 'Can Background' bit in the MF SIZE resource?

2. What does an application have to do to be 'MultiFinder Aware'?

I ask because I've written a program which seems to background fine
under MF - even though I've set 'MultiFinder Aware' to false,
and set 'Can Background' to true - *without* making the slightest
provision in my code to handle backgrounding.  Is this O.K. or
is my program doomed to crash under some wierd set of circumstances? 

-- 
Frank O'Dwyer,                            e-mail: FMODWYER@cs.tcd.ie
Dept. of Computer Science,
Trinity College Dublin,
IRELAND.

nick@lfcs.ed.ac.uk (Nick Rothwell) (04/10/89)

In article <42072@csvax1.cs.tcd.ie> fmodwyer@csvax1.cs.tcd.ie (Frank O'Dwyer, Dept. of Computer Science, TCD, Dublin 2, IRELAND) writes:
>I'm sure that these questions are answered in some
>tech note or other - but since I don't have the notes I'm
>going to ask them anyway.

>...[Multifinder Interfacing questions]

>I ask because I've written a program which seems to background fine
>under MF - even though I've set 'MultiFinder Aware' to false,
>and set 'Can Background' to true - *without* making the slightest
>provision in my code to handle backgrounding.  Is this O.K. or
>is my program doomed to crash under some wierd set of circumstances? 

I'v been programming in Lightspeed C for quite a while, and know nothing
(well, mostly nothing) about MultiFinder interfacing, and have had no
problems. I have all the MultiFinder flags set to 0, and all that seems to
happen is that MultiFinder kicks in by posting a faked Select Desk Accessory
menu action. Note that this action *must* be respected immediately; I tried
putting up a dialog when this happened, for debugging, and things broke.
I suspect that doing things properly (getting the suspend/resume events)
will be more efficient. I also presume that you have to be conformant in
order to run in the background.

So: my request. Could somebody post a short definitive document on how to
write things for MultiFinder, assuming Inside Mac I/II knowledge? I'm sure
it wouldn't be too long; just a summary of the app4 event and the SIZE-1
flags. Is there a lot more to it than that?

I'm endeavouring to get this information from APDA, but here in Scotland,
it looks like it's going to take a while...

>Frank O'Dwyer,                            e-mail: FMODWYER@cs.tcd.ie

		Nick.
--
Nick Rothwell,	Laboratory for Foundations of Computer Science, Edinburgh.
		nick@lfcs.ed.ac.uk    <Atlantic Ocean>!mcvax!ukc!lfcs!nick
~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~
...while the builders of the cages sleep with bullets, bars and stone,
they do not see your road to freedom that you build with flesh and bone.

jackiw@cs.swarthmore.edu (Nick Jackiw) (04/11/89)

In article <42072@csvax1.cs.tcd.ie> fmodwyer@csvax1.cs.tcd.ie (Frank O'Dwyer, Dept. of Computer Science, TCD, Dublin 2, IRELAND) writes:
> 1. When can an application background under MF?  i.e., when is it
> O.K. to set the 'Can Background' bit in the MF SIZE resource?

Anytime.  CanBackground really only seems to be used to determine whether
the application should get null events while it's in the background (on
which it should "process-one-null-event's-worth").  It'll get update
events for its windows regardless of whether it CanBackground or not. 

> 2. What does an application have to do to be 'MultiFinder Aware'?

You should understand suspend and resume events (which are both appl4
events; Suspend has bit#0 of theEvent.message clear; Resume has bit#0
set.  What does it mean to "understand" these events?  Two things: you
should deactivate your topmost window, get rid of all hi-liting, etc.
Second, if you keep the content of the clipboard in some private format
(instead of using the actual DeskScrap), for efficiency's sake lets say,
and actually put it onto the deskScrap only when User asks for a desk
accessory or quits (intending, presumably, to PASTE it into some application
which doesn't parse your internal format), then you want to normalize
your scrap (convert to desk scrap) on suspend. Resume requires only
reactivation of the window, generally speaking.

If you don't set Multifinder Aware, Multifinder goes through a long
song-and-dance of trying to convince your application that it's about to
see a desk accessory (based on the assumption that your app will respond
in more or less the ways outlined in the previous paragraph).

> I ask because I've written a program which seems to background fine
> under MF - even though I've set 'MultiFinder Aware' to false,
> and set 'Can Background' to true - *without* making the slightest
> provision in my code to handle backgrounding.  Is this O.K. or
> is my program doomed to crash under some wierd set of circumstances? 

Your program is merrily getting null events (canBackground), which I
assume it interprets as a signal to do-some-more-processing.  Fine, you
won't crash.  Adding code to understand Suspend&Resume events, and then
setting MultiFinderAware, will speed up your program's response to being
switched out.  If it seems to work fine now, you probably don't need to
worry about being (technically) MultifinderAware.

> -- 
> Frank O'Dwyer,                            e-mail: FMODWYER@cs.tcd.ie
> Dept. of Computer Science,
> Trinity College Dublin,
> IRELAND.


-- 
     _  _|\____    Nick Jackiw | Visual Geometry Project | Math Department
   / /_/   O>  \   ------------+-------------------------+ Swarthmore College
   |       O>   |  215-328-8225| jackiw@cs.swarthmore.edu| Swarthmore PA 19081
    \_Guernica_/   ------------+-------------------------+                 USA