Ported FLTK 2 changes to event system on OS X back to FLTK 1

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4585 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher
2005-09-25 21:48:43 +00:00
parent 60812b2ecc
commit c0ef4603d4
+9 -22
View File
@@ -420,8 +420,8 @@ void Fl::remove_fd(int n)
*/ */
int fl_ready() int fl_ready()
{ {
if (GetNumEventsInQueue(GetCurrentEventQueue()) > 0) return 1; EventRef event;
return 0; return !ReceiveNextEvent(0, NULL, 0.0, false, &event);
} }
/** /**
@@ -543,7 +543,6 @@ static pascal OSStatus carbonDispatchHandler( EventHandlerCallRef nextHandler, E
} }
if ( ret == eventNotHandledErr ) if ( ret == eventNotHandledErr )
ret = CallNextEventHandler( nextHandler, event ); // let the OS handle the activation, but continue to get a click-through effect ret = CallNextEventHandler( nextHandler, event ); // let the OS handle the activation, but continue to get a click-through effect
QuitApplicationEventLoop();
fl_unlock_function(); fl_unlock_function();
@@ -551,18 +550,6 @@ static pascal OSStatus carbonDispatchHandler( EventHandlerCallRef nextHandler, E
} }
/**
* this callback simply quits the main event loop handler, so FLTK can do its magic
*/
static pascal void timerProcCB( EventLoopTimerRef, void* )
{
fl_lock_function();
QuitApplicationEventLoop();
fl_unlock_function();
}
/** /**
* break the current event loop * break the current event loop
*/ */
@@ -601,7 +588,6 @@ static double do_queued_events( double time = 0.0 )
} }
OSStatus ret; OSStatus ret;
static EventTargetRef target = 0; static EventTargetRef target = 0;
static EventLoopTimerRef timer = 0;
if ( !target ) if ( !target )
{ {
target = GetEventDispatcherTarget(); target = GetEventDispatcherTarget();
@@ -628,7 +614,6 @@ static double do_queued_events( double time = 0.0 )
static EventTypeSpec appEvents[] = { static EventTypeSpec appEvents[] = {
{ kEventClassCommand, kEventCommandProcess } }; { kEventClassCommand, kEventCommandProcess } };
ret = InstallApplicationEventHandler( dispatchHandler, GetEventTypeCount(appEvents), appEvents, 0, 0L ); ret = InstallApplicationEventHandler( dispatchHandler, GetEventTypeCount(appEvents), appEvents, 0, 0L );
ret = InstallEventLoopTimer( GetMainEventLoop(), 0, 0, NewEventLoopTimerUPP( timerProcCB ), 0, &timer );
} }
got_events = 0; got_events = 0;
@@ -643,10 +628,13 @@ static double do_queued_events( double time = 0.0 )
fl_unlock_function(); fl_unlock_function();
SetEventLoopTimerNextFireTime( timer, time ); EventRef event;
RunApplicationEventLoop(); // will return after the previously set time EventTimeout timeout = time;
if ( dataready.IsThreadRunning() ) if (!ReceiveNextEvent(0, NULL, timeout, true, &event)) {
{ dataready.CancelThread(DEBUGTEXT("APPEVENTLOOP DONE\n")); } got_events = 1;
SendEventToEventTarget( event, target );
ReleaseEvent( event );
}
fl_lock_function(); fl_lock_function();
@@ -691,7 +679,6 @@ static OSErr QuitAppleEventHandler( const AppleEvent *appleEvt, AppleEvent* repl
return noErr; // FLTK has not close all windows, so we return to the main program now return noErr; // FLTK has not close all windows, so we return to the main program now
} }
} }
QuitApplicationEventLoop();
fl_unlock_function(); fl_unlock_function();