Annotation of Examples/AppKit/Backspace/SleepView.m, revision 1.1.1.1

1.1       root        1: //  SleepView.m
                      2: //
                      3: //  You may freely copy, distribute, and reuse the code in this example.
                      4: //  NeXT disclaims any warranty of any kind, expressed or  implied, as to its
                      5: //  fitness for any particular use.
                      6: 
                      7: //  This view goes in a little 4 pixel window and cause BackSpace to sleep
                      8: //  whenever the cursor goes to a preselected corner.
                      9: 
                     10: #import "Thinker.h"
                     11: #import "SleepView.h"
                     12: #import <libc.h>
                     13: #import <appkit/timer.h>
                     14: 
                     15: @implementation SleepView
                     16: 
                     17: - mouseEntered:(NXEvent *)theEvent
                     18: {
                     19:        int     looping = YES;
                     20:        int doSaver = NO;
                     21:     NXTrackingTimer   myTimer;
                     22: 
                     23:     NXBeginTimer(&myTimer, 3.0, 5.0);
                     24:        while (looping)
                     25:        {
                     26:                theEvent = [NXApp getNextEvent: NX_TIMERMASK|NX_MOUSEEXITEDMASK];
                     27: 
                     28:                switch (theEvent->type)
                     29:                {
                     30:                        case NX_TIMER:
                     31:                                doSaver = YES;
                     32:                                // now fall into MOUSEEXITED code
                     33: 
                     34:                        case NX_MOUSEEXITED:
                     35:                                looping = NO;
                     36:                                break;
                     37:                }
                     38:        }
                     39: 
                     40:     NXEndTimer(&myTimer);
                     41:        if (doSaver) [BSThinker() showFakeScreenSaver:self];
                     42:     return self;
                     43: }
                     44: 
                     45: @end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.