|
|
1.1 ! root 1: // ioctls.m ! 2: // ! 3: // This file contains methods related to blacking out screens; this used ! 4: // to be done via ioctls (hence the name) but for 3.0 there's a better ! 5: // interface. ! 6: // ! 7: // You may freely copy, distribute, and reuse the code in this example. ! 8: // NeXT disclaims any warranty of any kind, expressed or implied, as to its ! 9: // fitness for any particular use. ! 10: ! 11: ! 12: #import "Thinker.h" ! 13: #import "BackWindow.h" ! 14: #import "psfuncts.h" ! 15: #import <appkit/Window.h> ! 16: #import <objc/List.h> ! 17: #import <libc.h> ! 18: ! 19: ! 20: @implementation Thinker(ioctls) ! 21: ! 22: - normalMode ! 23: { ! 24: [self _setDimBrightness : &dimBrightness]; ! 25: return self; ! 26: } ! 27: ! 28: - screenSaverMode ! 29: { ! 30: // this method prevents the screen from dimming so you can see the ! 31: // screen saver. Just return self right here if you want the screen ! 32: // to go dim while the screensaver is doing its thing. ! 33: ! 34: [self getNormalBrightness :&normalBrightness]; ! 35: [self _setDimBrightness :&normalBrightness]; ! 36: ! 37: return self; ! 38: } ! 39: ! 40: ! 41: // In the multi-headed case, I gotta throw a black window over all ! 42: // the screens so they don't burn in while I do animation on one. ! 43: // You'd want to black out all screen in every case if you switched ! 44: // animations on the fly to prevent the screen from possibly being ! 45: // unlocked for a moment. ! 46: ! 47: // Hmm, I don't know why I didn't just put a single big non retained ! 48: // window over all screens instead... ! 49: ! 50: - blackOutAllScreens ! 51: { ! 52: int i; ! 53: NXRect r; ! 54: ! 55: if (screenCount <= 1) return self; ! 56: ! 57: if (!screenList) screenList = [[List alloc] init]; ! 58: ! 59: for (i=0; i < screenCount; i++) ! 60: { ! 61: id theWindow; ! 62: r = screens[i].screenBounds; ! 63: ! 64: theWindow = [[BackWindow alloc] ! 65: initContent:&r style:NX_TOKENSTYLE ! 66: backing:NX_NONRETAINED buttonMask:0 defer:NO]; ! 67: ! 68: [screenList addObject:theWindow]; ! 69: ! 70: [theWindow removeFromEventMask:(NX_LMOUSEDOWNMASK | NX_LMOUSEUPMASK ! 71: | NX_MOUSEMOVEDMASK | NX_LMOUSEDRAGGEDMASK ! 72: | NX_MOUSEENTEREDMASK | NX_MOUSEEXITEDMASK ! 73: | NX_KEYDOWNMASK | NX_KEYUPMASK ! 74: | NX_CURSORUPDATEMASK)]; ! 75: [theWindow setBackgroundGray:NX_BLACK]; ! 76: ! 77: tweakWindow([theWindow windowNum], SAVERTIER-1); ! 78: [theWindow placeWindowAndDisplay:&r]; ! 79: [theWindow orderFront:self]; ! 80: ! 81: } ! 82: ! 83: return self; ! 84: } ! 85: ! 86: - unBlackOutAllScreens ! 87: { ! 88: if (screenCount <= 1) return self; ! 89: [screenList makeObjectsPerform:@selector(orderOut:) with:self]; ! 90: [screenList freeObjects]; ! 91: return self; ! 92: } ! 93: ! 94: - getDimBrightness:(double *)b ! 95: { ! 96: *b = NXAutoDimBrightness(evs); ! 97: return self; ! 98: } ! 99: ! 100: - _setDimBrightness :(double *)b ! 101: { ! 102: NXSetAutoDimBrightness(evs, *b); ! 103: if (NXAutoDimState(evs)) ! 104: { ! 105: NXSetAutoDimState(evs, NO); ! 106: NXSetAutoDimState(evs, YES); ! 107: } ! 108: return self; ! 109: } ! 110: ! 111: ! 112: - getNormalBrightness :(double *)b ! 113: { ! 114: *b = NXScreenBrightness(evs); ! 115: return self; ! 116: } ! 117: ! 118: ! 119: - getDimTime :(double *)t ! 120: { ! 121: *t = NXAutoDimTime(evs); ! 122: return self; ! 123: } ! 124: ! 125: @end ! 126:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.