ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/Darwin/gtk-osx-loop.patch
Revision: 1.2
Committed: 2006-05-05T05:56:52Z (18 years, 6 months ago) by gbeauche
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Error occurred while calculating annotation data.
Log Message:
remove

File Contents

# Content
1 2006-04-17 Gwenole Beauchesne <gb.public@free.fr>
2
3 * glib-1.2.10/gmain.c (g_main_run): Don't block in
4 RunApplicationEventLoop(), code inspired from Inside Mac
5 technote.
6
7 Patch to apply to raw GTK+OSX 0.7 distribution.
8
9 --- ../gmain.c~ Sat Dec 27 22:23:06 2003
10 +++ ../gmain.c Mon Apr 17 22:12:15 2006
11 @@ -145,6 +145,7 @@
12 gpointer user_data);
13
14 #ifdef MAC_CARBON_EVENTS
15 +static void mac_run_application_event_loop (GMainLoop *loop);
16 static void mac_handle_idle_action (EventLoopTimerRef timer_ref,
17 EventLoopIdleTimerMessage state,
18 void* user_data);
19 @@ -1116,7 +1117,7 @@
20 loop->is_running = TRUE;
21
22 #ifdef MAC_CARBON_EVENTS
23 - RunApplicationEventLoop ();
24 + mac_run_application_event_loop (loop);
25 #else
26 while (loop->is_running)
27 g_main_iterate (TRUE, TRUE);
28 @@ -1870,4 +1871,94 @@
29 #endif
30 }
31
32 -#endif /* MAC_CARBON_EVENTS */
33 \ No newline at end of file
34 +static EventHandlerUPP g_quit_event_handler_upp;
35 +
36 +static pascal OSStatus QuitEventHandler(EventHandlerCallRef inHandlerCallRef,
37 + EventRef inEvent, void *inUserData)
38 +{
39 + OSStatus err;
40 +
41 + if ((err = CallNextEventHandler(inHandlerCallRef, inEvent)) == noErr)
42 + *((Boolean *)inUserData) = TRUE;
43 +
44 + return err;
45 +}
46 +
47 +static EventHandlerUPP g_event_loop_event_handler_upp;
48 +
49 +static pascal OSStatus EventLoopEventHandler(EventHandlerCallRef inHandlerCallRef,
50 + EventRef inEvent, void *inUserData)
51 +{
52 + OSStatus err;
53 + OSStatus junk;
54 + EventHandlerRef installedHandler;
55 + EventTargetRef theTarget;
56 + EventRef theEvent;
57 + EventTimeout timeToWaitForEvent;
58 + Boolean quitNow;
59 + GMainLoop * loop = (GMainLoop *)inUserData;
60 + static const EventTypeSpec eventSpec = {kEventClassApplication, kEventAppQuit};
61 +
62 + quitNow = false;
63 +
64 + err = InstallEventHandler(GetApplicationEventTarget(),
65 + g_quit_event_handler_upp,
66 + 1, &eventSpec, &quitNow, &installedHandler);
67 + if (err == noErr) {
68 + theTarget = GetEventDispatcherTarget();
69 + do {
70 + timeToWaitForEvent = kEventDurationNoWait;
71 + err = ReceiveNextEvent(0, NULL, timeToWaitForEvent,
72 + true, &theEvent);
73 + if (err == noErr) {
74 + SendEventToEventTarget(theEvent, theTarget);
75 + ReleaseEvent(theEvent);
76 + }
77 + YieldToAnyThread();
78 + } while ( loop->is_running && ! quitNow );
79 + junk = RemoveEventHandler(installedHandler);
80 + }
81 +
82 + return err;
83 +}
84 +
85 +static void
86 +mac_run_application_event_loop (GMainLoop *loop)
87 +{
88 + static const EventTypeSpec eventSpec = {'KWIN', 'KWIN' };
89 + OSStatus err;
90 + OSStatus junk;
91 + EventHandlerRef installedHandler;
92 + EventRef dummyEvent;
93 +
94 + dummyEvent = nil;
95 +
96 + err = noErr;
97 + if (g_event_loop_event_handler_upp == nil)
98 + g_event_loop_event_handler_upp = NewEventHandlerUPP(EventLoopEventHandler);
99 + if (g_quit_event_handler_upp == nil)
100 + g_quit_event_handler_upp = NewEventHandlerUPP(QuitEventHandler);
101 + if (g_event_loop_event_handler_upp == nil || g_quit_event_handler_upp == nil)
102 + err = memFullErr;
103 +
104 + if (err == noErr) {
105 + err = InstallEventHandler(GetApplicationEventTarget(),
106 + g_event_loop_event_handler_upp,
107 + 1, &eventSpec, loop, &installedHandler);
108 + if (err == noErr) {
109 + err = MacCreateEvent(nil, 'KWIN', 'KWIN', GetCurrentEventTime(),
110 + kEventAttributeNone, &dummyEvent);
111 + if (err == noErr)
112 + err = PostEventToQueue(GetMainEventQueue(), dummyEvent,
113 + kEventPriorityHigh);
114 + if (err == noErr)
115 + RunApplicationEventLoop();
116 +
117 + junk = RemoveEventHandler(installedHandler);
118 + }
119 + }
120 +
121 + if (dummyEvent != nil)
122 + ReleaseEvent(dummyEvent);
123 +}
124 +#endif /* MAC_CARBON_EVENTS */