ScreenSaver *really* stopped vs monitor-slept?
ScreenSaver *really* stopped vs monitor-slept?
- Subject: ScreenSaver *really* stopped vs monitor-slept?
- From: email@hidden
- Date: Sat, 17 Jan 2004 14:10:38 -0500
I have a screen saver that is doing some background computation while running, and I want this computation to continue until the screen saver ends. The computation requires some clean-up: I need to take some action as part of stopping it, I can't just have it die. I had been initiating my background computation in [savermodule startAnimation] and cleaning up and stopping it in [savermodule stopAnimation].
Problem: I've discovered that, when Energy Saver puts the monitor to sleep, the screen saver is informed of this, and sends "stopAnimation" to the screen saver module. I don't want to stop my computation just because the screen has been put to sleep.
Partial solution: No big deal, I just don't use [savermodule stopAnimation] as the signal to clean up and stop my background computation. I've confirmed the screenSaverEngine is still running, and the computation can continue.
New problem: How do I tell when the screen saver has *really* quit? stopAnimation isn't good for this purpose, as it responds to the screen sleep. I've been looking for some detectable event that is equivalent to the screen saver coming back to life, but haven't found one yet.
Things I've tried
- dealloc of my ScreenSaverView doesn't get called
- NSWindowWillClose notification on the main window doesn't get called
- NSApplicationWillTerminate on the screen saver engine application doesn't get called
- resignFirstResponder doesn't get called
Things I've thought of but haven't tried:
- Become the delegate of the screenSaverEngine application and respond to appWillTerminate or appShouldTerminate. I don't like this because the application already has a delegate and I don't want to interfere with what it's doing
- Spin off a separate subtask, which stays running and gets somehow notified when the ScreenSaverEngine application terminates, then handles the cleanup and termination of the background computation (which is being run in a separate task) through appleEvents or other IAC. This would work but seems like a lot of work for such a simple problem.
Ideas I intend to investigate:
- WindowServer sends out various notifications. Is there something there?
- Is there any other service that might be sending interesting notifications?
- Somehow detect the monitor-off event from the power manager and use this fact (such as ignoring a stopAnimation that immediately follows a power-off)
I would welcome any suggestions on other approaches. Actual solutions are, of course, also welcome.
Thanks
Richard
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.