X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fplat%2FDarwin.cc;h=716719f412909144ab781be1685a30f68678b958;hb=cf3587e2fd5966b7ebfd721d9413674224d1ad2a;hp=cb08664c645b790b6a60a943e11344b4e6df2ca6;hpb=a31ea439cbb4e49894d8384c6c69e5fe8fae5619;p=org.ibex.core.git diff --git a/src/org/xwt/plat/Darwin.cc b/src/org/xwt/plat/Darwin.cc index cb08664..716719f 100644 --- a/src/org/xwt/plat/Darwin.cc +++ b/src/org/xwt/plat/Darwin.cc @@ -7,6 +7,9 @@ #define APPLE_GCC #endif +#define __private_extern__ +#include + #include "POSIX.cc" #include "OpenGL.cc" @@ -24,16 +27,19 @@ #include #include -#include -#include -// For proxy stuff -#include -// For LSOpenURLRef -#include +#include -#include +#include "DarwinCarbonHeaders.h" -#include +#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