mirror of
https://github.com/fltk/fltk.git
synced 2026-06-05 16:12:13 +08:00
OSX threading support - a little buggy right now, but hopefully we'll be
able to work out the kinks without too much effort. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2093 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
CHANGES IN FLTK 1.1.0rc1
|
CHANGES IN FLTK 1.1.0rc1
|
||||||
|
|
||||||
|
- Added threading support for MacOS X and Darwin.
|
||||||
- The filesystem list in the file chooser now works under
|
- The filesystem list in the file chooser now works under
|
||||||
MacOS X and Darwin.
|
MacOS X and Darwin.
|
||||||
- The fl_msg structure now contains all data passed to
|
- The fl_msg structure now contains all data passed to
|
||||||
|
|||||||
+7
-2
@@ -1,7 +1,7 @@
|
|||||||
dnl -*- sh -*-
|
dnl -*- sh -*-
|
||||||
dnl the "configure" script is made from this by running GNU "autoconf"
|
dnl the "configure" script is made from this by running GNU "autoconf"
|
||||||
dnl
|
dnl
|
||||||
dnl "$Id: configure.in,v 1.33.2.31.2.59 2002/04/10 16:26:33 easysw Exp $"
|
dnl "$Id: configure.in,v 1.33.2.31.2.60 2002/04/16 15:49:06 easysw Exp $"
|
||||||
dnl
|
dnl
|
||||||
dnl Configuration script for the Fast Light Tool Kit (FLTK).
|
dnl Configuration script for the Fast Light Tool Kit (FLTK).
|
||||||
dnl
|
dnl
|
||||||
@@ -360,6 +360,11 @@ case $uname in
|
|||||||
# MacOS X uses Carbon for graphics...
|
# MacOS X uses Carbon for graphics...
|
||||||
LIBS="$LIBS -framework Carbon -framework ApplicationServices"
|
LIBS="$LIBS -framework Carbon -framework ApplicationServices"
|
||||||
|
|
||||||
|
if test $have_pthread = yes; then
|
||||||
|
AC_DEFINE(HAVE_PTHREAD)
|
||||||
|
THREADS="threads"
|
||||||
|
fi
|
||||||
|
|
||||||
if test x$enable_gl != xno; then
|
if test x$enable_gl != xno; then
|
||||||
AC_DEFINE(HAVE_GL)
|
AC_DEFINE(HAVE_GL)
|
||||||
AC_DEFINE(HAVE_GL_GLU_H)
|
AC_DEFINE(HAVE_GL_GLU_H)
|
||||||
@@ -712,5 +717,5 @@ dnl Make sure the fltk-config script is executable...
|
|||||||
chmod +x fltk-config
|
chmod +x fltk-config
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl End of "$Id: configure.in,v 1.33.2.31.2.59 2002/04/10 16:26:33 easysw Exp $".
|
dnl End of "$Id: configure.in,v 1.33.2.31.2.60 2002/04/16 15:49:06 easysw Exp $".
|
||||||
dnl
|
dnl
|
||||||
|
|||||||
+77
-12
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: Fl_mac.cxx,v 1.1.2.21 2002/04/15 20:30:06 easysw Exp $"
|
// "$Id: Fl_mac.cxx,v 1.1.2.22 2002/04/16 15:49:06 easysw Exp $"
|
||||||
//
|
//
|
||||||
// MacOS specific code for the Fast Light Tool Kit (FLTK).
|
// MacOS specific code for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@@ -93,6 +93,11 @@ extern Fl_Window* fl_xmousewin;
|
|||||||
enum { kEventClassFLTK = 'fltk' };
|
enum { kEventClassFLTK = 'fltk' };
|
||||||
enum { kEventFLTKBreakLoop = 1 };
|
enum { kEventFLTKBreakLoop = 1 };
|
||||||
|
|
||||||
|
// these pointers are set by the Fl::lock() function:
|
||||||
|
static void nothing() {}
|
||||||
|
void (*fl_lock_function)() = nothing;
|
||||||
|
void (*fl_unlock_function)() = nothing;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \todo This funtion is not yet implemented!
|
* \todo This funtion is not yet implemented!
|
||||||
@@ -154,6 +159,9 @@ int fl_ready()
|
|||||||
static pascal OSStatus carbonDispatchHandler( EventHandlerCallRef nextHandler, EventRef event, void *userData )
|
static pascal OSStatus carbonDispatchHandler( EventHandlerCallRef nextHandler, EventRef event, void *userData )
|
||||||
{
|
{
|
||||||
OSStatus ret = eventNotHandledErr;
|
OSStatus ret = eventNotHandledErr;
|
||||||
|
|
||||||
|
fl_lock_function();
|
||||||
|
|
||||||
switch ( GetEventClass( event ) )
|
switch ( GetEventClass( event ) )
|
||||||
{
|
{
|
||||||
case kEventClassMouse:
|
case kEventClassMouse:
|
||||||
@@ -180,6 +188,9 @@ 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();
|
QuitApplicationEventLoop();
|
||||||
|
|
||||||
|
fl_unlock_function();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +200,11 @@ static pascal OSStatus carbonDispatchHandler( EventHandlerCallRef nextHandler, E
|
|||||||
*/
|
*/
|
||||||
static void timerProcCB( EventLoopTimerRef, void* )
|
static void timerProcCB( EventLoopTimerRef, void* )
|
||||||
{
|
{
|
||||||
|
fl_lock_function();
|
||||||
|
|
||||||
QuitApplicationEventLoop();
|
QuitApplicationEventLoop();
|
||||||
|
|
||||||
|
fl_unlock_function();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -199,9 +214,14 @@ static void timerProcCB( EventLoopTimerRef, void* )
|
|||||||
static void breakMacEventLoop()
|
static void breakMacEventLoop()
|
||||||
{
|
{
|
||||||
EventRef breakEvent;
|
EventRef breakEvent;
|
||||||
|
|
||||||
|
fl_lock_function();
|
||||||
|
|
||||||
CreateEvent( 0, kEventClassFLTK, kEventFLTKBreakLoop, 0, kEventAttributeUserEvent, &breakEvent );
|
CreateEvent( 0, kEventClassFLTK, kEventFLTKBreakLoop, 0, kEventAttributeUserEvent, &breakEvent );
|
||||||
PostEventToQueue( GetCurrentEventQueue(), breakEvent, kEventPriorityStandard );
|
PostEventToQueue( GetCurrentEventQueue(), breakEvent, kEventPriorityStandard );
|
||||||
ReleaseEvent( breakEvent );
|
ReleaseEvent( breakEvent );
|
||||||
|
|
||||||
|
fl_unlock_function();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -251,10 +271,15 @@ static double do_queued_events( double time = 0.0 )
|
|||||||
ret = InstallEventHandler( target, dispatchHandler, 15, dispatchEvents, 0, 0L );
|
ret = InstallEventHandler( target, dispatchHandler, 15, dispatchEvents, 0, 0L );
|
||||||
ret = InstallEventLoopTimer( GetMainEventLoop(), 0, 0, NewEventLoopTimerUPP( timerProcCB ), 0, &timer );
|
ret = InstallEventLoopTimer( GetMainEventLoop(), 0, 0, NewEventLoopTimerUPP( timerProcCB ), 0, &timer );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( time > 0.0 )
|
if ( time > 0.0 )
|
||||||
{
|
{
|
||||||
|
fl_unlock_function();
|
||||||
|
|
||||||
SetEventLoopTimerNextFireTime( timer, time );
|
SetEventLoopTimerNextFireTime( timer, time );
|
||||||
RunApplicationEventLoop(); // wil return after the previously set time
|
RunApplicationEventLoop(); // will return after the previously set time
|
||||||
|
|
||||||
|
fl_lock_function();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -266,11 +291,12 @@ static double do_queued_events( double time = 0.0 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONSOLIDATE_MOTION
|
#if CONSOLIDATE_MOTION
|
||||||
if (send_motion && send_motion == fl_xmousewin) {
|
if (send_motion && send_motion == fl_xmousewin) {
|
||||||
send_motion = 0;
|
send_motion = 0;
|
||||||
Fl::handle(FL_MOVE, fl_xmousewin);
|
Fl::handle(FL_MOVE, fl_xmousewin);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,13 +320,20 @@ double fl_wait( double time )
|
|||||||
*/
|
*/
|
||||||
static OSErr QuitAppleEventHandler( const AppleEvent *appleEvt, AppleEvent* reply, UInt32 refcon )
|
static OSErr QuitAppleEventHandler( const AppleEvent *appleEvt, AppleEvent* reply, UInt32 refcon )
|
||||||
{
|
{
|
||||||
|
fl_lock_function();
|
||||||
|
|
||||||
while ( Fl_X::first ) {
|
while ( Fl_X::first ) {
|
||||||
Fl_X *x = Fl_X::first;
|
Fl_X *x = Fl_X::first;
|
||||||
Fl::handle( FL_CLOSE, x->w );
|
Fl::handle( FL_CLOSE, x->w );
|
||||||
if ( Fl_X::first == x )
|
if ( Fl_X::first == x ) {
|
||||||
|
fl_unlock_function();
|
||||||
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ExitToShell();
|
ExitToShell();
|
||||||
|
|
||||||
|
fl_unlock_function();
|
||||||
|
|
||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,6 +352,8 @@ static pascal OSStatus carbonWindowHandler( EventHandlerCallRef nextHandler, Eve
|
|||||||
WindowClass winClass;
|
WindowClass winClass;
|
||||||
static Fl_Window *activeWindow = 0;
|
static Fl_Window *activeWindow = 0;
|
||||||
|
|
||||||
|
fl_lock_function();
|
||||||
|
|
||||||
switch ( kind )
|
switch ( kind )
|
||||||
{
|
{
|
||||||
case kEventWindowDrawContent:
|
case kEventWindowDrawContent:
|
||||||
@@ -370,6 +405,8 @@ static pascal OSStatus carbonWindowHandler( EventHandlerCallRef nextHandler, Eve
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fl_unlock_function();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,6 +419,9 @@ static pascal OSStatus carbonMousewheelHandler( EventHandlerCallRef nextHandler,
|
|||||||
{
|
{
|
||||||
Fl_Window *window = (Fl_Window*)userData;
|
Fl_Window *window = (Fl_Window*)userData;
|
||||||
EventMouseWheelAxis axis;
|
EventMouseWheelAxis axis;
|
||||||
|
|
||||||
|
fl_lock_function();
|
||||||
|
|
||||||
GetEventParameter( event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(EventMouseWheelAxis), NULL, &axis );
|
GetEventParameter( event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(EventMouseWheelAxis), NULL, &axis );
|
||||||
long delta;
|
long delta;
|
||||||
GetEventParameter( event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(long), NULL, &delta );
|
GetEventParameter( event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(long), NULL, &delta );
|
||||||
@@ -395,7 +435,14 @@ static pascal OSStatus carbonMousewheelHandler( EventHandlerCallRef nextHandler,
|
|||||||
Fl::e_dy = -delta;
|
Fl::e_dy = -delta;
|
||||||
if ( Fl::e_dy) Fl::handle( FL_MOUSEWHEEL, window );
|
if ( Fl::e_dy) Fl::handle( FL_MOUSEWHEEL, window );
|
||||||
}
|
}
|
||||||
else return eventNotHandledErr;
|
else {
|
||||||
|
fl_unlock_function();
|
||||||
|
|
||||||
|
return eventNotHandledErr;
|
||||||
|
}
|
||||||
|
|
||||||
|
fl_unlock_function();
|
||||||
|
|
||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,6 +468,9 @@ static pascal OSStatus carbonMouseHandler( EventHandlerCallRef nextHandler, Even
|
|||||||
{
|
{
|
||||||
static int keysym[] = { 0, FL_Button+1, FL_Button+3, FL_Button+2 };
|
static int keysym[] = { 0, FL_Button+1, FL_Button+3, FL_Button+2 };
|
||||||
static int px, py;
|
static int px, py;
|
||||||
|
|
||||||
|
fl_lock_function();
|
||||||
|
|
||||||
fl_os_event = event;
|
fl_os_event = event;
|
||||||
Fl_Window *window = (Fl_Window*)userData;
|
Fl_Window *window = (Fl_Window*)userData;
|
||||||
Point pos;
|
Point pos;
|
||||||
@@ -437,8 +487,10 @@ static pascal OSStatus carbonMouseHandler( EventHandlerCallRef nextHandler, Even
|
|||||||
{
|
{
|
||||||
case kEventMouseDown:
|
case kEventMouseDown:
|
||||||
part = FindWindow( pos, &tempXid );
|
part = FindWindow( pos, &tempXid );
|
||||||
if ( part != inContent )
|
if ( part != inContent ) {
|
||||||
|
fl_unlock_function();
|
||||||
return CallNextEventHandler( nextHandler, event ); // let the OS handle this for us
|
return CallNextEventHandler( nextHandler, event ); // let the OS handle this for us
|
||||||
|
}
|
||||||
if ( !IsWindowActive( xid ) )
|
if ( !IsWindowActive( xid ) )
|
||||||
CallNextEventHandler( nextHandler, event ); // let the OS handle the activation, but continue to get a click-through effect
|
CallNextEventHandler( nextHandler, event ); // let the OS handle the activation, but continue to get a click-through effect
|
||||||
// normal handling of mouse-down follows
|
// normal handling of mouse-down follows
|
||||||
@@ -479,6 +531,9 @@ static pascal OSStatus carbonMouseHandler( EventHandlerCallRef nextHandler, Even
|
|||||||
Fl::handle( sendEvent, window );
|
Fl::handle( sendEvent, window );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fl_unlock_function();
|
||||||
|
|
||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,6 +583,9 @@ pascal OSStatus carbonKeyboardHandler( EventHandlerCallRef nextHandler, EventRef
|
|||||||
Fl_Window *window = (Fl_Window*)userData;
|
Fl_Window *window = (Fl_Window*)userData;
|
||||||
UInt32 mods;
|
UInt32 mods;
|
||||||
static UInt32 prevMods = 0xffffffff;
|
static UInt32 prevMods = 0xffffffff;
|
||||||
|
|
||||||
|
fl_lock_function();
|
||||||
|
|
||||||
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &mods );
|
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &mods );
|
||||||
if ( prevMods == 0xffffffff ) prevMods = mods;
|
if ( prevMods == 0xffffffff ) prevMods = mods;
|
||||||
UInt32 keyCode;
|
UInt32 keyCode;
|
||||||
@@ -572,8 +630,15 @@ pascal OSStatus carbonKeyboardHandler( EventHandlerCallRef nextHandler, EventRef
|
|||||||
break; }
|
break; }
|
||||||
}
|
}
|
||||||
while (window->parent()) window = window->window();
|
while (window->parent()) window = window->window();
|
||||||
if (sendEvent && Fl::handle(sendEvent,window)) return noErr; // return noErr if FLTK handled the event
|
if (sendEvent && Fl::handle(sendEvent,window)) {
|
||||||
return CallNextEventHandler( nextHandler, event );;
|
fl_unlock_function();
|
||||||
|
|
||||||
|
return noErr; // return noErr if FLTK handled the event
|
||||||
|
} else {
|
||||||
|
fl_unlock_function();
|
||||||
|
|
||||||
|
return CallNextEventHandler( nextHandler, event );;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1364,6 +1429,6 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
|
|||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_mac.cxx,v 1.1.2.21 2002/04/15 20:30:06 easysw Exp $".
|
// End of "$Id: Fl_mac.cxx,v 1.1.2.22 2002/04/16 15:49:06 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user