- Timestamp:
- Sep 17, 2009 8:31:00 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/xpcom/threads/plevent.c
r1 r23073 69 69 #endif 70 70 71 #if defined(XP_MAC) || defined(XP_MACOSX) 72 #if !defined(MOZ_WIDGET_COCOA) && TARGET_CARBON 73 #include <CarbonEvents.h> 74 #define MAC_USE_CARBON_EVENT 75 #else 76 #include <Processes.h> 77 #define MAC_USE_WAKEUPPROCESS 78 #endif 79 #endif 80 81 #if defined(XP_MAC) 82 #include "pprthred.h" 83 #else 71 #if defined(XP_MACOSX) 72 #if defined(MOZ_WIDGET_COCOA) 73 #include <CoreFoundation/CoreFoundation.h> 74 #define MAC_USE_CFRUNLOOPSOURCE 75 #elif defined(TARGET_CARBON) 76 /* #include <CarbonEvents.h> */ 77 /* #define MAC_USE_CARBON_EVENT */ 78 #include <CoreFoundation/CoreFoundation.h> 79 #define MAC_USE_CFRUNLOOPSOURCE 80 #endif 81 #endif 82 84 83 #include "private/pprthred.h" 85 #endif /* defined(XP_MAC) */86 84 87 85 #if defined(VMS) … … 152 150 PRPackedBool processingEvents; 153 151 PRPackedBool notified; 154 #if defined(_WIN32) 152 #if defined(_WIN32) 155 153 PRPackedBool timerSet; 156 154 #endif … … 169 167 #elif defined(XP_BEOS) 170 168 port_id eventport; 171 #elif defined(XP_MAC) || defined(XP_MACOSX) 172 #if defined(MAC_USE_CARBON_EVENT) 169 #elif defined(XP_MACOSX) 170 #if defined(MAC_USE_CFRUNLOOPSOURCE) 171 CFRunLoopSourceRef mRunLoopSource; 172 CFRunLoopRef mMainRunLoop; 173 #elif defined(MAC_USE_CARBON_EVENT) 173 174 EventHandlerUPP eventHandlerUPP; 174 175 EventHandlerRef eventHandlerRef; 175 #elif defined(MAC_USE_WAKEUPPROCESS)176 ProcessSerialNumber psn;177 176 #endif 178 177 #endif … … 259 258 self->removeMsg = PR_TRUE; 260 259 #endif 261 #if defined(MAC_USE_WAKEUPPROCESS)262 self->psn.lowLongOfPSN = kNoProcess;263 #endif264 260 265 261 self->notified = PR_FALSE; … … 286 282 } 287 283 288 PR_EXTERN(PLEventQueue *) 284 PR_EXTERN(PLEventQueue *) 289 285 PL_CreateNativeEventQueue(const char *name, PRThread *handlerThread) 290 286 { … … 292 288 } 293 289 294 PR_EXTERN(PLEventQueue *) 290 PR_EXTERN(PLEventQueue *) 295 291 PL_CreateMonitoredEventQueue(const char *name, PRThread *handlerThread) 296 292 { … … 307 303 _pl_destroyEvent(PLEvent* event, void* data, PLEventQueue* queue) 308 304 { 309 #ifdef XP_MAC310 #pragma unused (data, queue)311 #endif312 305 PL_DequeueEvent(event, queue); 313 306 PL_DestroyEvent(event); … … 735 728 PL_DequeueEvent(PLEvent* self, PLEventQueue* queue) 736 729 { 737 #ifdef XP_MAC738 #pragma unused (queue)739 #endif740 730 if (self == NULL) 741 731 return; … … 851 841 _pl_SetupNativeNotifier(PLEventQueue* self) 852 842 { 853 #if defined(XP_MAC)854 #pragma unused (self)855 #endif856 857 843 #if defined(VMS) 858 844 unsigned int status; … … 907 893 char portname[64]; 908 894 char semname[64]; 909 PR_snprintf(portname, sizeof(portname), "event%lx", 895 PR_snprintf(portname, sizeof(portname), "event%lx", 910 896 (long unsigned) self->handlerThread); 911 PR_snprintf(semname, sizeof(semname), "sync%lx", 897 PR_snprintf(semname, sizeof(semname), "sync%lx", 912 898 (long unsigned) self->handlerThread); 913 899 … … 932 918 _pl_CleanupNativeNotifier(PLEventQueue* self) 933 919 { 934 #if defined(XP_MAC)935 #pragma unused (self)936 #endif937 938 920 #if defined(VMS) 939 921 { … … 953 935 RemoveProp(self->eventReceiverWindow, _md_GetEventQueuePropName()); 954 936 955 /* DestroyWindow doesn't do anything when called from a non ui thread. Since 937 /* DestroyWindow doesn't do anything when called from a non ui thread. Since 956 938 * self->eventReceiverWindow was created on the ui thread, it must be destroyed 957 939 * on the ui thread. … … 961 943 #elif defined(XP_OS2) 962 944 WinDestroyWindow(self->eventReceiverWindow); 945 #elif defined(MAC_USE_CFRUNLOOPSOURCE) 946 947 CFRunLoopRemoveSource(self->mMainRunLoop, self->mRunLoopSource, kCFRunLoopCommonModes); 948 CFRelease(self->mRunLoopSource); 949 CFRelease(self->mMainRunLoop); 950 963 951 #elif defined(MAC_USE_CARBON_EVENT) 964 952 EventComparatorUPP comparator = NewEventComparatorUPP(_md_CarbonEventComparator); … … 1259 1247 #endif /* XP_BEOS */ 1260 1248 1261 #if defined(XP_MAC ) || defined(XP_MACOSX)1249 #if defined(XP_MACOSX) 1262 1250 static PRStatus 1263 1251 _pl_NativeNotify(PLEventQueue* self) 1264 1252 { 1265 #if defined(MAC_USE_CARBON_EVENT) 1253 #if defined(MAC_USE_CFRUNLOOPSOURCE) 1254 CFRunLoopSourceSignal(self->mRunLoopSource); 1255 CFRunLoopWakeUp(self->mMainRunLoop); 1256 #elif defined(MAC_USE_CARBON_EVENT) 1266 1257 OSErr err; 1267 1258 EventRef newEvent; … … 1277 1268 if (err != noErr) 1278 1269 return PR_FAILURE; 1279 #elif defined(MAC_USE_WAKEUPPROCESS)1280 WakeUpProcess(&self->psn);1281 1270 #endif 1282 1271 return PR_SUCCESS; 1283 1272 } 1284 #endif /* defined(XP_MAC ) || defined(XP_MACOSX) */1273 #endif /* defined(XP_MACOSX) */ 1285 1274 1286 1275 static PRStatus … … 1341 1330 #else 1342 1331 1343 #if defined(XP_MAC)1344 #pragma unused (self)1345 #endif1346 1347 1332 /* nothing to do on the other platforms */ 1348 1333 return PR_SUCCESS; … … 1577 1562 #endif /* (defined(XP_UNIX) && !defined(XP_MACOSX)) || defined(XP_BEOS) */ 1578 1563 1579 #if defined(MAC_USE_CARBON_EVENT) 1564 #if defined(MAC_USE_CFRUNLOOPSOURCE) 1565 static void _md_EventReceiverProc(void *info) 1566 { 1567 PLEventQueue *queue = (PLEventQueue*)info; 1568 PL_ProcessPendingEvents(queue); 1569 } 1570 1571 #elif defined(MAC_USE_CARBON_EVENT) 1580 1572 /* 1581 1573 ** _md_CreateEventQueue() -- ModelDependent initializer … … 1619 1611 #endif /* defined(MAC_USE_CARBON_EVENT) */ 1620 1612 1621 #if defined(XP_MAC ) || defined(XP_MACOSX)1613 #if defined(XP_MACOSX) 1622 1614 static void _md_CreateEventQueue( PLEventQueue *eventQueue ) 1623 1615 { 1624 #if defined(MAC_USE_CARBON_EVENT) 1616 #if defined(MAC_USE_CFRUNLOOPSOURCE) 1617 CFRunLoopSourceContext sourceContext = { 0 }; 1618 sourceContext.version = 0; 1619 sourceContext.info = (void*)eventQueue; 1620 sourceContext.perform = _md_EventReceiverProc; 1621 1622 /* make a run loop source */ 1623 eventQueue->mRunLoopSource = CFRunLoopSourceCreate(kCFAllocatorDefault, 0 /* order */, &sourceContext); 1624 PR_ASSERT(eventQueue->mRunLoopSource); 1625 1626 eventQueue->mMainRunLoop = CFRunLoopGetCurrent(); 1627 CFRetain(eventQueue->mMainRunLoop); 1628 1629 /* and add it to the run loop */ 1630 CFRunLoopAddSource(eventQueue->mMainRunLoop, eventQueue->mRunLoopSource, kCFRunLoopCommonModes); 1631 1632 #elif defined(MAC_USE_CARBON_EVENT) 1625 1633 eventQueue->eventHandlerUPP = NewEventHandlerUPP(_md_EventReceiverProc); 1626 1634 PR_ASSERT(eventQueue->eventHandlerUPP); … … 1636 1644 PR_ASSERT(eventQueue->eventHandlerRef); 1637 1645 } 1638 #elif defined(MAC_USE_WAKEUPPROCESS)1639 OSErr err = GetCurrentProcess(&eventQueue->psn);1640 PR_ASSERT(err == noErr);1641 1646 #endif 1642 1647 } /* end _md_CreateEventQueue() */ 1643 #endif /* defined(XP_MAC ) || defined(XP_MACOSX) */1648 #endif /* defined(XP_MACOSX) */ 1644 1649 1645 1650 /* extra functions for unix */
Note:
See TracChangeset
for help on using the changeset viewer.