2003/09/13 05:10:15
[org.ibex.core.git] / src / org / xwt / plat / Darwin.cc
index 76c4fd6..716719f 100644 (file)
@@ -7,6 +7,9 @@
 #define APPLE_GCC
 #endif
 
+#define __private_extern__
+#include <mach-o/dyld.h>
+
 #include "POSIX.cc"
 #include "OpenGL.cc"
 
 #include <org/xwt/Proxy.h>
 #include <org/xwt/util/Semaphore.h>
 
-#include <Carbon/Carbon.h>
-#include <CoreFoundation/CoreFoundation.h>
-// For proxy stuff
-#include <SystemConfiguration/SystemConfiguration.h>
-// For LSOpenURLRef
-#include <ApplicationServices/ApplicationServices.h>
+#include <stdlib.h>
 
-#include <AGL/agl.h>
+#include "DarwinCarbonHeaders.h"
 
-#include <stdlib.h>
+#define XWT_CARBON_NO_BUNDLE_HACK
+#ifdef XWT_CARBON_NO_BUNDLE_HACK
+extern "C" {
+    OSErr CPSEnableForegroundOperation(ProcessSerialNumber *psn);
+    OSErr CPSSetFrontProcess(ProcessSerialNumber *psn);
+}
+#endif
+
+#include "DarwinWeakSymbols.h"
 
 using namespace org::xwt::plat;
 using gnu::gcj::RawData;
@@ -45,8 +51,8 @@ namespace org { namespace xwt { namespace plat {
 namespace darwin { }
 using namespace darwin;
 
-#pragma mark ------ Carbon Namespace ------
-namespace darwin {
+#pragma mark ------ Darwin Namespace ------
+
     // We put everything that isn't in org.xwt.plat.Darwin in 
     // org.xwt.plat.darwin to prevent namespace conflicts
     
@@ -125,10 +131,10 @@ namespace darwin {
     const static UInt32 kEventCarbonMessage = 'xwtb';
     const static UInt32 kEventParamCarbonMessage = 'xwtc';
     
-    pascal OSStatus darwin::carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData);
+    OSStatus our_carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData);
     void fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData);
 
-} // end namespace
+
 
 jboolean Darwin::isJaguar() {
     SInt32 version;
@@ -137,10 +143,14 @@ jboolean Darwin::isJaguar() {
     return version >= 0x1020;
 }
 
+void Darwin::linkMe() {
+    load_weak_symbols();
+}
+
 void Darwin$CarbonMessage::natInit() {
     OSStatus r;
     
-    EventHandlerUPP upp = NewEventHandlerUPP(carbonMessageEventHandler);
+    EventHandlerUPP upp = NewEventHandlerUPP(our_carbonMessageEventHandler);
     EventTypeSpec eventTypes = { kEventClassCarbonMessage, kEventCarbonMessage };
     r = InstallEventHandler(GetApplicationEventTarget(),upp,1,&eventTypes,NULL,NULL);
     checkStatus(r,"InstallEventHandler");
@@ -162,7 +172,7 @@ void Darwin$CarbonMessage::add(Darwin$CarbonMessage *msg) {
 }
 
 
-pascal OSStatus darwin::carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) {
+OSStatus our_carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) {
     UInt32 eKind = GetEventKind(e);
     UInt32 eClass = GetEventClass(e);
     OSStatus r;
@@ -179,7 +189,7 @@ pascal OSStatus darwin::carbonMessageEventHandler(EventHandlerCallRef handler, E
 
 #pragma mark ------ Utility Functions ------
 
-void darwin::funcFailed(char *func,int r){
+void funcFailed(char *func,int r){
     fprintf(stderr,"%s() failed (%d)\n",func,r);
     exit(EXIT_FAILURE);
 } 
@@ -273,7 +283,7 @@ static const EventTypeSpec eventTypeSpecs[] = {
     { kEventClassMouse, kEventMouseWheelMoved },
 };
     
-pascal OSStatus windowEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) {
+OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) {
     Darwin$CarbonSurface *surface = (Darwin$CarbonSurface*) userData;
     UInt32 eKind = GetEventKind(e);
     UInt32 eClass = GetEventClass(e);
@@ -532,7 +542,7 @@ void Darwin$CarbonSurface::natInit(jboolean framed) {
     checkStatus(r,"CreateNewWindow");
     
     GCJ$Retainer::retain(this); // Need to account for the EventHandlers pointer to us
-    EventHandlerUPP upp = NewEventHandlerUPP(windowEventHandler);
+    EventHandlerUPP upp = NewEventHandlerUPP(our_windowEventHandler);
     
     r = InstallWindowEventHandler(window,upp,sizeof(eventTypeSpecs)/sizeof(EventTypeSpec),eventTypeSpecs,this,NULL);
     checkStatus(r,"InstallWindowEventHandler");
@@ -593,7 +603,7 @@ void Darwin$CarbonSurface::natSetLimits(jint minw, jint minh, jint maxw, jint ma
 
 
 #pragma mark ------ Carbon Methods ------
-void darwin::fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData) {
+void fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData) {
     Darwin$FileDialogHelper *helper = (Darwin$FileDialogHelper*) userData;
     NavDialogRef dialog = callBackParms->context;
     OSStatus r;
@@ -637,7 +647,7 @@ void Darwin::natFileDialog(Darwin$FileDialogHelper *helper,jstring suggestion_,
     WindowRef window = FrontWindow();
     NavDialogCreationOptions options;
         
-    NavEventUPP handler = NewNavEventUPP(darwin::fileDialogEventHandler);
+    NavEventUPP handler = NewNavEventUPP(fileDialogEventHandler);
     
     NavGetDefaultDialogCreationOptions(&options);
     options.optionFlags =
@@ -807,11 +817,11 @@ doproto(SOCKS,socks)
 }
 
 jint Darwin::cgScreenWidth() {
-    return CGDisplayPixelsWide(kCGDirectMainDisplay);
+    return CGDisplayPixelsWide(((CGDirectDisplayID)0));
 }
 
 jint Darwin::cgScreenHeight() {
-    return CGDisplayPixelsHigh(kCGDirectMainDisplay);
+    return CGDisplayPixelsHigh(((CGDirectDisplayID)0));
 }
 
 void Darwin::_newBrowserWindow(jstring js) {
@@ -827,13 +837,6 @@ void Darwin::_exit() {
     QuitApplicationEventLoop();
 }
 
-#define XWT_CARBON_NO_BUNDLE_HACK
-#ifdef XWT_CARBON_NO_BUNDLE_HACK
-extern "C" {
-    OSErr CPSEnableForegroundOperation(ProcessSerialNumber *psn);
-    OSErr CPSSetFrontProcess(ProcessSerialNumber *psn);
-}
-#endif
 void Darwin::natInit() {     
     OSStatus r;
     #ifdef XWT_CARBON_NO_BUNDLE_HACK
@@ -1059,3 +1062,6 @@ void Darwin$GLCarbonSurface::natDispose() {
 }
 
 } } } // end namepsace org::xwt::plat
+
+
+