Esempio n. 1
0
Word BURGERCALL InputSetState(Word NewState)
{
	MacInput_t *LocalPtr;
	LocalPtr = &MacInputLocals;
	if (LocalPtr->InputSprocketInited) {
		if (LocalPtr->InputSprocketActive) {
			if (!NewState) {
				MacLastKeyDown = 0;
				KeyboardFlush();
				LocalPtr->InputSprocketActive = FALSE;	/* Kill IRQ */
				ISpSuspend();			/* Shut down services */
				KeyboardFlush();
				FlushEvents(everyEvent,0);
			}
			return TRUE;					/* Previous state was active */
		}
		if (NewState) {
			MacLastKeyDown = 0;
			KeyboardFlush();
			FlushEvents(everyEvent,0);
			if (!ISpResume()) {				/* Resume services */
				LocalPtr->InputSprocketActive = TRUE;		/* Allow IRQ */
			}
			KeyboardFlush();
			MacLastKeyDown = 0;
		}
	}
	return FALSE;				/* Previous state was inactive */
}
Esempio n. 2
0
// --------------------------------------------------------------------------------------
static void initialize(void)
{
	MenuBarHandle menuBar;
	OSErr error;
	
	MoreMasters();				// I doubt we actually need any extra master pointers 
	InitGraf(&qd.thePort);		// but I left the calls here as a reminder for where they 
	InitFonts();				// belong if they are needed
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(NULL);
	
	InitCursor();
	RegisterAppearanceClient();
	
	menuBar = GetNewMBar(rMenuBar);		// draw the menu bar as soon as possible
	if (menuBar == NULL)
		ExitToShell();
	SetMenuBar(menuBar);
	DrawMenuBar();
	
		// do non time sensitive initialization after we get the application event loop going
	gOpenAppAEHandler = NewAEEventHandlerUPP(openApplicationAEHandler);
	error = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, gOpenAppAEHandler, 0, 
									false);
	if (error != noErr)
		ExitToShell();
	
		/* If we supported them, we would install open documents and print documents 
		   handlers here and we would do most of the same initialization stuff that we 
		   do in the open application handler. */
	
	FlushEvents(everyEvent, 0);
}
Esempio n. 3
0
void BasicInit()
#ifdef MAC
{
	void InitColors();
#if MACB4CARBON  
	short i;
	Ptr stackTop;
	// JLMextern _DataInit();
	
	stackTop = GetApplLimit();
	
	
	SetApplLimit((void *)(stackTop - (Ptr)30000));
	// SetApplLimit((void *)(*(long *)csb - 30000));
	MaxApplZone();
	for (i = 1 ; i <= 16 ; i++) MoreMasters();
	
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(nil);
	FlushEvents(everyEvent, 0);
#endif
	InitCursor();
	
	InitColors();
}
Esempio n. 4
0
/*
=============
InitMacStuff
=============
*/
void InitMacStuff( void ) {
	Handle 		menuBar;
	char		dir[MAX_OSPATH];
	
	// init toolbox
	MaxApplZone();
	MoreMasters();
	
	InitGraf(&qd.thePort);
	InitFonts();
	FlushEvents(everyEvent, 0);
	SetEventMask( -1 );
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(nil);
	InitCursor();

	// init menu
	menuBar = GetNewMBar(rMenuBar);
	if(!menuBar) {
		Com_Error( ERR_FATAL, "MenuBar not found.");
	}
	
	SetMenuBar(menuBar);
	DisposeHandle(menuBar);
	AppendResMenu(GetMenuHandle(mApple),'DRVR');
	DrawMenuBar();

	Sys_InitConsole();

	SetEventMask( -1 );
}
Esempio n. 5
0
void initMac()
{
	InitCursor();
	FlushEvents( 0, everyEvent );
	
	setUpMenus();
}
Esempio n. 6
0
static int
MacintoshInit()
{
    MaxApplZone();
    MoreMasters();
    MoreMasters();
    MoreMasters();
    MoreMasters();

    tcl_macQdPtr = &qd;

     if (TkMacHaveAppearance()) {
         RegisterAppearanceClient();
     }

    InitGraf(&tcl_macQdPtr->thePort);
    InitFonts();

    if (TkMacHaveAppearance() >= 0x110) {
	InitFloatingWindows();
    } else {
	InitWindows();
    }

    InitMenus();
    InitDialogs((long) NULL);		
    InitCursor();

    FlushEvents(everyEvent, 0);
    SetEventMask(everyEvent);
    Tcl_MacSetEventProc(TkMacConvertEvent);

    return TCL_OK;
}
Esempio n. 7
0
File: ugView.c Progetto: rolk/ug
int main (void)
{
  /* init the Macintosh toolbox */
  InitGraf(&qd.thePort);
  InitFonts();
  FlushEvents(everyEvent,0);
  InitWindows();
  InitMenus();
  TEInit();
  InitDialogs(nil);
  InitCursor();

  /* read the screen's size */
  screenx = ((qd.screenBits).bounds).right;
  screeny = ((qd.screenBits).bounds).bottom;
  SetRect(&dragRect,4,24,((qd.screenBits).bounds).right-4,((qd.screenBits).bounds).bottom-4);


  SetUpMenus ();
  SetState(CLOSED);
  OpenCommand();

  /* handle events till the end */
  while (!quitFlag)
  {
    ProcessEvent();
  }

  return(0);
}
Esempio n. 8
0
int main()
{
	
	Rect bounds = {44,12,330,500}/*,zoomFrom,zoomTo*/;
	//Rect	tempRect1;	//used for carbonization
		
	InitStuff();
	gWindow = NewWindow(nil,&bounds,"\pDrag Two Rects to Zoom",true,documentProc,(WindowPtr)-1L,true,0);
	//SetPort(window);
	SetPortWindowPort(gWindow);
	
	/*do {
		if (GetRects(&zoomFrom,&zoomTo))
			ZoomRect(kZoomLarger,&zoomFrom,&zoomTo);
		//EraseRect(&window->portRect);
		EraseRect(GetPortBounds(GetWindowPort(window), &tempRect1));
	}
	while (!gDone);*/
	
	doEventLoop();
	
	FlushEvents(everyEvent,0);
        
        return 0;
}
Esempio n. 9
0
void InitStuff(void)
{
	//InitGraf(&qd.thePort);
	//InitFonts();
	//InitWindows();
	//InitMenus();
	//TEInit();
	//InitDialogs(nil);
	InitCursor();
	FlushEvents(everyEvent,0);
}
/**
 * End capturing stats and queue the upload 
 */
void FAnalyticsProviderET::EndSession()
{
	if (bSessionInProgress)
	{
		RecordEvent(TEXT("SessionEnd"), TArray<FAnalyticsEventAttribute>());
	}
		FlushEvents();
		SessionID.Empty();

	bSessionInProgress = false;
}
Esempio n. 11
0
/* ----------- private code */
static void initialize_application(
	void)
{
	Handle menubar;
	StringHandle		userName;

#ifndef OP_PLATFORM_MAC_CARBON_FLAG
	MaxApplZone();
	MoreMasters();
	MoreMasters();
	MoreMasters();
	
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(NULL);
#else
	MoreMasterPointers(192);
#endif // ! OP_PLATFORM_MAC_CARBON_FLAG

	InitCursor();

	FlushEvents(everyEvent, 0);

	menubar= GetNewMBar(rMENU_BAR_ID);
	op_assert(menubar);

	SetMenuBar(menubar);
	DisposeHandle(menubar);
	AppendResMenu(GetMenuHandle(mApple), 'DRVR');
	DrawMenuBar();

	//	Get the user name from the systemÉ
	
	userName = GetString (-16096);
	if (userName == NULL)
		strcpy(gNameString, "OpenPlay Test");
	else
	{
		doCopyP2CStr(*userName,gNameString);
		ReleaseResource ((Handle) userName);
	}

	// ecf - we wanna enable enumeration by default...
	check_menu_item(mSpecial, iActiveEnumeration, active_enumeration);
	
	//install apple event handler for quitting
	AEInstallEventHandler(kCoreEventClass,kAEQuitApplication,NewAEEventHandlerUPP((AEEventHandlerProcPtr)do_quit_apple_event),0L,false);
	
	return;
}
/** Helper to log any ET event. Used by all the LogXXX functions. */
void FAnalyticsProviderET::RecordEvent(const FString& EventName, const TArray<FAnalyticsEventAttribute>& Attributes)
{
	// There are much better ways to do this, but since most events are recorded and handled on the same (game) thread,
	// this is probably mostly fine for now, and simply favoring not crashing at the moment
	FScopeLock ScopedLock(&CachedEventsCS);
	CachedEvents.Add(FAnalyticsEventEntry(EventName, Attributes));
	// if we aren't caching events, flush immediately. This is really only for debugging as it will significantly affect bandwidth.
	if (!bShouldCacheEvents)
	{
		FlushEvents();
	}
}
void initMac()
{
	//MaxApplZone();

	/*InitGraf( &qd.thePort );
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs( nil );*/
	InitCursor();
	FlushEvents( 0, everyEvent );
}
Esempio n. 14
0
void InitManagers(void)
{
	MaxApplZone();	
	MoreMasters(); MoreMasters(); MoreMasters();
	
	InitGraf(&qd.thePort);  
	InitFonts();			
	InitWindows();
	InitMenus();
	TEInit();				
	InitDialogs(NULL);
	
	InitCursor();		
	FlushEvents(everyEvent, 0);	
}
Esempio n. 15
0
void Initialize(void)
{
	InitGraf((Ptr) &qd.thePort);
	InitFonts();
	FlushEvents(everyEvent, 0);

	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(nil);
	InitCursor();
	
	SetUpMenus();

}
Esempio n. 16
0
int 	main( int argc, char *argv[] )

	{

	
#ifdef OS9 
	ToolboxInit();

	

	if ( HasAppearance() )

		RegisterAppearanceClient();
#endif
	



	game.InitGL();

	

	game.InitGame();

	

	game.EventLoop();

	

	game.Dispose();

	
#ifdef OS9 
	if ( HasAppearance() )

		UnregisterAppearanceClient();

	

	FlushEvents( everyEvent, 0 );

	ExitToShell();
#endif
	

}
bool FAnalyticsProviderET::Tick(float DeltaSeconds)
{
	QUICK_SCOPE_CYCLE_COUNTER(STAT_FAnalyticsProviderET_Tick);

	if (CachedEvents.Num() > 0)
	{
		// Countdown to flush
		FlushEventsCountdown -= DeltaSeconds;
		// If reached countdown or already at max cached events then flush
		if (FlushEventsCountdown <= 0 ||
			CachedEvents.Num() >= MaxCachedNumEvents)
		{
			FlushEvents();
		}
	}
	return true;
}
Esempio n. 18
0
InitMacInterface() 
  {
   int myRsrc, i;
   int MainEvent();
    
   /*=====================================================*/
   /* Macintosh Incantation for initializing application. */
   /*=====================================================*/
	
   InitGraf(&thePort);
   InitFonts();
   InitWindows();
   InitMenus();
   TEInit();
   InitDialogs(0L);
	
   MaxApplZone();
   FlushEvents(everyEvent,0);
	  
   /*==================================*/
   /* Get the screen width and height. */
   /*==================================*/
   
   ScreenHeight = screenBits.bounds.bottom - screenBits.bounds.top;
   ScreenWidth = screenBits.bounds.right - screenBits.bounds.left;
   
   /*===============================*/
   /* Set up the menus and cursors. */
   /*===============================*/
   
   SetUpMenus();
   SetUpCursors();
   
   /*=====================================*/
   /* Initialize global window variables. */
   /*=====================================*/
   
   TheWindow = NULL;
   
   /*=========================*/
   /* Initialize the windows. */
   /*=========================*/
      
   InitDisplayWindow();
   InitFileListWindow();
  }
Esempio n. 19
0
static PyObject *Evt_FlushEvents(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    EventMask whichMask;
    EventMask stopMask;
#ifndef FlushEvents
    PyMac_PRECHECK(FlushEvents);
#endif
    if (!PyArg_ParseTuple(_args, "HH",
                          &whichMask,
                          &stopMask))
        return NULL;
    FlushEvents(whichMask,
                stopMask);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}
Esempio n. 20
0
File: main.c Progetto: prophile/dim3
void app_init(void)
{
	RegisterAppearanceClient();

	InitCursor();
	
	MoreMasterPointers(128);
	FlushEvents(everyEvent,0);

	HMSetTagDelay(250);
	
		// setup paths

	file_paths_setup(&file_path_setup,TRUE);
	
		// no open files
		
	fileopen=FALSE;
}
Esempio n. 21
0
static void InitToolBox(void) {

#if !TARGET_CARBON
	MaxApplZone();
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(0);
#endif
	FlushEvents(everyEvent, 0);
	InitCursor();

#ifdef TARGET_API_MAC_CARBON
	AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
						AEProc(handleQuitApp), 0L, false);
#endif
}
Esempio n. 22
0
ToolBox::ToolBox(void)
{
	short i;
	/* if you have stack requirements that differ from the default, 
		then you counld use SetApplLimit to increase StackSpace at
		this point, before calling MaxApplZone */
		
	MaxApplZone();
	for(i = 0; i < 50; i++)
		MoreMasters();

	//notice the following order is important
	InitGraf(&(qd.thePort));
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(0L);
	InitCursor();
	FlushEvents( everyEvent, REMOVE_EVENTS);
}
void do_about_box( void)
{
	GrafPtr oldPort;
	DialogPtr dptr;
	short item, itemType;
	Handle itemHdl;
	Rect itemRect;

	dptr = GetNewDialog( rAboutBox, nil, (WindowPtr)-1L);
	
	if( dptr == (DialogPtr)0){
		Handle items = NewHandle( sizeof(missing_DITL));
		static Rect bounds = {40, 20, 150, 340};

		if( ! items) return;
		BlockMove( missing_DITL, *items, sizeof(missing_DITL));

		dptr = NewColorDialog( nil, &bounds, (unsigned char*)"\005About",
					false, dBoxProc, (WindowPtr)-1L, false, 0, items);
                }
	
	if( dptr == (DialogPtr)0) return;
	GetPort (&oldPort);
	SetPort (GetDialogPort(dptr));
	GetDialogItem( dptr, ok, &itemType, &itemHdl, &itemRect);
	InsetRect( &itemRect, -4, -4);
	SetDialogItem( dptr, 6, userItem + itemDisable, (Handle)outline_hook_upp, &itemRect);

	FlushEvents( everyEvent, 0);
        ShowWindow( GetDialogWindow(dptr));

	do {
		ModalDialog( about_filter_upp, &item);
	} while( item != ok);

	DisposeDialog( dptr);
	SetPort( oldPort);
}
Esempio n. 24
0
void CDDBaseGrid::OnLClicked(int col,long row, int updn, RECT *rect, POINT *point, int processed) 
{
   // Some grids update via a PostMessage, because OnEditFinish is called when editing is about
   // to finish,not after editting is finished. So the update message is posted, edit allowed to 
   // finish, then the grid is updated. This LClicked event might trigger OnEditFinish, but then
   // the update that is posted comes after this LClick we have in hand. If multi-select is active
   // then the multi-select params get wiped out, and the grid update fails to update the whole
   // selection. So flush the queue before continuing with the LClick event.
   FlushEvents();

   CaptureSelection();

#ifdef BUTTON_ACTIONS
   if (updn == TRUE)  // button down
   {
   }

   if (updn == FALSE) // button up
   {
   }
#endif

}
Esempio n. 25
0
static void initmacintosh (void) {

	/*
	the magic stuff that every Macintosh application needs to do 
	before doing anything else.
	*/

	short i;
		
	MaxApplZone ();
	
	for (i = 0; i < 10; i++) 
		MoreMasters ();
	
	InitGraf (&qd.thePort);
	
	InitFonts ();
	
	FlushEvents (everyEvent, 0);
	
	InitWindows ();
	
	InitMenus ();
	
	TEInit ();
	
	InitDialogs (0L);
	
	InitCursor ();
	
	for (i = 0; i < 5; i++) { /*register with Multifinder*/
		
		EventRecord ev;
		
		EventAvail (everyEvent, &ev); /*see TN180 -- splash screen*/
		} /*for*/
	} /*initmacintosh*/
void StereoObject::SetUpForInputOfPoleOrMatrix()
Esempio n. 27
0
boolean initmacintosh (void) {
	
	/*
	the magic stuff that every Macintosh application needs to do 
	before doing anything else.
	
	4/24/91 dmb: added memory config resource stuff
	
	3.0.4 dmb: use LMGetCurStackBase, not CurStackBase global
	
	3.0.4 dmb: pass 0L to InitDialogs
	*/
	
	register short i;
	register hdlmemoryconfig h;
	register long ctbytes;
	//Code change by Timothy Paustian Thursday, June 8, 2000 3:45:13 PM
	//
	#if TARGET_API_MAC_CARBON == 0
	long ctstack;
	#endif
	long ctheap, ctcode;
	short ctmasters;
	
	h = (hdlmemoryconfig) Get1Resource ('MCFG', 1);
	
	if (h == nil)
		clearbytes (&macmemoryconfig, sizeof (macmemoryconfig));
	else
		macmemoryconfig = **h;
	
	//Code change by Timothy Paustian Saturday, June 3, 2000 10:13:20 PM
	//Changed to Opaque call for Carbon
	//we don't need this in carbon.
	#if TARGET_API_MAC_CARBON == 0
	if (h != nil) { /*first check stack size*/
		
		ctbytes = (**h).minstacksize;
		
		ctstack = LMGetCurStackBase () - GetApplLimit (); /*current stack size*/
		
		if (ctbytes > ctstack)
			SetApplLimit (LMGetCurStackBase () - ctbytes);
		}
	MaxApplZone ();
	
	#endif

	
	
	if (h != nil) { /*check heap size and master pointers*/
		
		ctbytes = (**h).minheapsize;
		
		//Code change by Timothy Paustian Thursday, June 8, 2000 3:04:31 PM
		//Changed to Opaque call for Carbon
		//This is meaningless for OS X since it has unlimited memory.
		
		#if TARGET_API_MAC_CARBON == 1
		//we need to do somethings else. FreeMem is going to return some large value
		//of all the available system memory
		//This whole thing is pointless. We can get as much memory as we need.

			#pragma unused (ctmasters)
			#pragma unused (ctcode)
			#pragma unused (ctheap)
		
		#else

		ctheap = FreeMem ();
		
		if (ctbytes > ctheap) {
			
			return (false);
			}
		
		ctbytes = (**h).avghandlesize;
		
		ctcode = (**h).reserveforcode;
		
		if ((ctbytes > 0) && (ctheap > ctcode)) {
			
			ctmasters = ((ctheap - ctcode) / ctbytes) / kNumberOfMasters;
			
			ctmasters = min (ctmasters, 1024);  /*7.1b37 PBS: You'd think 1024 calls would be enough. With large memory alottments on Mac
			  						  			Classic, we're calling MoreMasters in excess of 20,000 times. That makes the app take
			  						  			a minute or so to start up! So instead I've chosen an arbitrary limit.*/
			  						  
			for (i = 1; i < ctmasters; i++) 
				MoreMasters ();
			}
		#endif

		ReleaseResource ((Handle) h); /*we're done with it*/
		}
	
	//Code change by Timothy Paustian Thursday, June 8, 2000 3:21:06 PM
	//Changed to Opaque call for Carbon
	//we don't need this initialization in carbon
	#if TARGET_API_MAC_CARBON == 0
	InitGraf (&qd.thePort);
	
	InitFonts ();
	
	FlushEvents (everyEvent, 0);
	
	InitWindows ();
	
	InitMenus ();
	
	TEInit ();
	
	InitDialogs (0L);
	#endif

	
	InitCursor ();
	//Code change by Timothy Paustian Thursday, June 8, 2000 3:22:57 PM
	//Changed to Opaque call for Carbon
	//this is obsolete, we should be using gestalt for this.
	
	{	
		long quickDrawFeatures;
		OSErr theErr = Gestalt(gestaltSystemVersion, &gSystemVersion);
		if(oserror(theErr))
			ExitToShell();

		theErr = Gestalt(gestaltQuickdrawFeatures, &quickDrawFeatures);
		
		if(oserror(theErr))
			ExitToShell();
		gHasColorQD = (quickDrawFeatures & (1 << gestaltHasColor));
		//Nav services has to be present and we want the 1.1 or greater version.
		gCanUseNavServ = (NavServicesAvailable() && (NavLibraryVersion() >= 0x01108000));
	}
	
	
	//SysEnvirons (1, &macworld);
	
	//gee I bet this isn't required anymore either.
	for (i = 1; i <= 5; i++) { /*register with Multifinder*/
		
		EventRecord ev;
		
		EventAvail (everyEvent, &ev); /*see TN180 -- splash screen*/
		} /*for*/
	
	#if TARGET_API_MAC_CARBON == 1
	
		RegisterAppearanceClient ();
		
	#endif
	
	return (true);
	} /*initmacintosh*/
Esempio n. 28
0
static int
MacintoshInit()
{
    int i;
    long result, mask = 0x0700; 		/* mask = system 7.x */

#if GENERATING68K && !GENERATINGCFM
    SetApplLimit(GetApplLimit() - (TK_MAC_68K_STACK_GROWTH));
#endif
    MaxApplZone();
    for (i = 0; i < 4; i++) {
	(void) MoreMasters();
    }

    /*
     * Tk needs us to set the qd pointer it uses.  This is needed
     * so Tk doesn't have to assume the availablity of the qd global
     * variable.  Which in turn allows Tk to be used in code resources.
     */
    tcl_macQdPtr = &qd;

    /*
     * If appearance is present, then register Tk as an Appearance client
     * This means that the mapping from non-Appearance to Appearance cdefs
     * will be done for Tk regardless of the setting in the Appearance
     * control panel.  
     */
     
     if (TkMacHaveAppearance()) {
         RegisterAppearanceClient();
     }

    InitGraf(&tcl_macQdPtr->thePort);
    InitFonts();
    if (TkMacHaveAppearance() >= 0x110) {
        InitFloatingWindows();
    } else {
    InitWindows();
    }
    InitMenus();
    InitDialogs((long) NULL);		
    InitCursor();

    /*
     * Make sure we are running on system 7 or higher
     */
     
    if ((NGetTrapAddress(_Gestalt, ToolTrap) == 
    	    NGetTrapAddress(_Unimplemented, ToolTrap))
    	    || (((Gestalt(gestaltSystemVersion, &result) != noErr)
	    || (result < mask)))) {
	panic("Tcl/Tk requires System 7 or higher.");
    }

    /*
     * Make sure we have color quick draw 
     * (this means we can't run on 68000 macs)
     */
     
    if (((Gestalt(gestaltQuickdrawVersion, &result) != noErr)
	    || (result < gestalt32BitQD13))) {
	panic("Tk requires Color QuickDraw.");
    }

    
    FlushEvents(everyEvent, 0);
    SetEventMask(everyEvent);


    Tcl_MacSetEventProc(TkMacConvertEvent);
    return TCL_OK;
}
Esempio n. 29
0
void
CPlaybackTaskGroup::_locate()
{
	D_INTERNAL(("CPlaybackTaskGroup::_locate()\n"));

	CPlaybackTask *th[2];
	th[0] = th[1] = NULL;

	// If the locator has to seek around in the sequence, then
	// kill all of the stuff that's playing now and re-launch
	// the master track.
	if (flags & (Locator_Reset | Locator_Find))
	{
		LOCK_PLAYER;

		// Stop all notes for this song.
		FlushEvents();

		if (flags & Locator_Reset)
		{
			// Stop all playback tasks for this song.
			_flushTasks();

			real.seekTime = metered.seekTime = 0;

			// Launch each of the two main tracks
			for (int i = 0; i < 2; i++)
			{
				CEventTrack	*tr = (CEventTrack *)mainTracks[i];
				if (tr == NULL)
					continue;
				
				// REM: This use of "track duration" is incorrect if
				// both the master sequences are playing.
				CReadLock lock(tr);
				if (!tr->Events().IsEmpty())
				{
					// Start the new tasks at time 0 with no parent task.
					if (tr->ClockType() == ClockType_Real)
					{
						int32 endTime = pbOptions & PB_Loop ? LONG_MAX
															: real.end;
						th[0] = new CRealClockEventTask(*this,
														(CEventTrack *)tr,
														NULL, 0, endTime);
					}
					else
					{
						int32 endTime = pbOptions & PB_Loop ? LONG_MAX
															: metered.end;
						th[1] = new CMeteredClockEventTask(*this,
														   (CEventTrack *)tr,
														   NULL, 0, endTime);
					}
				}
			}
		}
		flags &= ~(Locator_Reset | Locator_Find);
	}

	if (locateType == LocateTarget_Real)
	{
		// While seek time has not caught up to actual time,
		// locate through some number of events, except
		// if we're near the start of the song there's no need
		// to do any locating.
		while ((real.seekTime < real.time) && (real.time > 100))
		{
			// Check once in a while to see if we have spent too much
			// time locating and didn't give other tasks a chance to run.
			// Also, check to see if the locate should be abandoned.
			if (flags & (Locator_Reset | Locator_Find))
				return;

			LOCK_PLAYER;

			// Pop events off of the stack which are ready to go
			_locateNextChunk(real);
			metered.seekTime = tempo.ConvertRealToMetered(real.seekTime);
			_locateNextChunk(metered);

			if (!real.stack.NextTime(&real.seekTime))
				real.seekTime = real.time;
		}
	}
	else
	{
		// While seek time has not caught up to actual time,
		// locate through some number of events, except
		// if we're near the start of the song there's no need
		// to do any locating.
		if (metered.time > 10)
		{
			while (metered.seekTime < metered.time)
			{
				// Check once in a while to see if we have spent too much
				// time locating and didn't give other tasks a chance to run.
				// Also, check to see if the locate should be abandoned.
				if (flags & (Locator_Reset | Locator_Find))
					return;

				// Lock the player for another batch of events we are seeking.
				LOCK_PLAYER;
	
				_locateNextChunk(metered);
				real.seekTime = tempo.ConvertMeteredToReal(metered.seekTime);
				_locateNextChunk(real);
	
				int32 target = metered.time;
				if (pbOptions & PB_Folded)
					target = metered.time + metered.expansion;
				else
					target = metered.time;

				int32 nextTime;
				if (metered.stack.NextTime(&nextTime))
					metered.seekTime = MIN(nextTime + cTrackAdvance_Metered,
										   target);
				else
					metered.seekTime = target;
			}
		}

		// REM: I'm not sure this is right, but it works for now...
		real.time = tempo.ConvertMeteredToReal(metered.seekTime);
	}

	// Push back task origin so that lTime is correct.
	// REM: Is this correct for synced sequences???
	// +++++ REMOVE THIS DEPENDANCY +++++
	origin = thePlayer.m_internalTimerTick - real.time;
	flags &= ~Clock_Locating;

	// notify all destinations that locating has finished
	if (doc->ReadLock(500))
	{
		CDestination *destination = NULL;
		int32 index = 0;
		bigtime_t now = system_time();
		while ((destination = doc->GetNextDestination(&index)) != NULL)
			destination->DoneLocating(now);
		doc->ReadUnlock();
	}

	// Poke the main player task to make sure it handles the first
	// event promptly. It doesn't have to actually do anything with
	// this command.
	write_port(thePlayer.Port(), Command_Attention, "", 0);
}
Esempio n. 30
0
init_mac_interface() 
  {
   int myRsrc, i;
   int MainEvent();
    
   /*=====================================================*/
   /* Macintosh Incantation for initializing application. */
   /*=====================================================*/
	
   InitGraf(&thePort);
   InitFonts();
   InitWindows();
   InitMenus();
   TEInit();
   InitDialogs(0L);
	
   MaxApplZone();
   FlushEvents(everyEvent,0);
	  
   /*==================================*/
   /* Get the screen width and height. */
   /*==================================*/
   
   ScreenHeight = screenBits.bounds.bottom - screenBits.bounds.top;
   ScreenWidth = screenBits.bounds.right - screenBits.bounds.left;
   
   /*===============================*/
   /* Set up the menus and cursors. */
   /*===============================*/
   
   SetUpMenus();
   SetUpCursors();
   
   /*=====================================*/
   /* Initialize global window variables. */
   /*=====================================*/
   
   TheText = NULL;
   TheWindow = NULL;
   TheVScrollBar = NULL;
   TheHScrollBar = NULL;
   
   /*======================================*/
   /* Place any selected files in buffers. */
   /*======================================*/
   
   DoStartup();
   
   /*=======================*/
   /* Initialize the Scrap. */
   /*=======================*/
   
   InitializeScrap();
   
   /*=========================*/
   /* Set up for MultiFinder. */
   /*=========================*/
   
   MultiFinderSetup();
   
   /*===================================*/
   /* Set up routers for the interface. */
   /*===================================*/
   
   SetUpRouters();
   
   /*==================================================================*/
   /* Set up hook between CLIPS command loop and interface event loop. */
   /*==================================================================*/
   
   set_event_function(MainEvent);
   
   /*==================================================================*/
   /* Add execution function to update interface between rule firings. */
   /*==================================================================*/
   
   add_exec_function("macint",mac_exec_function);
  }