Thanks for all the input. I've been busily digging into the many
possible ways of handling things. And cursing a lot at 10.6 - not
because of bugs for a change, but because every time I found a good
way to do something it was labelled "Available in Mac OS X v10.6 and
later." and I need 10.4 support ;( My respect for 10.6 has gone up a
whole lot in the last couple of days :)
Anyway, the app is finished (well, I'll improve it perhaps, but it's
done and released). It's here if anyone's interested: http://www.interealtime.com/RedScreen/RedScreen.dmg
It's intended for night vision - you can make the screen red (which is
better for your night vision than any other colour), and dim the
screen. The only issue I'm aware of is the screensaver - it seems the
screensaver resets the display's gamma settings when it loads and
exits. I've put some hooks in to catch it, but it still flickers
briefly into full colour as the screensaver starts. There's a control
to stop the screensaver.
I ended up not needing QC at all.. I was intending to use a QC overlay
as a replacement screensaver, but then realised that a simple screen
fade works better and eats less cycles :)
I checked out the link Troy sent, using IOKit, and got a bit excited
(because I also felt like periodic "don't sleep" messages are lame ;).
After some testing, however, it looks like that only disables system
sleep and display dimming, not disabling the screen saver. (I could
be mistaken on this, so if I'm incorrect by all means set me
straight).
So, if the above is correct, it looks like UpdateSystemActivity
(OverallAct); is still the way to go (every ~30 seconds)... I find
that putting it on a background thread is easy enough (and keeps
random timer events off the main thread), but that might be overkill
for your application.
Yeah, I got to the same conclusion and ended up calling
UpdateSystemActivity(UsrActivity) on a timer (that stops dimming too..
actually, dimming isn't any harm at all, but what I'm doing makes the
screen so dark already that extra dimming seems a bit pointless :)
I've learned a ton of CG stuff doing this too - I'll put some useful
bits here, I guess others will probably find them useful too. Screen
fades are very easy with:
CGDisplayErr err;
err = CGAcquireDisplayFadeReservation (4.0, &token); // 1
if (err == kCGErrorSuccess)
{
err = CGDisplayFade (token, 1.0, kCGDisplayBlendNormal,
kCGDisplayBlendSolidColor, 0, 0, 0, true);
err = CGDisplayFade (token, 1.0, kCGDisplayBlendSolidColor,
kCGDisplayBlendNormal,
0, 0, 0, true);
err = CGReleaseDisplayFadeReservation (token);
}
You'd probably want some actual code between the fade out/fade in part
(like switch to fullscreen), but I actually wanted to just fade out
and in and not do anything (do this every 20 minutes = instant
screensaver). Control monitor backlight with this (range is 0..1,
careful - 0 can be 'off'):
- (void)setDisplayBrightness:(float)newBrightness {
CGDisplayErr cgErr;
io_service_t service;
CGDirectDisplayID targetDisplay;
CFStringRef key = CFSTR(kIODisplayBrightnessKey);
targetDisplay = CGMainDisplayID();
service = CGDisplayIOServicePort(targetDisplay);
if (newBrightness != HUGE_VALF) cgErr = IODisplaySetFloatParameter
(service, kNilOptions, key, newBrightness);
}
Lastly, you can modify the video card's gamma tables with
CGSetDisplayTransferByTable. You could have all sorts of fun with
that. I'm using it to disable green/blue colours entirely (pure red
screen, no white allowed :) and also to darken the screen.
Thanks for the help once again guys :D
Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to [email protected]