File:  [NeXTSTEP 3.3 examples] / Examples / AppKit / Backspace / SleepView.m
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:48:31 2018 UTC (8 years, 1 month ago) by root
Branches: NeXT, MAIN
CVS tags: NeXTSTEP33, HEAD
Sample Programs from NeXSTEP 3.3

//  SleepView.m
//
//  You may freely copy, distribute, and reuse the code in this example.
//  NeXT disclaims any warranty of any kind, expressed or  implied, as to its
//  fitness for any particular use.

//  This view goes in a little 4 pixel window and cause BackSpace to sleep
//  whenever the cursor goes to a preselected corner.

#import "Thinker.h"
#import "SleepView.h"
#import <libc.h>
#import <appkit/timer.h>

@implementation SleepView

- mouseEntered:(NXEvent *)theEvent
{
	int	looping = YES;
	int doSaver = NO;
    NXTrackingTimer   myTimer;

    NXBeginTimer(&myTimer, 3.0, 5.0);
	while (looping)
	{
		theEvent = [NXApp getNextEvent: NX_TIMERMASK|NX_MOUSEEXITEDMASK];

		switch (theEvent->type)
		{
			case NX_TIMER:
				doSaver = YES;
				// now fall into MOUSEEXITED code

			case NX_MOUSEEXITED:
				looping = NO;
				break;
		}
   	}

    NXEndTimer(&myTimer);
	if (doSaver) [BSThinker() showFakeScreenSaver:self];
    return self;
}

@end

unix.superglobalmegacorp.com

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