/* MiniDockApplication.m created by fred on Wed 22-Sep-1999 */

#import "MiniDockApplication.h"

#define noVERBOSE

//	----------------------------------------------------------------------------

@implementation MiniDockApplication

- (void)startTrackingModifierFlags:(int)aStartFlags
{	itsLastModifierFlags = aStartFlags;	//	So user gets a NSFlagsChanged event that gives the original status
	[self startTrackingModifierFlags];
}

//	----------------------------------------------------------------------------

- (void)startTrackingModifierFlags
{	[NSEvent startPeriodicEventsAfterDelay:0 withPeriod:0.05];
}

//	----------------------------------------------------------------------------

- (void)stopTrackingModifierFlags
{	[NSEvent stopPeriodicEvents];
}

@end

//	----------------------------------------------------------------------------

@implementation MiniDockApplication(NSApplication_Overrides)

- (void)hide:sender
{	//	We never hide
}

//	----------------------------------------------------------------------------

- (void)sendEvent:(NSEvent *)anEvent
{	if ([anEvent type]==NSPeriodic)
	{
#ifdef VERBOSE
		NSLog( @"CHECKING IS POSTING NEW FLAGS (%d vs %d)", itsLastModifierFlags, [anEvent modifierFlags] );
#endif
		if (itsLastModifierFlags!=[anEvent modifierFlags])
		{	NSEvent *theEvent = [NSEvent keyEventWithType:NSFlagsChanged location:[anEvent locationInWindow] modifierFlags:[anEvent modifierFlags] timestamp:[anEvent timestamp] windowNumber:[anEvent windowNumber] context:[anEvent context] characters:@"" charactersIgnoringModifiers:@"" isARepeat:NO keyCode:0];
#ifdef VERBOSE
			NSLog( @"  APPLICATION POSTING NEW FLAGS" );
#endif
			[self postEvent:theEvent atStart:YES];
		}
	}
	else
	{	if ([anEvent type]==NSFlagsChanged)
			itsLastModifierFlags = [anEvent modifierFlags];
		[super sendEvent:anEvent];
	}
}

@end

