Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!zaphod.mps.ohio-state.edu!think.com!hsdndev!dartvax!eleazar.dartmouth.edu!ari From: ari@eleazar.dartmouth.edu (Ari Halberstadt) Newsgroups: comp.sys.mac.programmer Subject: How do I write a screen saver? Message-ID: <1991Jan11.013203.13763@dartvax.dartmouth.edu> Date: 11 Jan 91 01:32:03 GMT References: <13650002@hpspdra.HP.COM> Sender: news@dartvax.dartmouth.edu (The News Manager) Organization: Dartmouth College, Hanover, NH Lines: 46 I know the basic idea of a screen saver: if nothing's happened for X minutes, then blank the screen (gee whiz). I've written an application which will blacken the entire screen (or screens), and wait till there's a click or some other user event. I've even written a patch to GetNextEvent which, for lack of anything better to do, beeped if nothing had happened for several minutes. What I need is a screen saver which will work both in Finder and in MultiFinder. It can be an INIT, like AutoIdle. I have several questions: If I write it as an INIT, like AutoIdle, and patch GetNextEvent, then I need some way to blacken the screen. AutoIdle seems to patch InitGraf as well, so that it can find out if it's been called. If InitGraf hasn't been called, then I guess AutoIdle calls it. To blacken the screen, all I'd have to do is create a port and paint it black. The problem is, how do I tell the application to redraw its windows when it's time to unblacken the screen? Also, I'm not sure that I can always create a graf port if InitGraf isn't called by the application. Under MultiFinder, assuming I wrote a background program, how do I examine the event queues of all of the applications? And, how do I force a background application's window to be the frontmost window when it's time to blacken the screen? One technique, employed by a shareware utility, is to launch another application as a foreground application which will blacken the screen. How do I make sure all of this works under A/UX 2.0? (This requirement isn't that critical, but it's always nice to be compatible.) I understand A/UX doesn't have the same type of event queue that regular macs have. Thanks folks. If I get enough replies, maybe I'll post a summary. ------- cut here if you think tail patches are good for your digestion ------ The following comment has had bloody battles fought over it, but since I'm talking about patching GetNextEvent, I sort of feel it's my duty to state this. NOTICE MAC PROGRAMMERS: Tail patches are bad. Inside Macintosh says you shouldn't do them (lookup SetTrapAddress). Please don't start a flame war, it's just that I still see source code with tail patches in it. Someday I'll post an assembly language and C stub showing how to write friendly patches.