From 62389bb3c0ebcc9bc3409e989c0e758fcd7b95da Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Mon, 1 May 2006 23:09:12 +0000 Subject: [PATCH] Add my local changes to GTK+OSX 0.7 -- it's only correct for Basilisk II and SheepShaver purposes. i.e. it's not fully suitable as a generic g_main_run() replacement. --- BasiliskII/src/Unix/Darwin/gtk-osx-loop.patch | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 BasiliskII/src/Unix/Darwin/gtk-osx-loop.patch diff --git a/BasiliskII/src/Unix/Darwin/gtk-osx-loop.patch b/BasiliskII/src/Unix/Darwin/gtk-osx-loop.patch new file mode 100644 index 00000000..45f35fa2 --- /dev/null +++ b/BasiliskII/src/Unix/Darwin/gtk-osx-loop.patch @@ -0,0 +1,124 @@ +2006-04-17 Gwenole Beauchesne + + * glib-1.2.10/gmain.c (g_main_run): Don't block in + RunApplicationEventLoop(), code inspired from Inside Mac + technote. + + Patch to apply to raw GTK+OSX 0.7 distribution. + +--- ../gmain.c~ Sat Dec 27 22:23:06 2003 ++++ ../gmain.c Mon Apr 17 22:12:15 2006 +@@ -145,6 +145,7 @@ + gpointer user_data); + + #ifdef MAC_CARBON_EVENTS ++static void mac_run_application_event_loop (GMainLoop *loop); + static void mac_handle_idle_action (EventLoopTimerRef timer_ref, + EventLoopIdleTimerMessage state, + void* user_data); +@@ -1116,7 +1117,7 @@ + loop->is_running = TRUE; + + #ifdef MAC_CARBON_EVENTS +- RunApplicationEventLoop (); ++ mac_run_application_event_loop (loop); + #else + while (loop->is_running) + g_main_iterate (TRUE, TRUE); +@@ -1870,4 +1871,94 @@ + #endif + } + +-#endif /* MAC_CARBON_EVENTS */ +\ No newline at end of file ++static EventHandlerUPP g_quit_event_handler_upp; ++ ++static pascal OSStatus QuitEventHandler(EventHandlerCallRef inHandlerCallRef, ++ EventRef inEvent, void *inUserData) ++{ ++ OSStatus err; ++ ++ if ((err = CallNextEventHandler(inHandlerCallRef, inEvent)) == noErr) ++ *((Boolean *)inUserData) = TRUE; ++ ++ return err; ++} ++ ++static EventHandlerUPP g_event_loop_event_handler_upp; ++ ++static pascal OSStatus EventLoopEventHandler(EventHandlerCallRef inHandlerCallRef, ++ EventRef inEvent, void *inUserData) ++{ ++ OSStatus err; ++ OSStatus junk; ++ EventHandlerRef installedHandler; ++ EventTargetRef theTarget; ++ EventRef theEvent; ++ EventTimeout timeToWaitForEvent; ++ Boolean quitNow; ++ GMainLoop * loop = (GMainLoop *)inUserData; ++ static const EventTypeSpec eventSpec = {kEventClassApplication, kEventAppQuit}; ++ ++ quitNow = false; ++ ++ err = InstallEventHandler(GetApplicationEventTarget(), ++ g_quit_event_handler_upp, ++ 1, &eventSpec, &quitNow, &installedHandler); ++ if (err == noErr) { ++ theTarget = GetEventDispatcherTarget(); ++ do { ++ timeToWaitForEvent = kEventDurationNoWait; ++ err = ReceiveNextEvent(0, NULL, timeToWaitForEvent, ++ true, &theEvent); ++ if (err == noErr) { ++ SendEventToEventTarget(theEvent, theTarget); ++ ReleaseEvent(theEvent); ++ } ++ YieldToAnyThread(); ++ } while ( loop->is_running && ! quitNow ); ++ junk = RemoveEventHandler(installedHandler); ++ } ++ ++ return err; ++} ++ ++static void ++mac_run_application_event_loop (GMainLoop *loop) ++{ ++ static const EventTypeSpec eventSpec = {'KWIN', 'KWIN' }; ++ OSStatus err; ++ OSStatus junk; ++ EventHandlerRef installedHandler; ++ EventRef dummyEvent; ++ ++ dummyEvent = nil; ++ ++ err = noErr; ++ if (g_event_loop_event_handler_upp == nil) ++ g_event_loop_event_handler_upp = NewEventHandlerUPP(EventLoopEventHandler); ++ if (g_quit_event_handler_upp == nil) ++ g_quit_event_handler_upp = NewEventHandlerUPP(QuitEventHandler); ++ if (g_event_loop_event_handler_upp == nil || g_quit_event_handler_upp == nil) ++ err = memFullErr; ++ ++ if (err == noErr) { ++ err = InstallEventHandler(GetApplicationEventTarget(), ++ g_event_loop_event_handler_upp, ++ 1, &eventSpec, loop, &installedHandler); ++ if (err == noErr) { ++ err = MacCreateEvent(nil, 'KWIN', 'KWIN', GetCurrentEventTime(), ++ kEventAttributeNone, &dummyEvent); ++ if (err == noErr) ++ err = PostEventToQueue(GetMainEventQueue(), dummyEvent, ++ kEventPriorityHigh); ++ if (err == noErr) ++ RunApplicationEventLoop(); ++ ++ junk = RemoveEventHandler(installedHandler); ++ } ++ } ++ ++ if (dummyEvent != nil) ++ ReleaseEvent(dummyEvent); ++} ++#endif /* MAC_CARBON_EVENTS */