From f8e2aa0c7c2b5bd2bca1808fb15dfc8e75d96d56 Mon Sep 17 00:00:00 2001 From: megacz Date: Fri, 30 Jan 2004 07:36:02 +0000 Subject: [PATCH] 2003/09/21 10:25:34 darcs-hash:20040130073602-2ba56-c07b985d2a3e2ca7f560c1b3cb84b82f96c8e08b.gz --- src/org/xwt/plat/Darwin.cc | 561 +++++++++++++++++++++----------- src/org/xwt/plat/Darwin.java | 2 - src/org/xwt/plat/DarwinCarbonHeaders.h | 1 + 3 files changed, 366 insertions(+), 198 deletions(-) diff --git a/src/org/xwt/plat/Darwin.cc b/src/org/xwt/plat/Darwin.cc index 068b766..6f4789d 100644 --- a/src/org/xwt/plat/Darwin.cc +++ b/src/org/xwt/plat/Darwin.cc @@ -28,7 +28,6 @@ #include #include -#include #include "DarwinCarbonHeaders.h" @@ -40,7 +39,125 @@ extern "C" { } #endif -#include "DarwinWeakSymbols.h" +static const mach_header* CarbonHandle = NULL; +static const mach_header* AGLHandle = NULL; +static const mach_header* SCHandle = NULL; +#define CARBON_LIBRARY_PATH "/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon" +#define AGL_LIBRARY_PATH "/System/Library/Frameworks/AGL.framework/Versions/A/AGL" +#define SC_LIBRARY_PATH "/System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration" + +static void* dlsym(char* symbol) { + if (CarbonHandle == NULL) CarbonHandle = NSAddImage(CARBON_LIBRARY_PATH, NSADDIMAGE_OPTION_NONE); + if (AGLHandle == NULL) AGLHandle = NSAddImage(AGL_LIBRARY_PATH, NSADDIMAGE_OPTION_NONE); + if (SCHandle == NULL) SCHandle = NSAddImage(SC_LIBRARY_PATH, NSADDIMAGE_OPTION_NONE); + void* ret = NSAddressOfSymbol(NSLookupSymbolInImage(CarbonHandle, symbol, + NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + if (ret == NULL) ret = NSAddressOfSymbol(NSLookupSymbolInImage(AGLHandle, symbol, + NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + if (ret == NULL) ret = NSAddressOfSymbol(NSLookupSymbolInImage(SCHandle, symbol, + NSLOOKUPSYMBOLINIMAGE_OPTION_BIND)); + printf("linking symbol %s to address %x\n", symbol, ret); + fflush(stdout); + return ret; +} + +#define declare_weak(symbol) typeof(symbol) *symbol##_weak = NULL +#define WC(func) \ + (*((func##_weak != NULL) ? func##_weak : func##_weak = (typeof(func##_weak))dlsym("_" #func))) + +declare_weak(GetRegionBounds); +declare_weak(RegisterToolboxObjectClass); +declare_weak(GetWindowProperty); +declare_weak(SetWindowProperty); +declare_weak(CreateCustomWindow); +declare_weak(InstallWindowContentPaintProc); +declare_weak(AEGetNthPtr); +declare_weak(CFArrayGetCount); +declare_weak(CFArrayGetTypeID); +declare_weak(CFArrayGetValueAtIndex); +declare_weak(CFDictionaryGetValue); +declare_weak(CFGetTypeID); +declare_weak(CFNumberGetTypeID); +declare_weak(CFNumberGetValue); +declare_weak(CFRelease); +declare_weak(CFStringCompare); +declare_weak(CFStringCreateWithCString); +declare_weak(CFStringCreateWithCharacters); +declare_weak(CFStringGetCharacters); +declare_weak(CFStringGetLength); +declare_weak(CFStringGetTypeID); +declare_weak(CFURLCopyScheme); +declare_weak(CFURLCreateWithString); +declare_weak(CGDisplayPixelsHigh); +declare_weak(CGDisplayPixelsWide); +declare_weak(CallNextEventHandler); +declare_weak(CollapseWindow); +declare_weak(ConstrainWindowToScreen); +declare_weak(CreateEvent); +declare_weak(CreateNewWindow); +declare_weak(DisposeEventHandlerUPP); +declare_weak(DisposeNavEventUPP); +declare_weak(DisposeWindow); +declare_weak(ExitToShell); +declare_weak(FSRefMakePath); +declare_weak(FrontWindow); +declare_weak(Gestalt); +declare_weak(GetApplicationEventTarget); +declare_weak(GetCurrentProcess); +declare_weak(GetCurrentScrap); +declare_weak(GetEventClass); +declare_weak(GetEventKind); +declare_weak(GetEventParameter); +declare_weak(GetMainEventQueue); +declare_weak(GetScrapFlavorData); +declare_weak(GetScrapFlavorSize); +declare_weak(GetWindowBounds); +declare_weak(GetWindowEventTarget); +declare_weak(GetWindowPort); +declare_weak(HideWindow); +declare_weak(InstallEventHandler); +declare_weak(IsWindowCollapsed); +declare_weak(LSOpenCFURLRef); +declare_weak(NavCreateGetFileDialog); +declare_weak(NavCreatePutFileDialog); +declare_weak(NavDialogDispose); +declare_weak(NavDialogGetReply); +declare_weak(NavDialogGetUserAction); +declare_weak(NavDialogRun); +declare_weak(NavDisposeReply); +declare_weak(NavGetDefaultDialogCreationOptions); +declare_weak(NewEventHandlerUPP); +declare_weak(NewNavEventUPP); +declare_weak(PostEventToQueue); +declare_weak(PutScrapFlavor); +declare_weak(QuitApplicationEventLoop); +declare_weak(ReleaseEvent); +declare_weak(RunApplicationEventLoop); +declare_weak(SCDynamicStoreCopyProxies); +declare_weak(SelectWindow); +declare_weak(SendBehind); +declare_weak(SetEventParameter); +declare_weak(SetThemeCursor); +declare_weak(SetWindowBounds); +declare_weak(SetWindowResizeLimits); +declare_weak(SetWindowTitleWithCFString); +declare_weak(ShowWindow); +declare_weak(ZoomWindowIdeal); +declare_weak(__CFStringMakeConstantString); +declare_weak(aglChoosePixelFormat); +declare_weak(aglCreateContext); +declare_weak(aglDestroyContext); +declare_weak(aglSetCurrentContext); +declare_weak(aglSetDrawable); +declare_weak(aglSurfaceTexture); +declare_weak(aglUpdateContext); +declare_weak(CPSEnableForegroundOperation); +declare_weak(CPSSetFrontProcess); +declare_weak(kCFAllocatorDefault); + +#define GetWindowEventTarget WC(GetWindowEventTarget) +#define InstallEventHandler WC(InstallEventHandler) +#define __CFStringMakeConstantString WC(__CFStringMakeConstantString) using namespace org::xwt::plat; using gnu::gcj::RawData; @@ -67,11 +184,11 @@ using namespace darwin; static inline void checkStatus(void *p, char *func) { if(!p) funcFailed(func,-1); } jstring cfStringToJString(CFStringRef s) { - CFIndex length = CFStringGetLength(s); + CFIndex length = WC(CFStringGetLength)(s); CFRange range = CFRangeMake(0,length); jstring js = JvAllocString(length); UniChar *buf = (UniChar*)JvGetStringChars(js); - CFStringGetCharacters(s,range,buf); + WC(CFStringGetCharacters)(s,range,buf); return js; } @@ -79,7 +196,7 @@ using namespace darwin; class SmartCFString { private: CFStringRef p; - void release() { if(p) CFRelease(p); } + void release() { if(p) WC(CFRelease)(p); } void checkNull() { if(!p) throw new java::lang::Error(JvNewStringLatin1("CFString function failed")); } public: // Constructors @@ -93,7 +210,7 @@ using namespace darwin; SmartCFString& operator= (const char *s) { release(); if(!s) s = "(null)"; - p = CFStringCreateWithCString(kCFAllocatorDefault,s,kCFStringEncodingISOLatin1); + p = WC(CFStringCreateWithCString)(WC(kCFAllocatorDefault),s,kCFStringEncodingISOLatin1); checkNull(); return *this; } @@ -102,7 +219,7 @@ using namespace darwin; release(); UniChar *buf = (UniChar*) JvGetStringChars(js); CFIndex length = js->length(); - p = CFStringCreateWithCharacters(kCFAllocatorDefault,buf,length); + p = WC(CFStringCreateWithCharacters)(WC(kCFAllocatorDefault),buf,length); checkNull(); return *this; } @@ -123,7 +240,7 @@ using namespace darwin; } bool equals(CFStringRef cfs) { - return CFStringCompare(p,cfs,0) == kCFCompareEqualTo; + return WC(CFStringCompare)(p,cfs,0) == kCFCompareEqualTo; } }; @@ -139,22 +256,18 @@ using namespace darwin; jboolean Darwin::isJaguar() { SInt32 version; - OSStatus r = Gestalt(gestaltSystemVersion, &version); - checkStatus(r,"Gestalt"); + OSStatus r = WC(Gestalt)(gestaltSystemVersion, &version); + checkStatus(r,"WC(Gestalt)"); return version >= 0x1020; } -void Darwin::linkMe() { - load_weak_symbols(); -} - void Darwin$CarbonMessage::natInit() { OSStatus r; - EventHandlerUPP upp = NewEventHandlerUPP(our_carbonMessageEventHandler); + EventHandlerUPP upp = WC(NewEventHandlerUPP)(our_carbonMessageEventHandler); EventTypeSpec eventTypes = { kEventClassCarbonMessage, kEventCarbonMessage }; - r = InstallEventHandler(GetApplicationEventTarget(),upp,1,&eventTypes,NULL,NULL); - checkStatus(r,"InstallEventHandler"); + r = InstallEventHandler(WC(GetApplicationEventTarget)(),upp,1,&eventTypes,NULL,NULL); + checkStatus(r,"WC(InstallEventHandler)"); } void Darwin$CarbonMessage::add(Darwin$CarbonMessage *msg) { @@ -163,25 +276,25 @@ void Darwin$CarbonMessage::add(Darwin$CarbonMessage *msg) { GCJ$Retainer::retain(msg); - r = CreateEvent(kCFAllocatorDefault,kEventClassCarbonMessage,kEventCarbonMessage,0,kEventAttributeNone,&event); - checkStatus(r,"CreateEvent"); - r = SetEventParameter(event,kEventParamCarbonMessage,typeVoidPtr,sizeof(msg),(void*)&msg); - checkStatus(r,"SetEventParameter"); - r = PostEventToQueue(GetMainEventQueue(),event,kEventPriorityHigh); - checkStatus(r,"PostEventToQueue"); - ReleaseEvent(event); + r = WC(CreateEvent)(WC(kCFAllocatorDefault),kEventClassCarbonMessage,kEventCarbonMessage,0,kEventAttributeNone,&event); + checkStatus(r,"WC(CreateEvent)"); + r = WC(SetEventParameter)(event,kEventParamCarbonMessage,typeVoidPtr,sizeof(msg),(void*)&msg); + checkStatus(r,"WC(SetEventParameter)"); + r = WC(PostEventToQueue)(WC(GetMainEventQueue)(),event,kEventPriorityHigh); + checkStatus(r,"WC(PostEventToQueue)"); + WC(ReleaseEvent)(event); } OSStatus our_carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) { - UInt32 eKind = GetEventKind(e); - UInt32 eClass = GetEventClass(e); + UInt32 eKind = WC(GetEventKind)(e); + UInt32 eClass = WC(GetEventClass)(e); OSStatus r; Darwin$CarbonMessage *msg; if(eClass != kEventClassCarbonMessage || eKind != kEventCarbonMessage) return eventNotHandledErr; - r = GetEventParameter(e,kEventParamCarbonMessage,typeVoidPtr,NULL,sizeof(msg),NULL,&msg); - checkStatus(r,"GetEventParameter"); + r = WC(GetEventParameter)(e,kEventParamCarbonMessage,typeVoidPtr,NULL,sizeof(msg),NULL,&msg); + checkStatus(r,"WC(GetEventParameter)"); msg->perform(); GCJ$Retainer::release(msg); return noErr; @@ -212,45 +325,45 @@ void Darwin$CarbonSurface::natSyncCursor(jint n) { case 6: c = kThemeResizeLeftRightCursor; default: c = kThemeArrowCursor; } - SetThemeCursor(c); + WC(SetThemeCursor)(c); } void Darwin$CarbonSurface::natSetInvisible(jboolean b) { WindowRef window = (WindowRef) rawWindowRef; fprintf(stderr,"Making window %s\n",b?"invisible":"visible"); - if(b) HideWindow(window); - else ShowWindow(window); + if(b) WC(HideWindow)(window); + else WC(ShowWindow)(window); } void Darwin$CarbonSurface::nat_setMaximized(jboolean b) { WindowRef window = (WindowRef) rawWindowRef; Point ideal = { 10000, 10000 }; - OSStatus r = ZoomWindowIdeal(window,(b?inZoomOut:inZoomIn),&ideal); - checkStatus(r,"ZoomWindowIdeal"); + OSStatus r = WC(ZoomWindowIdeal)(window,(b?inZoomOut:inZoomIn),&ideal); + checkStatus(r,"WC(ZoomWindowIdeal)"); } void Darwin$CarbonSurface::nat_setMinimized(jboolean b) { WindowRef window = (WindowRef) rawWindowRef; - if((IsWindowCollapsed(window) ? 1 : 0) == (b ? 1 : 0)) return; - OSStatus r = CollapseWindow(window,b); - checkStatus(r,"CollapseWindow"); + if((WC(IsWindowCollapsed)(window) ? 1 : 0) == (b ? 1 : 0)) return; + OSStatus r = WC(CollapseWindow)(window,b); + checkStatus(r,"WC(CollapseWindow)"); } void Darwin$CarbonSurface::natSetTitleBarText(jstring js) { SmartCFString s = js; WindowRef window = (WindowRef) rawWindowRef; - SetWindowTitleWithCFString(window,s); + WC(SetWindowTitleWithCFString)(window,s); } void Darwin$CarbonSurface::natToBack() { WindowRef window = (WindowRef) rawWindowRef; - SendBehind(window,NULL); + WC(SendBehind)(window,NULL); } void Darwin$CarbonSurface::natToFront() { WindowRef window = (WindowRef) rawWindowRef; - fprintf(stderr,"SelectWindow()\n"); - SelectWindow(window); + fprintf(stderr,"WC(SelectWindow)()\n"); + WC(SelectWindow)(window); } #pragma mark ---- Window Event Handler ---- @@ -269,6 +382,11 @@ static const EventTypeSpec eventTypeSpecs[] = { { kEventClassWindow, kEventWindowExpanded }, { kEventClassWindow, kEventWindowClose }, { kEventClassWindow, kEventWindowClosed }, + { kEventClassWindow, kEventWindowDrawFrame }, + { kEventClassWindow, kEventWindowDrawPart }, + + // kEventClassControl + { kEventClassControl, kEventControlApplyBackground }, // kEventClassKeyboard { kEventClassKeyboard, kEventRawKeyDown }, @@ -285,11 +403,26 @@ static const EventTypeSpec eventTypeSpecs[] = { }; OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) { - Darwin$CarbonSurface *surface = (Darwin$CarbonSurface*) userData; - UInt32 eKind = GetEventKind(e); - UInt32 eClass = GetEventClass(e); - OSStatus r; + Darwin$CarbonSurface *surface = (Darwin$CarbonSurface*)userData; + if (surface == NULL) { + WindowRef window = 0; + WC(GetEventParameter) (e, + kEventParamDirectObject, + typeWindowRef, + NULL, + sizeof(window), + NULL, + &window); + UInt32 unused; + WC(GetWindowProperty) (window, 'XWT!', 'XWT!', sizeof(surface), &unused, &surface); + } + UInt32 eKind = WC(GetEventKind)(e); + UInt32 eClass = WC(GetEventClass)(e); + OSStatus r; + char* ec = (char*)&eClass; + if (surface == NULL) return eventNotHandledErr; + switch(eClass) { case kEventClassCommand: switch(eKind) { @@ -304,8 +437,8 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u UInt32 keyCode; jstring js; - r = GetEventParameter(e,kEventParamKeyCode,typeUInt32,NULL,sizeof(keyCode),NULL,&keyCode); - checkStatus(r,"GetEventParameter"); + r = WC(GetEventParameter)(e,kEventParamKeyCode,typeUInt32,NULL,sizeof(keyCode),NULL,&keyCode); + checkStatus(r,"WC(GetEventParameter)"); switch(keyCode) { // These values were obtained by experimentation. I can't find any constants for them @@ -342,14 +475,14 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u default: { UInt32 size; UInt32 modifiers = surface->modifiers; - r = GetEventParameter(e,kEventParamKeyUnicodes,typeUnicodeText,NULL,0,&size,NULL); - checkStatus(r,"GetEventParameter"); + r = WC(GetEventParameter)(e,kEventParamKeyUnicodes,typeUnicodeText,NULL,0,&size,NULL); + checkStatus(r,"WC(GetEventParameter)"); if(size == 0 || (modifiers & controlKey && size>sizeof(UniChar))) return eventNotHandledErr; js = JvAllocString(size/sizeof(UniChar)); UniChar *buf = (UniChar*)JvGetStringChars(js); - r = GetEventParameter(e,kEventParamKeyUnicodes,typeUnicodeText,NULL,size,NULL,buf); - checkStatus(r,"GetEventParameter"); + r = WC(GetEventParameter)(e,kEventParamKeyUnicodes,typeUnicodeText,NULL,size,NULL,buf); + checkStatus(r,"WC(GetEventParameter)"); if(!buf[0]) return eventNotHandledErr; // shouldn't happen // odd, when the ctrl key is pressed a-"`" become 1-31, this brings them back to the corect values @@ -379,8 +512,8 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u UInt32 oldModifiers = (UInt32) surface->modifiers; UInt32 newModifiers; - r = GetEventParameter(e,kEventParamKeyModifiers,typeUInt32,NULL,sizeof(newModifiers),NULL,&newModifiers); - checkStatus(r,"GetEventParameter"); + r = WC(GetEventParameter)(e,kEventParamKeyModifiers,typeUInt32,NULL,sizeof(newModifiers),NULL,&newModifiers); + checkStatus(r,"WC(GetEventParameter)"); surface->modifiers = (jint) newModifiers; UInt32 changedModifiers = oldModifiers ^ newModifiers; @@ -399,7 +532,7 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u case kEventClassMouse: // The default handler gets first dibs on mouse events // (this catches the titlebar, resize box, etc) - r = CallNextEventHandler(handler, e); + r = WC(CallNextEventHandler)(handler, e); if(r != eventNotHandledErr && eKind != kEventMouseMoved && eKind != kEventMouseDragged) return r; switch(eKind) { @@ -409,10 +542,10 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u Point p; Rect rect; - r = GetEventParameter(e,kEventParamMouseLocation,typeQDPoint,NULL,sizeof(p),NULL,&p); - checkStatus(r,"GetEventParameter"); - r = GetWindowBounds(window,kWindowContentRgn,&rect); - checkStatus(r,"GetWindowBounds"); + r = WC(GetEventParameter)(e,kEventParamMouseLocation,typeQDPoint,NULL,sizeof(p),NULL,&p); + checkStatus(r,"WC(GetEventParameter)"); + r = WC(GetWindowBounds)(window,kWindowContentRgn,&rect); + checkStatus(r,"WC(GetWindowBounds)"); surface->Move(p.h-rect.left,p.v-rect.top); return noErr; } @@ -421,10 +554,10 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u EventMouseButton button; UInt32 clickCount; jint xwtButton; - r = GetEventParameter(e,kEventParamMouseButton,typeMouseButton,NULL,sizeof(button),NULL,&button); - checkStatus(r,"GetEventParameter"); - r = GetEventParameter(e,kEventParamClickCount,typeUInt32,NULL,sizeof(clickCount),NULL,&clickCount); - checkStatus(r,"GetEventParameter"); + r = WC(GetEventParameter)(e,kEventParamMouseButton,typeMouseButton,NULL,sizeof(button),NULL,&button); + checkStatus(r,"WC(GetEventParameter)"); + r = WC(GetEventParameter)(e,kEventParamClickCount,typeUInt32,NULL,sizeof(clickCount),NULL,&clickCount); + checkStatus(r,"WC(GetEventParameter)"); switch(button) { case kEventMouseButtonPrimary: xwtButton = 1; break; @@ -447,11 +580,11 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u case kEventMouseWheelMoved: { EventMouseWheelAxis axis; SInt32 delta; - r = GetEventParameter(e,kEventParamMouseWheelAxis,typeMouseWheelAxis,NULL,sizeof(axis),NULL,&axis); - checkStatus(r,"GetEventParameter"); + r = WC(GetEventParameter)(e,kEventParamMouseWheelAxis,typeMouseWheelAxis,NULL,sizeof(axis),NULL,&axis); + checkStatus(r,"WC(GetEventParameter)"); if(axis != kEventMouseWheelAxisY) break; - r = GetEventParameter(e,kEventParamMouseWheelDelta,typeSInt32,NULL,sizeof(delta),NULL,&delta); - checkStatus(r,"GetEventParameter"); + r = WC(GetEventParameter)(e,kEventParamMouseWheelDelta,typeSInt32,NULL,sizeof(delta),NULL,&delta); + checkStatus(r,"WC(GetEventParameter)"); fprintf(stderr,"kEventMouseWheelMoved: delta: %d",delta); // surface->MouseWheelMoved(...) IMPROVMENT: mouse wheel support in xwt return noErr; @@ -461,23 +594,23 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u case kEventClassWindow: { WindowRef window; - r = GetEventParameter(e,kEventParamDirectObject,typeWindowRef,NULL,sizeof(window),NULL,&window); - checkStatus(r,"kEventClassWindow/GetEventParameter"); + r = WC(GetEventParameter)(e,kEventParamDirectObject,typeWindowRef,NULL,sizeof(window),NULL,&window); + checkStatus(r,"kEventClassWindow/WC(GetEventParameter)"); if((RawData*)window != surface->rawWindowRef) Darwin::abort(JvNewStringLatin1("window != surface->window")); switch(eKind) { - case kEventWindowUpdate: { - surface->Dirty(0,0,surface->root->width,surface->root->height); - return noErr; - } + + case kEventWindowDrawFrame: { + return noErr; + } case kEventWindowBoundsChanged: { UInt32 attr; Rect rect; - r = GetEventParameter(e,kEventParamAttributes,typeUInt32,NULL,sizeof(attr),NULL,&attr); - checkStatus(r,"kEventWindowBoundsChanged/GetEventParameter"); - r = GetWindowBounds(window,kWindowContentRgn,&rect); - checkStatus(r,"GetWindowBounds"); + r = WC(GetEventParameter)(e,kEventParamAttributes,typeUInt32,NULL,sizeof(attr),NULL,&attr); + checkStatus(r,"kEventWindowBoundsChanged/WC(GetEventParameter)"); + r = WC(GetWindowBounds)(window,kWindowContentRgn,&rect); + checkStatus(r,"WC(GetWindowBounds)"); if(attr & kWindowBoundsChangeSizeChanged) { jint w = rect.right-rect.left; jint h = rect.bottom-rect.top; @@ -485,8 +618,6 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u surface->Maximized(false); surface->reshape(w,h); surface->SizeChange(w,h); - surface->Dirty(0,0,w,h); - surface->blitDirtyScreenRegions(); } if(attr & kWindowBoundsChangeOriginChanged) { surface->PosChange(rect.left,rect.top); @@ -516,7 +647,7 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u return noErr; } case kEventWindowClosed: { - DisposeEventHandlerUPP((EventHandlerUPP)surface->rawEventHandlerUPP); + WC(DisposeEventHandlerUPP)((EventHandlerUPP)surface->rawEventHandlerUPP); GCJ$Retainer::release(surface); return noErr; } @@ -528,6 +659,37 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u } } // end namespace +OSStatus paint(GDHandle device, + GrafPtr qdContext, + WindowRef window, + RgnHandle inClientPaintRgn, + RgnHandle outSystemPaintRgn, + void * refCon) { + Rect r; + WC(GetRegionBounds)(inClientPaintRgn, &r); + ((Darwin$CarbonSurface*)refCon)->Dirty(r.left, r.top, r.right - r.left, r.bottom - r.top); + ((Darwin$CarbonSurface*)refCon)->blitDirtyScreenRegions(); + //printf("hit %d %d %d %d\n", r.left, r.top, r.right, r.bottom); +} + + long MyCustomWindowEventHandler (short code, WindowRef window, short message, long param) { + /* + switch (code) { + case kEventWindowDrawFrame: + return noErr; + GetPort (&thePort); + GetPortBounds (thePort, &windBounds); + PenNormal(); + PenSize (10,10); + FrameRect (windBounds); + return noErr; + break; + } + */ + return eventNotHandledErr; + } + + void Darwin$CarbonSurface::natInit(jboolean framed) { WindowRef window; Rect rect; @@ -537,25 +699,32 @@ void Darwin$CarbonSurface::natInit(jboolean framed) { WindowAttributes attr = kWindowStandardHandlerAttribute| (framed ? kWindowInWindowMenuAttribute|kWindowStandardDocumentAttributes|kWindowLiveResizeAttribute : 0); OSStatus r; - - rect.top = 0; rect.left = 0; rect.bottom = 10; rect.right=10; - r = CreateNewWindow(wc,attr,&rect,&window); - checkStatus(r,"CreateNewWindow"); - - id NSWindowClass = objc_getClass("NSWindow"); - printf("nswindowclass is %x\n", NSWindowClass); - SEL selector = sel_registerName("initWithWindowRef"); - printf("selector is %s\n", selector); - objc_method method = class_getClassMethod(NSWindowClass, selector); - printf("method is %x\n", method); - id windowInstance = objc_msgSend(NSWindowClass, selector, window); - printf("instance is %x\n", windowInstance); - + rect.top = 0; rect.left = 0; rect.bottom = 300; rect.right=300; + EventHandlerUPP upp = WC(NewEventHandlerUPP)(our_windowEventHandler); + + ToolboxObjectClassRef customWindow; + WC(RegisterToolboxObjectClass) ( CFSTR("org.xwt.plat.Darwin.CarbonWindow"), + NULL, sizeof(eventTypeSpecs)/sizeof(EventTypeSpec), + eventTypeSpecs, + upp, NULL, &customWindow); + WindowDefSpec myCustomWindowSpec; + myCustomWindowSpec.defType = kWindowDefObjectClass; + myCustomWindowSpec.u.classRef = customWindow; + r = WC(CreateCustomWindow) (&myCustomWindowSpec, + kDocumentWindowClass, + kWindowStandardHandlerAttribute | kWindowStandardDocumentAttributes, + &rect, + &window); + + Darwin$CarbonSurface* me = this; + WC(SetWindowProperty) (window, 'XWT!', 'XWT!', sizeof(me), &me); + checkStatus(r,"WC(CreateNewWindow)"); + GCJ$Retainer::retain(this); // Need to account for the EventHandlers pointer to us - EventHandlerUPP upp = NewEventHandlerUPP(our_windowEventHandler); - r = InstallWindowEventHandler(window,upp,sizeof(eventTypeSpecs)/sizeof(EventTypeSpec),eventTypeSpecs,this,NULL); checkStatus(r,"InstallWindowEventHandler"); + + WC(InstallWindowContentPaintProc) (window, &paint, 0, this); rawWindowRef = (RawData*) window; rawEventHandlerUPP = (RawData*) upp; @@ -563,7 +732,7 @@ void Darwin$CarbonSurface::natInit(jboolean framed) { void Darwin$CarbonSurface::natDispose() { WindowRef window = (WindowRef) rawWindowRef; - DisposeWindow(window); + WC(DisposeWindow)(window); } void Darwin$CarbonSurface::natSetIcon(org::xwt::Picture *_p) { @@ -572,29 +741,29 @@ void Darwin$CarbonSurface::natSetIcon(org::xwt::Picture *_p) { void Darwin$CarbonSurface::natSetLocation(jint x, jint y) { WindowRef window = (WindowRef) rawWindowRef; Rect rect; - OSStatus r = GetWindowBounds(window,kWindowStructureRgn,&rect); - checkStatus(r,"GetWindowBounds"); + OSStatus r = WC(GetWindowBounds)(window,kWindowStructureRgn,&rect); + checkStatus(r,"WC(GetWindowBounds)"); rect.bottom = y + (rect.bottom - rect.top); rect.right = x + (rect.right - rect.left); rect.top = y; rect.left = x; - r = SetWindowBounds(window,kWindowStructureRgn,&rect); - checkStatus(r,"SetWindowBounds"); - r = ConstrainWindowToScreen(window,kWindowStructureRgn,kWindowConstrainMoveRegardlessOfFit,NULL,NULL); - checkStatus(r,"ConstrainWindowToScreen"); + r = WC(SetWindowBounds)(window,kWindowStructureRgn,&rect); + checkStatus(r,"WC(SetWindowBounds)"); + r = WC(ConstrainWindowToScreen)(window,kWindowStructureRgn,kWindowConstrainMoveRegardlessOfFit,NULL,NULL); + checkStatus(r,"WC(ConstrainWindowToScreen)"); } void Darwin$CarbonSurface::natSetSize(jint w, jint h) { WindowRef window = (WindowRef) rawWindowRef; Rect rect; - OSStatus r = GetWindowBounds(window,kWindowStructureRgn,&rect); - checkStatus(r,"GetWindowBounds"); + OSStatus r = WC(GetWindowBounds)(window,kWindowStructureRgn,&rect); + checkStatus(r,"WC(GetWindowBounds)"); rect.bottom = rect.top + h; rect.right = rect.left + w; - r = SetWindowBounds(window,kWindowStructureRgn,&rect); - checkStatus(r,"SetWindowBounds"); - r = ConstrainWindowToScreen(window,kWindowStructureRgn,kWindowConstrainMoveRegardlessOfFit,NULL,NULL); - checkStatus(r,"ConstrainWindowToScreen"); + r = WC(SetWindowBounds)(window,kWindowStructureRgn,&rect); + checkStatus(r,"WC(SetWindowBounds)"); + r = WC(ConstrainWindowToScreen)(window,kWindowStructureRgn,kWindowConstrainMoveRegardlessOfFit,NULL,NULL); + checkStatus(r,"WC(ConstrainWindowToScreen)"); } void Darwin$CarbonSurface::natSetLimits(jint minw, jint minh, jint maxw, jint maxh) { @@ -607,8 +776,8 @@ void Darwin$CarbonSurface::natSetLimits(jint minw, jint minh, jint maxw, jint ma min.height = minh > maxMax ? maxMax : (minh < minMinH ? minMinH : minh); max.width = maxw > maxMax ? maxMax : (maxw < minMinW ? minMinW : maxw); max.height = maxh > maxMax ? maxMax : (maxh < minMinH ? minMinH : maxh); - OSStatus r = SetWindowResizeLimits(window,&min,&max); - checkStatus(r,"SetWindowResizeLimits"); + OSStatus r = WC(SetWindowResizeLimits)(window,&min,&max); + checkStatus(r,"WC(SetWindowResizeLimits)"); } @@ -619,32 +788,32 @@ void fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPt OSStatus r; switch(callBackSelector) { case kNavCBUserAction: { - NavUserAction action = NavDialogGetUserAction(dialog); + NavUserAction action = WC(NavDialogGetUserAction)(dialog); if(action == kNavUserActionNone || action == kNavUserActionCancel) { helper->fileName = 0; } else { NavReplyRecord reply; - r = NavDialogGetReply(dialog,&reply); - checkStatus(r,"NavDialogGetReply"); + r = WC(NavDialogGetReply)(dialog,&reply); + checkStatus(r,"WC(NavDialogGetReply)"); AEKeyword keyword; FSRef ref; char buf[4096]; - r = AEGetNthPtr(&reply.selection,1,typeFSRef,&keyword,NULL,&ref,sizeof(ref),NULL); - checkStatus(r,"AEGetNthPtr"); - r = FSRefMakePath(&ref,(UInt8*)buf,sizeof(buf)-1); - checkStatus(r,"FSRefMakePath"); + r = WC(AEGetNthPtr)(&reply.selection,1,typeFSRef,&keyword,NULL,&ref,sizeof(ref),NULL); + checkStatus(r,"WC(AEGetNthPtr)"); + r = WC(FSRefMakePath)(&ref,(UInt8*)buf,sizeof(buf)-1); + checkStatus(r,"WC(FSRefMakePath)"); helper->fileName = JvNewStringLatin1(buf); if(helper->save) helper->saveName = cfStringToJString(reply.saveFileName); - r = NavDisposeReply(&reply); - checkStatus(r,"NavDialogGetReply"); + r = WC(NavDisposeReply)(&reply); + checkStatus(r,"WC(NavDialogGetReply)"); } helper->sem->release(); break; } case kNavCBTerminate: - DisposeNavEventUPP((NavEventUPP)helper->rawUPP); - NavDialogDispose(dialog); + WC(DisposeNavEventUPP)((NavEventUPP)helper->rawUPP); + WC(NavDialogDispose)(dialog); break; } } @@ -654,12 +823,12 @@ void Darwin::natFileDialog(Darwin$FileDialogHelper *helper,jstring suggestion_, SmartCFString suggestion = suggestion_; CFStringRef message = CFSTR("By selecting a file in this dialog you are giving this XWT application permission to access that file."); OSStatus r; - WindowRef window = FrontWindow(); + WindowRef window = WC(FrontWindow)(); NavDialogCreationOptions options; - NavEventUPP handler = NewNavEventUPP(fileDialogEventHandler); + NavEventUPP handler = WC(NewNavEventUPP)(fileDialogEventHandler); - NavGetDefaultDialogCreationOptions(&options); + WC(NavGetDefaultDialogCreationOptions)(&options); options.optionFlags = (options.optionFlags|kNavAllFilesInPopup|kNavSelectAllReadableItem|kNavDontUseCustomFrame|kNavDontConfirmReplacement) &~(kNavAllowStationery|kNavAllowMultipleFiles); @@ -671,13 +840,13 @@ void Darwin::natFileDialog(Darwin$FileDialogHelper *helper,jstring suggestion_, options.parentWindow = window; if(write) - r = NavCreatePutFileDialog(&options,0,0,handler,helper,&dlg); + r = WC(NavCreatePutFileDialog)(&options,0,0,handler,helper,&dlg); else - r = NavCreateGetFileDialog(&options,NULL,handler,NULL,NULL,helper,&dlg); + r = WC(NavCreateGetFileDialog)(&options,NULL,handler,NULL,NULL,helper,&dlg); checkStatus(r,"NavCreate(Get/Put)FileDialog"); helper->rawUPP = (RawData*)handler; - NavDialogRun(dlg); + WC(NavDialogRun)(dlg); } jstring Darwin::natGetClipBoard() { @@ -685,21 +854,21 @@ jstring Darwin::natGetClipBoard() { OSStatus r; Size size,size2; - r = GetCurrentScrap(&scrap); - checkStatus(r,"GetCurrentScrap"); + r = WC(GetCurrentScrap)(&scrap); + checkStatus(r,"WC(GetCurrentScrap)"); - r = GetScrapFlavorSize( scrap, kScrapFlavorTypeUnicode, &size); + r = WC(GetScrapFlavorSize)( scrap, kScrapFlavorTypeUnicode, &size); if(r == scrapFlavorNotFoundErr) return JvNewStringLatin1(""); - checkStatus(r,"GetScrapFlavorSize"); + checkStatus(r,"WC(GetScrapFlavorSize)"); unsigned int length = size/sizeof(UniChar); jstring js = JvAllocString(length); UniChar *buf = (UniChar*) JvGetStringChars(js); size2 = size; - r = GetScrapFlavorData(scrap,kScrapFlavorTypeUnicode,&size2,buf); + r = WC(GetScrapFlavorData)(scrap,kScrapFlavorTypeUnicode,&size2,buf); if(r == scrapFlavorNotFoundErr); - checkStatus(r,"GetScrapFlavorData"); + checkStatus(r,"WC(GetScrapFlavorData)"); if(size2 != size) return JvNewStringLatin1(""); return js; @@ -710,11 +879,11 @@ void Darwin::natSetClipBoard(jstring js) { ScrapRef scrap; OSStatus r; - r = GetCurrentScrap(&scrap); - checkStatus(r,"GetCurrentScrap"); + r = WC(GetCurrentScrap)(&scrap); + checkStatus(r,"WC(GetCurrentScrap)"); - r = PutScrapFlavor(scrap,kScrapFlavorTypeUnicode,0,sizeof(UniChar)*length,JvGetStringChars(js)); - checkStatus(r,"PutScrapFlavor"); + r = WC(PutScrapFlavor)(scrap,kScrapFlavorTypeUnicode,0,sizeof(UniChar)*length,JvGetStringChars(js)); + checkStatus(r,"WC(PutScrapFlavor)"); } HTTP$Proxy *Darwin::natDetectProxy() { @@ -726,18 +895,18 @@ HTTP$Proxy *Darwin::natDetectProxy() { CFArrayRef exceptionList; int i; - CFDictionaryRef proxyInfo = SCDynamicStoreCopyProxies(NULL); + CFDictionaryRef proxyInfo = WC(SCDynamicStoreCopyProxies)(NULL); if(proxyInfo == NULL) return 0; #define doproto(proto,var) \ - number = (CFNumberRef) CFDictionaryGetValue(proxyInfo,kSCPropNetProxies ## proto ## Enable); \ - if(number != NULL && CFGetTypeID(number) != CFNumberGetTypeID()) number = NULL; \ - if(number && CFNumberGetValue(number,kCFNumberIntType,&i) && i) { \ - string = (CFStringRef) CFDictionaryGetValue(proxyInfo, kSCPropNetProxies ## proto ## Proxy);\ - if(string != NULL && CFGetTypeID(string) != CFStringGetTypeID()) string = NULL; \ - number = (CFNumberRef) CFDictionaryGetValue(proxyInfo, kSCPropNetProxies ## proto ## Port); \ - if(number != NULL && CFGetTypeID(number) != CFNumberGetTypeID()) number = NULL; \ - if(string && number && CFNumberGetValue(number,kCFNumberIntType,&i) && i) { \ + number = (CFNumberRef) WC(CFDictionaryGetValue)(proxyInfo,kSCPropNetProxies ## proto ## Enable); \ + if(number != NULL && WC(CFGetTypeID)(number) != WC(CFNumberGetTypeID)()) number = NULL; \ + if(number && WC(CFNumberGetValue)(number,kCFNumberIntType,&i) && i) { \ + string = (CFStringRef) WC(CFDictionaryGetValue)(proxyInfo, kSCPropNetProxies ## proto ## Proxy);\ + if(string != NULL && WC(CFGetTypeID)(string) != WC(CFStringGetTypeID)()) string = NULL; \ + number = (CFNumberRef) WC(CFDictionaryGetValue)(proxyInfo, kSCPropNetProxies ## proto ## Port); \ + if(number != NULL && WC(CFGetTypeID)(number) != WC(CFNumberGetTypeID)()) number = NULL; \ + if(string && number && WC(CFNumberGetValue)(number,kCFNumberIntType,&i) && i) { \ if(!p) p = new HTTP$Proxy(); \ p->var ## ProxyHost = cfStringToJString(string); \ p->var ## ProxyPort = i; \ @@ -748,19 +917,19 @@ doproto(HTTPS,https) doproto(SOCKS,socks) #undef doproto - exceptionList = (CFArrayRef) CFDictionaryGetValue(proxyInfo,kSCPropNetProxiesExceptionsList); - if(exceptionList != NULL && CFGetTypeID(exceptionList) != CFArrayGetTypeID()) exceptionList = NULL; - if(p && exceptionList && CFArrayGetCount(exceptionList)) { - CFIndex count = CFArrayGetCount(exceptionList); + exceptionList = (CFArrayRef) WC(CFDictionaryGetValue)(proxyInfo,kSCPropNetProxiesExceptionsList); + if(exceptionList != NULL && WC(CFGetTypeID)(exceptionList) != WC(CFArrayGetTypeID)()) exceptionList = NULL; + if(p && exceptionList && WC(CFArrayGetCount)(exceptionList)) { + CFIndex count = WC(CFArrayGetCount)(exceptionList); p->excluded = (JArray*) JvNewObjectArray(count,&java::lang::String::class$,0); for(i=0;iexcluded)[i] = string ? cfStringToJString(string) : JvNewStringLatin1("(null)"); } } - CFRelease(proxyInfo); + WC(CFRelease)(proxyInfo); return p; /* @@ -783,7 +952,7 @@ doproto(SOCKS,socks) NSNumber *port; NSArray *exceptionList; unsigned int i; - NSDictionary *proxyInfo = (NSDictionary*)SCDynamicStoreCopyProxies(NULL); + NSDictionary *proxyInfo = (NSDictionary*)WC(SCDynamicStoreCopyProxies)(NULL); if(proxyInfo == NULL) return 0; if([[proxyInfo objectForKey: (NSString*) kSCPropNetProxiesHTTPEnable] boolValue]) { @@ -827,24 +996,24 @@ doproto(SOCKS,socks) } jint Darwin::cgScreenWidth() { - return CGDisplayPixelsWide(((CGDirectDisplayID)0)); + return WC(CGDisplayPixelsWide)(((CGDirectDisplayID)0)); } jint Darwin::cgScreenHeight() { - return CGDisplayPixelsHigh(((CGDirectDisplayID)0)); + return WC(CGDisplayPixelsHigh)(((CGDirectDisplayID)0)); } void Darwin::_newBrowserWindow(jstring js) { SmartCFString cfs = js; - CFURLRef url = CFURLCreateWithString(kCFAllocatorDefault,cfs,NULL); - SmartCFString scheme = CFURLCopyScheme(url); + CFURLRef url = WC(CFURLCreateWithString)(WC(kCFAllocatorDefault),cfs,NULL); + SmartCFString scheme = WC(CFURLCopyScheme)(url); if(scheme.equals(CFStringRef("http"))) - LSOpenCFURLRef(url,NULL); - CFRelease(url); + WC(LSOpenCFURLRef)(url,NULL); + WC(CFRelease)(url); } void Darwin::_exit() { - QuitApplicationEventLoop(); + WC(QuitApplicationEventLoop)(); } void Darwin::natInit() { @@ -854,12 +1023,12 @@ void Darwin::natInit() { ProcessSerialNumber currentProcess = { 0, kCurrentProcess }; ::fprintf(stderr,"Doing XWT_CARBON_NO_BUNDLE_HACK\n"); - r = GetCurrentProcess(¤tProcess); - checkStatus(r,"GetCurrentProcess"); - r = CPSEnableForegroundOperation( ¤tProcess ); - checkStatus(r,"CPSEnableForegroundOperation"); - r = CPSSetFrontProcess(¤tProcess); - checkStatus(r,"CPSSetFrontProcess"); + r = WC(GetCurrentProcess)(¤tProcess); + checkStatus(r,"WC(GetCurrentProcess)"); + r = WC(CPSEnableForegroundOperation)( ¤tProcess ); + checkStatus(r,"WC(CPSEnableForegroundOperation)"); + r = WC(CPSSetFrontProcess)(¤tProcess); + checkStatus(r,"WC(CPSSetFrontProcess)"); } #else { @@ -876,15 +1045,15 @@ void Darwin::natInit() { } void Darwin::_running() { - RunApplicationEventLoop(); - ExitToShell(); + WC(RunApplicationEventLoop)(); + WC(ExitToShell)(); } #pragma mark ------ OpenGL Functions ----- void Darwin$CarbonOpenGL::activateSharedContext() { AGLContext ctx = (AGLContext) rawSharedContext; - aglSetCurrentContext(ctx); + WC(aglSetCurrentContext)(ctx); } jboolean Darwin$CarbonOpenGL::initPixelFormat() { @@ -899,14 +1068,14 @@ jboolean Darwin$CarbonOpenGL::initPixelFormat() { AGL_NONE }; - rawPixelFormat = (RawData*) aglChoosePixelFormat(NULL,0,attr); + rawPixelFormat = (RawData*) WC(aglChoosePixelFormat)(NULL,0,attr); return rawPixelFormat != 0; } void Darwin$CarbonOpenGL::initSharedContext() { AGLPixelFormat fmt = (AGLPixelFormat) rawPixelFormat; - rawSharedContext = (RawData*) aglCreateContext(fmt,NULL); - checkStatus(rawSharedContext,"aglCreateContext"); + rawSharedContext = (RawData*) WC(aglCreateContext)(fmt,NULL); + checkStatus(rawSharedContext,"WC(aglCreateContext)"); } void Darwin$GLCarbonPixelBuffer::natInit() { @@ -925,34 +1094,34 @@ void Darwin$GLCarbonPixelBuffer::natInit() { rect.right = width + rect.left; rect.bottom = height + rect.top; - r = CreateNewWindow(wc,attr,&rect,&window); - checkStatus(r,"CreateNewWindow"); + r = WC(CreateNewWindow)(wc,attr,&rect,&window); + checkStatus(r,"WC(CreateNewWindow)"); shared = (AGLContext) gl->rawSharedContext; fmt = (AGLPixelFormat) gl->rawPixelFormat; - ctx = aglCreateContext(fmt,shared); - checkStatus(ctx, "aglCreateContext"); + ctx = WC(aglCreateContext)(fmt,shared); + checkStatus(ctx, "WC(aglCreateContext)"); - b = aglSetDrawable(ctx,GetWindowPort(window)); - checkStatus(b,"aglSetDrawable"); + b = WC(aglSetDrawable)(ctx,WC(GetWindowPort)(window)); + checkStatus(b,"WC(aglSetDrawable)"); - aglSetCurrentContext(ctx); - aglUpdateContext(ctx); + WC(aglSetCurrentContext)(ctx); + WC(aglUpdateContext)(ctx); drawableInit(width,height); glClear(GL_COLOR_BUFFER_BIT); - aglSetCurrentContext(shared); + WC(aglSetCurrentContext)(shared); target = rectTexture ? GL_TEXTURE_RECTANGLE_EXT : GL_TEXTURE_2D; glEnable(target); glGenTextures(1,&tex); glBindTexture(target,tex); glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - aglSurfaceTexture (shared, target, GL_RGBA, ctx); + WC(aglSurfaceTexture) (shared, target, GL_RGBA, ctx); checkGLError(); glDisable(target); - //ShowWindow(window); + //WC(ShowWindow)(window); textureName = (jint) tex; rawWindowRef = (RawData*) window; rawCTX = (RawData*) ctx; @@ -960,14 +1129,14 @@ void Darwin$GLCarbonPixelBuffer::natInit() { void Darwin$GLCarbonPixelBuffer::activateContext() { AGLContext ctx = (AGLContext) rawCTX; - aglSetCurrentContext(ctx); + WC(aglSetCurrentContext)(ctx); } void Darwin$GLCarbonPixelBuffer::natCleanup(RawData* rawWindowRef, RawData* rawCTX) { WindowRef window = (WindowRef) rawWindowRef; AGLContext ctx = (AGLContext) rawCTX; - aglDestroyContext(ctx); - DisposeWindow(window); + WC(aglDestroyContext)(ctx); + WC(DisposeWindow)(window); } void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonPixelBuffer *db, jint sx1, jint sy1, jint dx1, jint dy1, jint dx2, jint dy2) { @@ -977,7 +1146,7 @@ void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonPixelBuffer *db, jint sx1, j db->activateContext(); glFlush(); checkGLError(); - aglSetCurrentContext(ctx); + WC(aglSetCurrentContext)(ctx); checkGLError(); if(db->rectTexture) { glEnable(GL_TEXTURE_RECTANGLE_EXT); @@ -1027,8 +1196,8 @@ void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonPixelBuffer *db, jint sx1, j void Darwin$GLCarbonSurface::natReshape(jint w, jint h) { AGLContext ctx = (AGLContext) rawCTX; - aglSetCurrentContext (ctx); - aglUpdateContext(ctx); + WC(aglSetCurrentContext) (ctx); + WC(aglUpdateContext)(ctx); glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); @@ -1048,26 +1217,26 @@ void Darwin$GLCarbonSurface::natInit() { shared = (AGLContext) gl->rawSharedContext; fmt = (AGLPixelFormat) gl->rawPixelFormat; - ctx = aglCreateContext(fmt,shared); - checkStatus(ctx, "aglCreateContext"); + ctx = WC(aglCreateContext)(fmt,shared); + checkStatus(ctx, "WC(aglCreateContext)"); - b = aglSetDrawable(ctx,GetWindowPort(window)); - checkStatus(b,"aglSetDrawable"); + b = WC(aglSetDrawable)(ctx,WC(GetWindowPort)(window)); + checkStatus(b,"WC(aglSetDrawable)"); - aglSetCurrentContext(ctx); + WC(aglSetCurrentContext)(ctx); checkGLError(); rawCTX = (RawData*)ctx; reshape(10,10); - aglSetCurrentContext(ctx); + WC(aglSetCurrentContext)(ctx); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); } void Darwin$GLCarbonSurface::natDispose() { AGLContext ctx = (AGLContext) rawCTX; - aglDestroyContext(ctx); + WC(aglDestroyContext)(ctx); Darwin$CarbonSurface::natDispose(); } diff --git a/src/org/xwt/plat/Darwin.java b/src/org/xwt/plat/Darwin.java index 17877c1..d6aa8d8 100644 --- a/src/org/xwt/plat/Darwin.java +++ b/src/org/xwt/plat/Darwin.java @@ -86,11 +86,9 @@ public class Darwin extends POSIX { } private static native final boolean isJaguar(); - private static native final void linkMe(); public void init() { super.init(); - linkMe(); jaguar = isJaguar(); try { openGL = new CarbonOpenGL(); diff --git a/src/org/xwt/plat/DarwinCarbonHeaders.h b/src/org/xwt/plat/DarwinCarbonHeaders.h index a7eba3f..c6953a5 100644 --- a/src/org/xwt/plat/DarwinCarbonHeaders.h +++ b/src/org/xwt/plat/DarwinCarbonHeaders.h @@ -56061,6 +56061,7 @@ enum { + kEventWindowBoundsChanged = 27, -- 1.7.10.4