summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2005-09-25 21:48:43 +0000
committerMatthias Melcher <fltk@matthiasm.com>2005-09-25 21:48:43 +0000
commitc0ef4603d4dc920653850dc231c6b9831187e708 (patch)
tree229f638819e10f91fea043d6c941baa17ab6676c
parent60812b2ecc615a5ce40fa9a4c93c170c06f4282e (diff)
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
-rw-r--r--src/Fl_mac.cxx31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx
index 920fa588d..f70ac5d55 100644
--- a/src/Fl_mac.cxx
+++ b/src/Fl_mac.cxx
@@ -420,8 +420,8 @@ void Fl::remove_fd(int n)
*/
int fl_ready()
{
- if (GetNumEventsInQueue(GetCurrentEventQueue()) > 0) return 1;
- return 0;
+ EventRef event;
+ return !ReceiveNextEvent(0, NULL, 0.0, false, &event);
}
/**
@@ -543,7 +543,6 @@ static pascal OSStatus carbonDispatchHandler( EventHandlerCallRef nextHandler, E
}
if ( ret == eventNotHandledErr )
ret = CallNextEventHandler( nextHandler, event ); // let the OS handle the activation, but continue to get a click-through effect
- QuitApplicationEventLoop();
fl_unlock_function();
@@ -552,18 +551,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
*/
static void breakMacEventLoop()
@@ -601,7 +588,6 @@ static double do_queued_events( double time = 0.0 )
}
OSStatus ret;
static EventTargetRef target = 0;
- static EventLoopTimerRef timer = 0;
if ( !target )
{
target = GetEventDispatcherTarget();
@@ -628,7 +614,6 @@ static double do_queued_events( double time = 0.0 )
static EventTypeSpec appEvents[] = {
{ kEventClassCommand, kEventCommandProcess } };
ret = InstallApplicationEventHandler( dispatchHandler, GetEventTypeCount(appEvents), appEvents, 0, 0L );
- ret = InstallEventLoopTimer( GetMainEventLoop(), 0, 0, NewEventLoopTimerUPP( timerProcCB ), 0, &timer );
}
got_events = 0;
@@ -643,10 +628,13 @@ static double do_queued_events( double time = 0.0 )
fl_unlock_function();
- SetEventLoopTimerNextFireTime( timer, time );
- RunApplicationEventLoop(); // will return after the previously set time
- if ( dataready.IsThreadRunning() )
- { dataready.CancelThread(DEBUGTEXT("APPEVENTLOOP DONE\n")); }
+ EventRef event;
+ EventTimeout timeout = time;
+ if (!ReceiveNextEvent(0, NULL, timeout, true, &event)) {
+ got_events = 1;
+ SendEventToEventTarget( event, target );
+ ReleaseEvent( event );
+ }
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
}
}
- QuitApplicationEventLoop();
fl_unlock_function();