From: brian Date: Fri, 30 Jan 2004 07:39:02 +0000 (+0000) Subject: 2003/10/13 00:44:54 X-Git-Tag: RC3~489 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=24b649e330a643931ed32f0667e4828498f7e3af 2003/10/13 00:44:54 darcs-hash:20040130073902-aa32f-2560f0f3aacff6e9b9cd84017623dae83ce7c9cc.gz --- diff --git a/src/org/xwt/plat/Darwin.cc b/src/org/xwt/plat/Darwin.cc index 7cbfad0..7f4d2f3 100644 --- a/src/org/xwt/plat/Darwin.cc +++ b/src/org/xwt/plat/Darwin.cc @@ -28,6 +28,7 @@ #include #include +#include #include "DarwinCarbonHeaders.h" @@ -154,6 +155,7 @@ declare_weak(aglUpdateContext); declare_weak(CPSEnableForegroundOperation); declare_weak(CPSSetFrontProcess); declare_weak(kCFAllocatorDefault); +declare_weak(NewWindowPaintUPP); #define GetWindowEventTarget WC(GetWindowEventTarget) #define InstallEventHandler WC(InstallEventHandler) @@ -166,108 +168,123 @@ using java::lang::Object; namespace org { namespace xwt { namespace plat { -namespace darwin { } -using namespace darwin; -#pragma mark ------ Darwin Namespace ------ +#pragma mark ----- Blit Locks ------ +static pthread_mutex_t blit_mutex; +static pthread_cond_t blit_cond; - // We put everything that isn't in org.xwt.plat.Darwin in - // org.xwt.plat.darwin to prevent namespace conflicts - - template static inline int CompileTimeCheck() { const int something_is_wrong=1; something_is_wrong++; return 0; } - template <> static inline int CompileTimeCheck() { return 0; } - const static int unichar_check = CompileTimeCheck(); - - void funcFailed(char *func,int r); - static inline void checkStatus(OSStatus r, char *func) { if(r != noErr) funcFailed(func,r); } - static inline void checkStatus(GLboolean b, char *func) { if(!b) funcFailed(func,-1); } - static inline void checkStatus(void *p, char *func) { if(!p) funcFailed(func,-1); } - - jstring cfStringToJString(CFStringRef s) { - CFIndex length = WC(CFStringGetLength)(s); - CFRange range = CFRangeMake(0,length); - jstring js = JvAllocString(length); - UniChar *buf = (UniChar*)JvGetStringChars(js); - WC(CFStringGetCharacters)(s,range,buf); - return js; - } - - #pragma mark ------ SmartCFString ------ - class SmartCFString { - private: - CFStringRef p; - void release() { if(p) WC(CFRelease)(p); } - void checkNull() { if(!p) throw new java::lang::Error(JvNewStringLatin1("CFString function failed")); } - public: - // Constructors - SmartCFString() : p(0) { } - SmartCFString(const char *s) : p(0) { *this = s; } - SmartCFString(jstring js) : p(0) { *this = js; } - SmartCFString(CFStringRef cf) : p(0) { *this = cf; } - // Destructor - ~SmartCFString() { release(); } - // Assignment - SmartCFString& operator= (const char *s) { - release(); - if(!s) s = "(null)"; - p = WC(CFStringCreateWithCString)(WC(kCFAllocatorDefault),s,kCFStringEncodingISOLatin1); - checkNull(); - return *this; - } - SmartCFString& operator= (jstring js) { - if(!js) return *this = "(null)"; - release(); - UniChar *buf = (UniChar*) JvGetStringChars(js); - CFIndex length = js->length(); - p = WC(CFStringCreateWithCharacters)(WC(kCFAllocatorDefault),buf,length); - checkNull(); - return *this; - } - SmartCFString& operator= (CFStringRef cf) { - if(cf == NULL) return *this = "(null)"; - release(); - p = cf; - return *this; - } - operator CFStringRef() { return p; } - operator jstring() { return getJString(); } - - jstring getJString() { return cfStringToJString(p); } - - bool equals(const char *s) { - SmartCFString cfs(s); - return equals(cfs); - } - - bool equals(CFStringRef cfs) { - return WC(CFStringCompare)(p,cfs,0) == kCFCompareEqualTo; - } - }; - - // CHECKME: Is just making up your own four char codes really correct? - const static UInt32 kEventClassCarbonMessage = 'xwta'; - const static UInt32 kEventCarbonMessage = 'xwtb'; - const static UInt32 kEventParamCarbonMessage = 'xwtc'; - - OSStatus our_carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData); - void fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData); +static inline void blit_lock() { if(pthread_mutex_lock(&blit_mutex) != 0) abort(); } +static inline void blit_unlock() { if(pthread_mutex_unlock(&blit_mutex) != 0) abort(); } +static inline void blit_wait() { if(pthread_cond_wait(&blit_cond,&blit_mutex) != 0) abort(); } +static inline void blit_signal() { if(pthread_cond_signal(&blit_cond) != 0) abort(); } + +void Darwin$CarbonSurface::blitLock() { blit_lock(); } +void Darwin$CarbonSurface::blitUnlock() { blit_unlock(); } +void Darwin$CarbonSurface::blitWait() { blit_wait(); } + + +template static inline int CompileTimeCheck() { const int something_is_wrong=1; something_is_wrong++; return 0; } +template <> static inline int CompileTimeCheck() { return 0; } +const static int unichar_check = CompileTimeCheck(); + +static void funcFailed(const char *func,int r); +static inline void funcFailed(const char *func) { funcFailed(func,-1); } + +static inline void checkStatus(OSStatus r, char *func) { if(r != noErr) funcFailed(func,r); } +static inline void checkStatus(GLboolean b, char *func) { if(!b) funcFailed(func,-1); } +static inline void checkStatus(void *p, char *func) { if(!p) funcFailed(func,-1); } + +jstring cfStringToJString(CFStringRef s) { + CFIndex length = WC(CFStringGetLength)(s); + CFRange range = CFRangeMake(0,length); + jstring js = JvAllocString(length); + UniChar *buf = (UniChar*)JvGetStringChars(js); + WC(CFStringGetCharacters)(s,range,buf); + return js; +} + +#pragma mark ------ SmartCFString ------ +class SmartCFString { + private: + CFStringRef p; + void release() { if(p) WC(CFRelease)(p); } + void checkNull() { if(!p) funcFailed("CFString function"); } + public: + // Constructors + SmartCFString() : p(0) { } + SmartCFString(const char *s) : p(0) { *this = s; } + SmartCFString(jstring js) : p(0) { *this = js; } + SmartCFString(CFStringRef cf) : p(0) { *this = cf; } + // Destructor + ~SmartCFString() { release(); } + // Assignment + SmartCFString& operator= (const char *s) { + release(); + if(!s) s = "(null)"; + p = WC(CFStringCreateWithCString)(WC(kCFAllocatorDefault),s,kCFStringEncodingISOLatin1); + checkNull(); + return *this; + } + SmartCFString& operator= (jstring js) { + if(!js) return *this = "(null)"; + release(); + UniChar *buf = (UniChar*) JvGetStringChars(js); + CFIndex length = js->length(); + p = WC(CFStringCreateWithCharacters)(WC(kCFAllocatorDefault),buf,length); + checkNull(); + return *this; + } + SmartCFString& operator= (CFStringRef cf) { + if(cf == NULL) return *this = "(null)"; + release(); + p = cf; + return *this; + } + operator CFStringRef() { return p; } + operator jstring() { return getJString(); } + + jstring getJString() { return cfStringToJString(p); } + + bool equals(const char *s) { + SmartCFString cfs(s); + return equals(cfs); + } + + bool equals(CFStringRef cfs) { + return WC(CFStringCompare)(p,cfs,0) == kCFCompareEqualTo; + } +}; + +// CHECKME: Is just making up your own four char codes really correct? +const static UInt32 kEventClassCarbonMessage = 'xwta'; +const static UInt32 kEventCarbonMessage = 'xwtb'; +const static UInt32 kEventParamCarbonMessage = 'xwtc'; +static OSStatus carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData); +static EventHandlerUPP carbonMessageEventHandlerUPP; +static void fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData); +static NavEventUPP fileDialogEventHandlerUPP; + +static OSStatus windowEventHandler(EventHandlerCallRef handler, EventRef e, void *userData); +static EventHandlerUPP windowEventHandlerUPP; + +static OSStatus paintProc(GDHandle device,GrafPtr qdContext,WindowRef window,RgnHandle inClientPaintRgn,RgnHandle outSystemPaintRgn,void *userData); +static WindowPaintUPP paintProcUPP; jboolean Darwin::isJaguar() { SInt32 version; OSStatus r = WC(Gestalt)(gestaltSystemVersion, &version); - checkStatus(r,"WC(Gestalt)"); + checkStatus(r,"Gestalt"); return version >= 0x1020; } void Darwin$CarbonMessage::natInit() { OSStatus r; - EventHandlerUPP upp = WC(NewEventHandlerUPP)(our_carbonMessageEventHandler); EventTypeSpec eventTypes = { kEventClassCarbonMessage, kEventCarbonMessage }; - r = InstallEventHandler(WC(GetApplicationEventTarget)(),upp,1,&eventTypes,NULL,NULL); - checkStatus(r,"WC(InstallEventHandler)"); + r = InstallEventHandler(WC(GetApplicationEventTarget)(),carbonMessageEventHandlerUPP,1,&eventTypes,NULL,NULL); + checkStatus(r,"InstallEventHandler"); } void Darwin$CarbonMessage::add(Darwin$CarbonMessage *msg) { @@ -277,16 +294,16 @@ void Darwin$CarbonMessage::add(Darwin$CarbonMessage *msg) { GCJ$Retainer::retain(msg); r = WC(CreateEvent)(WC(kCFAllocatorDefault),kEventClassCarbonMessage,kEventCarbonMessage,0,kEventAttributeNone,&event); - checkStatus(r,"WC(CreateEvent)"); + checkStatus(r,"CreateEvent"); r = WC(SetEventParameter)(event,kEventParamCarbonMessage,typeVoidPtr,sizeof(msg),(void*)&msg); - checkStatus(r,"WC(SetEventParameter)"); + checkStatus(r,"SetEventParameter"); r = WC(PostEventToQueue)(WC(GetMainEventQueue)(),event,kEventPriorityHigh); - checkStatus(r,"WC(PostEventToQueue)"); + checkStatus(r,"PostEventToQueue"); WC(ReleaseEvent)(event); } -OSStatus our_carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) { +static OSStatus carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) { UInt32 eKind = WC(GetEventKind)(e); UInt32 eClass = WC(GetEventClass)(e); OSStatus r; @@ -294,7 +311,7 @@ OSStatus our_carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, if(eClass != kEventClassCarbonMessage || eKind != kEventCarbonMessage) return eventNotHandledErr; r = WC(GetEventParameter)(e,kEventParamCarbonMessage,typeVoidPtr,NULL,sizeof(msg),NULL,&msg); - checkStatus(r,"WC(GetEventParameter)"); + checkStatus(r,"GetEventParameter"); msg->perform(); GCJ$Retainer::release(msg); return noErr; @@ -303,7 +320,7 @@ OSStatus our_carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, #pragma mark ------ Utility Functions ------ -void funcFailed(char *func,int r){ +static void funcFailed(const char *func,int r){ fprintf(stderr,"%s() failed (%d)\n",func,r); exit(EXIT_FAILURE); } @@ -339,14 +356,14 @@ void Darwin$CarbonSurface::nat_setMaximized(jboolean b) { WindowRef window = (WindowRef) rawWindowRef; Point ideal = { 10000, 10000 }; OSStatus r = WC(ZoomWindowIdeal)(window,(b?inZoomOut:inZoomIn),&ideal); - checkStatus(r,"WC(ZoomWindowIdeal)"); + checkStatus(r,"ZoomWindowIdeal"); } void Darwin$CarbonSurface::nat_setMinimized(jboolean b) { WindowRef window = (WindowRef) rawWindowRef; if((WC(IsWindowCollapsed)(window) ? 1 : 0) == (b ? 1 : 0)) return; OSStatus r = WC(CollapseWindow)(window,b); - checkStatus(r,"WC(CollapseWindow)"); + checkStatus(r,"CollapseWindow"); } void Darwin$CarbonSurface::natSetTitleBarText(jstring js) { @@ -362,12 +379,11 @@ void Darwin$CarbonSurface::natToBack() { void Darwin$CarbonSurface::natToFront() { WindowRef window = (WindowRef) rawWindowRef; - fprintf(stderr,"WC(SelectWindow)()\n"); + fprintf(stderr,"SelectWindow)()\n"); WC(SelectWindow)(window); } #pragma mark ---- Window Event Handler ---- -namespace darwin { static const EventTypeSpec eventTypeSpecs[] = { // kEventClassCommand // { kEventClassCommand, ??? }, @@ -375,6 +391,7 @@ static const EventTypeSpec eventTypeSpecs[] = { // kEventClassWindow { kEventClassWindow, kEventWindowUpdate }, { kEventClassWindow, kEventWindowBoundsChanged }, + { kEventClassWindow, kEventWindowBoundsChanging }, { kEventClassWindow, kEventWindowActivated }, { kEventClassWindow, kEventWindowDeactivated }, { kEventClassWindow, kEventWindowZoomed }, @@ -402,20 +419,8 @@ static const EventTypeSpec eventTypeSpecs[] = { { kEventClassMouse, kEventMouseWheelMoved }, }; -OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) { +static OSStatus windowEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) { 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; @@ -438,7 +443,7 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u jstring js; r = WC(GetEventParameter)(e,kEventParamKeyCode,typeUInt32,NULL,sizeof(keyCode),NULL,&keyCode); - checkStatus(r,"WC(GetEventParameter)"); + checkStatus(r,"GetEventParameter"); switch(keyCode) { // These values were obtained by experimentation. I can't find any constants for them @@ -476,13 +481,13 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u UInt32 size; UInt32 modifiers = surface->modifiers; r = WC(GetEventParameter)(e,kEventParamKeyUnicodes,typeUnicodeText,NULL,0,&size,NULL); - checkStatus(r,"WC(GetEventParameter)"); + checkStatus(r,"GetEventParameter"); if(size == 0 || (modifiers & controlKey && size>sizeof(UniChar))) return eventNotHandledErr; js = JvAllocString(size/sizeof(UniChar)); UniChar *buf = (UniChar*)JvGetStringChars(js); r = WC(GetEventParameter)(e,kEventParamKeyUnicodes,typeUnicodeText,NULL,size,NULL,buf); - checkStatus(r,"WC(GetEventParameter)"); + checkStatus(r,"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 @@ -513,7 +518,7 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u UInt32 oldModifiers = (UInt32) surface->modifiers; UInt32 newModifiers; r = WC(GetEventParameter)(e,kEventParamKeyModifiers,typeUInt32,NULL,sizeof(newModifiers),NULL,&newModifiers); - checkStatus(r,"WC(GetEventParameter)"); + checkStatus(r,"GetEventParameter"); surface->modifiers = (jint) newModifiers; UInt32 changedModifiers = oldModifiers ^ newModifiers; @@ -543,9 +548,9 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u Rect rect; r = WC(GetEventParameter)(e,kEventParamMouseLocation,typeQDPoint,NULL,sizeof(p),NULL,&p); - checkStatus(r,"WC(GetEventParameter)"); + checkStatus(r,"GetEventParameter"); r = WC(GetWindowBounds)(window,kWindowContentRgn,&rect); - checkStatus(r,"WC(GetWindowBounds)"); + checkStatus(r,"GetWindowBounds"); surface->Move(p.h-rect.left,p.v-rect.top); return noErr; } @@ -555,9 +560,9 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u UInt32 clickCount; jint xwtButton; r = WC(GetEventParameter)(e,kEventParamMouseButton,typeMouseButton,NULL,sizeof(button),NULL,&button); - checkStatus(r,"WC(GetEventParameter)"); + checkStatus(r,"GetEventParameter"); r = WC(GetEventParameter)(e,kEventParamClickCount,typeUInt32,NULL,sizeof(clickCount),NULL,&clickCount); - checkStatus(r,"WC(GetEventParameter)"); + checkStatus(r,"GetEventParameter"); switch(button) { case kEventMouseButtonPrimary: xwtButton = 1; break; @@ -581,10 +586,10 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u EventMouseWheelAxis axis; SInt32 delta; r = WC(GetEventParameter)(e,kEventParamMouseWheelAxis,typeMouseWheelAxis,NULL,sizeof(axis),NULL,&axis); - checkStatus(r,"WC(GetEventParameter)"); + checkStatus(r,"GetEventParameter"); if(axis != kEventMouseWheelAxisY) break; r = WC(GetEventParameter)(e,kEventParamMouseWheelDelta,typeSInt32,NULL,sizeof(delta),NULL,&delta); - checkStatus(r,"WC(GetEventParameter)"); + checkStatus(r,"GetEventParameter"); fprintf(stderr,"kEventMouseWheelMoved: delta: %d",delta); // surface->MouseWheelMoved(...) IMPROVMENT: mouse wheel support in xwt return noErr; @@ -595,33 +600,58 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u case kEventClassWindow: { WindowRef window; r = WC(GetEventParameter)(e,kEventParamDirectObject,typeWindowRef,NULL,sizeof(window),NULL,&window); - checkStatus(r,"kEventClassWindow/WC(GetEventParameter)"); + checkStatus(r,"kEventClassWindow/WC(GetEventParameter"); if((RawData*)window != surface->rawWindowRef) Darwin::abort(JvNewStringLatin1("window != surface->window")); switch(eKind) { - - case kEventWindowDrawFrame: { - return noErr; - } - case kEventWindowBoundsChanged: { + case kEventWindowBoundsChanging: { UInt32 attr; Rect rect; + 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)"); + checkStatus(r,"kEventWindowBoundsChanged/GetEventParameter"); + + r = WC(GetEventParameter)(e,kEventParamCurrentBounds,typeQDRectangle,NULL,sizeof(rect),NULL,&rect); + checkStatus(r,"kEventWindowBoundsChanging/GetEventParameter"); + if(attr & kWindowBoundsChangeSizeChanged) { jint w = rect.right-rect.left; jint h = rect.bottom-rect.top; - if(attr & kWindowBoundsChangeUserResize && surface->maximized) - surface->Maximized(false); - surface->reshape(w,h); + + blit_lock(); + + surface->winWidth = w; + surface->winHeight = h; + surface->pendingResize = true; + surface->needsReshape(); + + blit_unlock(); + surface->SizeChange(w,h); + if(attr & kWindowBoundsChangeUserResize && surface->maximized) + surface->Maximized(false); } + if(attr & kWindowBoundsChangeOriginChanged) { surface->PosChange(rect.left,rect.top); } + + return noErr; + } + case kEventWindowBoundsChanged: { + UInt32 attr; + r = WC(GetEventParameter)(e,kEventParamAttributes,typeUInt32,NULL,sizeof(attr),NULL,&attr); + checkStatus(r,"kEventWindowBoundsChanged/GetEventParameter"); + + if(attr & kWindowBoundsChangeSizeChanged) { + blit_lock(); + + surface->pendingResize = false; + + blit_signal(); + blit_unlock(); + } return noErr; } case kEventWindowActivated: @@ -630,7 +660,6 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u return noErr; } case kEventWindowZoomed: { - fprintf(stderr,"Zoomed....\n"); surface->Maximized(true); return noErr; } @@ -647,49 +676,34 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u return noErr; } case kEventWindowClosed: { - WC(DisposeEventHandlerUPP)((EventHandlerUPP)surface->rawEventHandlerUPP); GCJ$Retainer::release(surface); return noErr; } + case kEventWindowUpdate: { + fprintf(stderr,"kEventWindowUpdate: Should not be here\n"); + abort(); + } } } break; } return eventNotHandledErr; } -} // 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(); - ((Darwin$CarbonSurface*)refCon)->render_(); - //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; - } +static OSStatus paintProc ( + GDHandle device, + GrafPtr qdContext, + WindowRef window, + RgnHandle inClientPaintRgn, + RgnHandle outSystemPaintRgn, + void *userData +) { + Darwin$CarbonSurface *surface = (Darwin$CarbonSurface*) userData; + Rect rect; + WC(GetRegionBounds)(inClientPaintRgn, &rect); + surface->Dirty(rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top); + return noErr; +} void Darwin$CarbonSurface::natInit(jboolean framed) { WindowRef window; @@ -701,36 +715,22 @@ void Darwin$CarbonSurface::natInit(jboolean framed) { (framed ? kWindowInWindowMenuAttribute|kWindowStandardDocumentAttributes|kWindowLiveResizeAttribute : 0); OSStatus r; 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); - - //r = CreateNewWindow(kDocumentWindowClass, attr, &rect, &window); - Darwin$CarbonSurface* me = this; - WC(SetWindowProperty) (window, 'XWT!', 'XWT!', sizeof(me), &me); - checkStatus(r,"WC(CreateNewWindow)"); + winWidth = winHeight = 300; + + r = WC(CreateNewWindow)(wc, attr, &rect, &window); + checkStatus(r,"CreateNewWindow"); + + rawWindowRef = (RawData*) window; GCJ$Retainer::retain(this); // Need to account for the EventHandlers pointer to us - r = InstallWindowEventHandler(window,upp,sizeof(eventTypeSpecs)/sizeof(EventTypeSpec),eventTypeSpecs,this,NULL); + + r = InstallWindowEventHandler(window,windowEventHandlerUPP,sizeof(eventTypeSpecs)/sizeof(EventTypeSpec),eventTypeSpecs,this,NULL); checkStatus(r,"InstallWindowEventHandler"); - WC(InstallWindowContentPaintProc) (window, &paint, 0, this); + r = WC(InstallWindowContentPaintProc)(window,paintProcUPP,kWindowPaintProcOptionsNone,this); + checkStatus(r,"InstallWindowContentPaintProc"); - rawWindowRef = (RawData*) window; - rawEventHandlerUPP = (RawData*) upp; + WC(ShowWindow)(window); } void Darwin$CarbonSurface::natDispose() { @@ -747,28 +747,28 @@ void Darwin$CarbonSurface::natSetLocation() { jint x = root->x; jint y = root->y; OSStatus r = WC(GetWindowBounds)(window,kWindowStructureRgn,&rect); - checkStatus(r,"WC(GetWindowBounds)"); + checkStatus(r,"GetWindowBounds"); rect.bottom = y + (rect.bottom - rect.top); rect.right = x + (rect.right - rect.left); rect.top = y; rect.left = x; r = WC(SetWindowBounds)(window,kWindowStructureRgn,&rect); - checkStatus(r,"WC(SetWindowBounds)"); + checkStatus(r,"SetWindowBounds"); r = WC(ConstrainWindowToScreen)(window,kWindowStructureRgn,kWindowConstrainMoveRegardlessOfFit,NULL,NULL); - checkStatus(r,"WC(ConstrainWindowToScreen)"); + checkStatus(r,"ConstrainWindowToScreen"); } void Darwin$CarbonSurface::natSetSize(jint w, jint h) { WindowRef window = (WindowRef) rawWindowRef; Rect rect; - OSStatus r = WC(GetWindowBounds)(window,kWindowStructureRgn,&rect); - checkStatus(r,"WC(GetWindowBounds)"); + OSStatus r = WC(GetWindowBounds)(window,kWindowContentRgn,&rect); + checkStatus(r,"GetWindowBounds"); rect.bottom = rect.top + h; rect.right = rect.left + w; - r = WC(SetWindowBounds)(window,kWindowStructureRgn,&rect); - checkStatus(r,"WC(SetWindowBounds)"); + r = WC(SetWindowBounds)(window,kWindowContentRgn,&rect); + checkStatus(r,"SetWindowBounds"); r = WC(ConstrainWindowToScreen)(window,kWindowStructureRgn,kWindowConstrainMoveRegardlessOfFit,NULL,NULL); - checkStatus(r,"WC(ConstrainWindowToScreen)"); + checkStatus(r,"ConstrainWindowToScreen"); } void Darwin$CarbonSurface::natSetLimits(jint minw, jint minh, jint maxw, jint maxh) { @@ -782,7 +782,7 @@ void Darwin$CarbonSurface::natSetLimits(jint minw, jint minh, jint maxw, jint ma max.width = maxw > maxMax ? maxMax : (maxw < minMinW ? minMinW : maxw); max.height = maxh > maxMax ? maxMax : (maxh < minMinH ? minMinH : maxh); OSStatus r = WC(SetWindowResizeLimits)(window,&min,&max); - checkStatus(r,"WC(SetWindowResizeLimits)"); + checkStatus(r,"SetWindowResizeLimits"); } @@ -799,25 +799,24 @@ void fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPt } else { NavReplyRecord reply; r = WC(NavDialogGetReply)(dialog,&reply); - checkStatus(r,"WC(NavDialogGetReply)"); + checkStatus(r,"NavDialogGetReply"); AEKeyword keyword; FSRef ref; char buf[4096]; r = WC(AEGetNthPtr)(&reply.selection,1,typeFSRef,&keyword,NULL,&ref,sizeof(ref),NULL); - checkStatus(r,"WC(AEGetNthPtr)"); + checkStatus(r,"AEGetNthPtr"); r = WC(FSRefMakePath)(&ref,(UInt8*)buf,sizeof(buf)-1); - checkStatus(r,"WC(FSRefMakePath)"); + checkStatus(r,"FSRefMakePath"); helper->fileName = JvNewStringLatin1(buf); if(helper->save) helper->saveName = cfStringToJString(reply.saveFileName); r = WC(NavDisposeReply)(&reply); - checkStatus(r,"WC(NavDialogGetReply)"); + checkStatus(r,"NavDialogGetReply"); } helper->sem->release(); break; } case kNavCBTerminate: - WC(DisposeNavEventUPP)((NavEventUPP)helper->rawUPP); WC(NavDialogDispose)(dialog); break; } @@ -830,8 +829,6 @@ void Darwin::natFileDialog(Darwin$FileDialogHelper *helper,jstring suggestion_, OSStatus r; WindowRef window = WC(FrontWindow)(); NavDialogCreationOptions options; - - NavEventUPP handler = WC(NewNavEventUPP)(fileDialogEventHandler); WC(NavGetDefaultDialogCreationOptions)(&options); options.optionFlags = @@ -845,12 +842,11 @@ void Darwin::natFileDialog(Darwin$FileDialogHelper *helper,jstring suggestion_, options.parentWindow = window; if(write) - r = WC(NavCreatePutFileDialog)(&options,0,0,handler,helper,&dlg); + r = WC(NavCreatePutFileDialog)(&options,0,0,fileDialogEventHandlerUPP,helper,&dlg); else - r = WC(NavCreateGetFileDialog)(&options,NULL,handler,NULL,NULL,helper,&dlg); + r = WC(NavCreateGetFileDialog)(&options,NULL,fileDialogEventHandlerUPP,NULL,NULL,helper,&dlg); checkStatus(r,"NavCreate(Get/Put)FileDialog"); - helper->rawUPP = (RawData*)handler; WC(NavDialogRun)(dlg); } @@ -860,11 +856,11 @@ jstring Darwin::natGetClipBoard() { Size size,size2; r = WC(GetCurrentScrap)(&scrap); - checkStatus(r,"WC(GetCurrentScrap)"); + checkStatus(r,"GetCurrentScrap"); r = WC(GetScrapFlavorSize)( scrap, kScrapFlavorTypeUnicode, &size); if(r == scrapFlavorNotFoundErr) return JvNewStringLatin1(""); - checkStatus(r,"WC(GetScrapFlavorSize)"); + checkStatus(r,"GetScrapFlavorSize"); unsigned int length = size/sizeof(UniChar); @@ -873,7 +869,7 @@ jstring Darwin::natGetClipBoard() { size2 = size; r = WC(GetScrapFlavorData)(scrap,kScrapFlavorTypeUnicode,&size2,buf); if(r == scrapFlavorNotFoundErr); - checkStatus(r,"WC(GetScrapFlavorData)"); + checkStatus(r,"GetScrapFlavorData"); if(size2 != size) return JvNewStringLatin1(""); return js; @@ -885,10 +881,10 @@ void Darwin::natSetClipBoard(jstring js) { OSStatus r; r = WC(GetCurrentScrap)(&scrap); - checkStatus(r,"WC(GetCurrentScrap)"); + checkStatus(r,"GetCurrentScrap"); r = WC(PutScrapFlavor)(scrap,kScrapFlavorTypeUnicode,0,sizeof(UniChar)*length,JvGetStringChars(js)); - checkStatus(r,"WC(PutScrapFlavor)"); + checkStatus(r,"PutScrapFlavor"); } HTTP$Proxy *Darwin::natDetectProxy() { @@ -1019,17 +1015,26 @@ void Darwin::_newBrowserWindow(jstring js) { void Darwin::natInit() { OSStatus r; + + if(pthread_mutex_init(&blit_mutex,NULL) != 0) funcFailed("pthread_mutex_init"); + if(pthread_cond_init(&blit_cond,NULL) != 0) funcFailed("pthread_cond_init"); + + carbonMessageEventHandlerUPP = WC(NewEventHandlerUPP)(carbonMessageEventHandler); + windowEventHandlerUPP = WC(NewEventHandlerUPP)(windowEventHandler); + fileDialogEventHandlerUPP = WC(NewNavEventUPP)(fileDialogEventHandler); + paintProcUPP = WC(NewWindowPaintUPP)(paintProc); + #ifdef XWT_CARBON_NO_BUNDLE_HACK { ProcessSerialNumber currentProcess = { 0, kCurrentProcess }; ::fprintf(stderr,"Doing XWT_CARBON_NO_BUNDLE_HACK\n"); r = WC(GetCurrentProcess)(¤tProcess); - checkStatus(r,"WC(GetCurrentProcess)"); + checkStatus(r,"GetCurrentProcess"); r = WC(CPSEnableForegroundOperation)( ¤tProcess ); - checkStatus(r,"WC(CPSEnableForegroundOperation)"); + checkStatus(r,"CPSEnableForegroundOperation"); r = WC(CPSSetFrontProcess)(¤tProcess); - checkStatus(r,"WC(CPSSetFrontProcess)"); + checkStatus(r,"CPSSetFrontProcess"); } #else { @@ -1040,7 +1045,7 @@ void Darwin::natInit() { checkStatus(r,"SetMenuBarFromNib"); DisposeNibReference(nib); - // FIXME: Install menu event handler + // FEATURE: Install menu event handler } #endif } @@ -1076,7 +1081,7 @@ jboolean Darwin$CarbonOpenGL::initPixelFormat() { void Darwin$CarbonOpenGL::initSharedContext() { AGLPixelFormat fmt = (AGLPixelFormat) rawPixelFormat; rawSharedContext = (RawData*) WC(aglCreateContext)(fmt,NULL); - checkStatus(rawSharedContext,"WC(aglCreateContext)"); + checkStatus(rawSharedContext,"aglCreateContext"); } void Darwin$GLCarbonPixelBuffer::natInit() { @@ -1096,15 +1101,15 @@ void Darwin$GLCarbonPixelBuffer::natInit() { rect.bottom = height + rect.top; r = WC(CreateNewWindow)(wc,attr,&rect,&window); - checkStatus(r,"WC(CreateNewWindow)"); + checkStatus(r,"CreateNewWindow"); shared = (AGLContext) gl->rawSharedContext; fmt = (AGLPixelFormat) gl->rawPixelFormat; ctx = WC(aglCreateContext)(fmt,shared); - checkStatus(ctx, "WC(aglCreateContext)"); + checkStatus(ctx, "aglCreateContext"); b = WC(aglSetDrawable)(ctx,WC(GetWindowPort)(window)); - checkStatus(b,"WC(aglSetDrawable)"); + checkStatus(b,"aglSetDrawable"); WC(aglSetCurrentContext)(ctx); WC(aglUpdateContext)(ctx); @@ -1140,15 +1145,63 @@ void Darwin$GLCarbonPixelBuffer::natCleanup(RawData* rawWindowRef, RawData* rawC WC(DisposeWindow)(window); } +void Darwin$GLCarbonSurface::clear() { + AGLContext ctx = (AGLContext) rawCTX; + WC(aglSetCurrentContext)(ctx); + glColor4f(1.0f,1.0f,1.0f,1.0f); + + glMatrixMode (GL_MODELVIEW); + glPushMatrix (); + glLoadIdentity (); + glMatrixMode (GL_PROJECTION); + glPushMatrix (); + glLoadIdentity (); + glBegin (GL_QUADS); + glVertex3i (-1, -1, -1); + glVertex3i (1, -1, -1); + glVertex3i (1, 1, -1); + glVertex3i (-1, 1, -1); + glEnd (); + glPopMatrix (); + glMatrixMode (GL_MODELVIEW); + glPopMatrix (); +} + +void Darwin$GLCarbonSurface::flush() { + AGLContext ctx = (AGLContext) rawCTX; + WC(aglSetCurrentContext)(ctx); + glFlush(); +} + +// blit_lock is assumed to be held +void Darwin$GLCarbonSurface::reshape(jint w, jint h) { + AGLContext ctx = (AGLContext) rawCTX; + WC(aglSetCurrentContext)(ctx); + WC(aglUpdateContext)(ctx); + + glViewport(0,0,w,h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0,w,h,0,-1,1); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef (0.375f, 0.375f, 0.0f); + checkGLError(); +} + +// blit_lock is assumed to be held void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonPixelBuffer *db, jint sx1, jint sy1, jint dx1, jint dy1, jint dx2, jint dy2) { AGLContext ctx = (AGLContext) rawCTX; int sx2 = sx1 + (dx2-dx1); int sy2 = sy1 + (dy2-dy1); + jint w, h; db->activateContext(); glFlush(); checkGLError(); + WC(aglSetCurrentContext)(ctx); checkGLError(); + if(db->rectTexture) { glEnable(GL_TEXTURE_RECTANGLE_EXT); checkGLError(); @@ -1191,23 +1244,6 @@ void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonPixelBuffer *db, jint sx1, j glDisable(GL_TEXTURE_2D); checkGLError(); } - glFlush(); -} - -void Darwin$GLCarbonSurface::natReshape(jint w, jint h) { - AGLContext ctx = (AGLContext) rawCTX; - - WC(aglSetCurrentContext) (ctx); - WC(aglUpdateContext)(ctx); - - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, w, h, 0, -1, 1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef (0.375, 0.375, 0.0); - checkGLError(); } void Darwin$GLCarbonSurface::natInit() { @@ -1219,20 +1255,20 @@ void Darwin$GLCarbonSurface::natInit() { shared = (AGLContext) gl->rawSharedContext; fmt = (AGLPixelFormat) gl->rawPixelFormat; ctx = WC(aglCreateContext)(fmt,shared); - checkStatus(ctx, "WC(aglCreateContext)"); + checkStatus(ctx, "aglCreateContext"); b = WC(aglSetDrawable)(ctx,WC(GetWindowPort)(window)); - checkStatus(b,"WC(aglSetDrawable)"); + checkStatus(b,"aglSetDrawable"); WC(aglSetCurrentContext)(ctx); - checkGLError(); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); - rawCTX = (RawData*)ctx; + glClearColor (1.0f, 1.0f, 1.0f, 1.0f); + glClearDepth( 0.0f ); - reshape(10,10); - - WC(aglSetCurrentContext)(ctx); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + needsReshape(); + + rawCTX = (RawData*)ctx; } void Darwin$GLCarbonSurface::natDispose() { diff --git a/src/org/xwt/plat/Darwin.java b/src/org/xwt/plat/Darwin.java index 0812a3d..8da005c 100644 --- a/src/org/xwt/plat/Darwin.java +++ b/src/org/xwt/plat/Darwin.java @@ -47,7 +47,6 @@ public class Darwin extends POSIX { public Semaphore sem = new Semaphore(); public String fileName; public String saveName; - public RawData rawUPP; } private native void natFileDialog(FileDialogHelper helper, String suggestedFileName, boolean write); protected String _fileDialog(final String fn, final boolean w) { @@ -93,13 +92,10 @@ public class Darwin extends POSIX { throw new Error("No OpenGL support"); } natInit(); - new Thread() { - public void run() { - runApplicationEventLoop(); - } - }.start(); } + public void _running() { runApplicationEventLoop(); } + private final class CarbonOpenGL extends OpenGL { public RawData rawPixelFormat; public RawData rawSharedContext; @@ -132,8 +128,11 @@ public class Darwin extends POSIX { static abstract class CarbonSurface extends Surface.DoubleBufferedSurface { RawData rawWindowRef; - RawData rawEventHandlerUPP; int modifiers; + int winWidth; + int winHeight; + + boolean pendingResize; private native void natSetInvisible(boolean i); public void setInvisible(final boolean i) { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetInvisible(i); } }); } @@ -172,9 +171,7 @@ public class Darwin extends POSIX { final int n_ = n; CarbonMessage.add(new CarbonMessage() { public void perform() { natSyncCursor(n_); } }); } - - public void _sizeChange(int w, int h) { SizeChange(w,h); } - + /* Drawing stuff */ public abstract void blit(PixelBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2); @@ -190,7 +187,10 @@ public class Darwin extends POSIX { sem.block(); } - public void reshape(int w, int h) { } + public void needsReshape() { } + protected static native void blitLock(); + protected static native void blitUnlock(); + protected static native void blitWait(); } static class GLCarbonPixelBuffer extends OpenGL.GLPixelBuffer { @@ -226,9 +226,11 @@ public class Darwin extends POSIX { static class GLCarbonSurface extends CarbonSurface { RawData rawCTX; CarbonOpenGL gl; - boolean sizeChange; - + boolean needsReshape; + private final native void natInit(); + private final native void flush(); + private final native void clear(); public GLCarbonSurface(Box root, boolean framed, CarbonOpenGL gl) { super(root,framed); @@ -241,26 +243,38 @@ public class Darwin extends POSIX { mxh = Math.min(mxh,gl.maxSurfaceHeight); super.setLimits(mnw,mnh,mxw,mxh); } - public void _sizeChange(int w, int h) { - sizeChange = true; - super._sizeChange(w,h); - } public void setSize(int w, int h) { - sizeChange = true; w = Math.min(w,gl.maxSurfaceWidth); h = Math.min(h,gl.maxSurfaceWidth); super.setSize(w,h); } private native void natBlit(GLCarbonPixelBuffer db, int sx, int sy, int dx, int dy, int dx2, int dy2); - public synchronized void blit(PixelBuffer db, int sx, int sy, int dx, int dy, int dx2, int dy2) { + public void blit(PixelBuffer db, int sx, int sy, int dx, int dy, int dx2, int dy2) { natBlit((GLCarbonPixelBuffer)db,sx,sy,dx,dy,dx2,dy2); } - private native void natReshape(int w, int h); - public synchronized void reshape(int w, int h) { natReshape(w,h); } + // The blit_lock ensures the window size does not change through the entire blit operation. + public void render_() { + blitLock(); + while(pendingResize) blitWait(); + if(needsReshape) { + needsReshape = false; + + reshape(winWidth,winHeight); + clear(); + Dirty(0,0,getWidth(),getHeight()); + } + super.render_(); + flush(); + blitUnlock(); + } + + private native void reshape(int w, int h); + // blit_lock is assumed to be held + public void needsReshape() { needsReshape = true; } public native void natDispose(); } diff --git a/src/org/xwt/plat/DarwinCarbonHeaders.h b/src/org/xwt/plat/DarwinCarbonHeaders.h index c6953a5..4106ab7 100644 --- a/src/org/xwt/plat/DarwinCarbonHeaders.h +++ b/src/org/xwt/plat/DarwinCarbonHeaders.h @@ -1,6 +1,7 @@ // stuff needed from Mac OS headers that ARE NOT in /usr/include // this stuff usually comes from /System/Library/Frameworks/*/Headers +#include typedef u_int8_t uint8_t; typedef u_int16_t uint16_t; @@ -1559,88 +1560,6 @@ Boolean CFURLGetFSRef(CFURLRef url, struct FSRef *fsRef); } -typedef int boolean_t; -typedef unsigned int natural_t; -typedef int integer_t; - - - - - -typedef natural_t vm_offset_t; - - - - - - -typedef natural_t vm_size_t; - - - - -typedef unsigned int space_t; -typedef natural_t port_name_t; -typedef port_name_t *port_name_array_t; - - -typedef port_name_t port_t; -typedef port_t mach_port_t; -typedef port_t *mach_port_array_t; -typedef port_name_t mach_port_name_t; -typedef mach_port_name_t *mach_port_name_array_t; -typedef natural_t mach_port_right_t; -typedef natural_t mach_port_type_t; -typedef mach_port_type_t *mach_port_type_array_t; -typedef natural_t mach_port_urefs_t; -typedef integer_t mach_port_delta_t; - - - -typedef natural_t mach_port_seqno_t; -typedef natural_t mach_port_mscount_t; -typedef natural_t mach_port_msgcount_t; -typedef natural_t mach_port_rights_t; - - - - - - -typedef unsigned int mach_port_srights_t; - -typedef struct mach_port_status { - mach_port_name_t mps_pset; - mach_port_seqno_t mps_seqno; - mach_port_mscount_t mps_mscount; - mach_port_msgcount_t mps_qlimit; - mach_port_msgcount_t mps_msgcount; - mach_port_rights_t mps_sorights; - boolean_t mps_srights; - boolean_t mps_pdrequest; - boolean_t mps_nsrequest; - unsigned int mps_flags; -} mach_port_status_t; - - - - -typedef struct mach_port_limits { - mach_port_msgcount_t mpl_qlimit; -} mach_port_limits_t; - -typedef integer_t *mach_port_info_t; - - -typedef int mach_port_flavor_t; -typedef struct mach_port_qos { - boolean_t name:1; - boolean_t prealloc:1; - boolean_t pad1:30; - natural_t len; -} mach_port_qos_t; - - extern "C" { @@ -2701,484 +2620,7 @@ CFDataRef CFXMLTreeCreateXMLData(CFAllocatorRef allocator, CFXMLTreeRef xmlTree) } -extern "C" { -extern void __eprintf (const char *, const char *, unsigned, const char *) - __attribute__ ((noreturn)); -} -typedef struct { - rune_t min; - rune_t max; - rune_t map; - unsigned long *types; -} _RuneEntry; - -typedef struct { - int nranges; - _RuneEntry *ranges; -} _RuneRange; - -typedef struct { - char magic[8]; - char encoding[32]; - - rune_t (*sgetrune) - (const char *, size_t, char const **); - int (*sputrune) - (rune_t, char *, size_t, char **); - rune_t invalid_rune; - - unsigned long runetype[(1 <<8 )]; - rune_t maplower[(1 <<8 )]; - rune_t mapupper[(1 <<8 )]; - - - - - - - _RuneRange runetype_ext; - _RuneRange maplower_ext; - _RuneRange mapupper_ext; - - void *variable; - int variable_len; -} _RuneLocale; - - - -extern _RuneLocale _DefaultRuneLocale; -extern _RuneLocale *_CurrentRuneLocale; -extern "C" { -int isalnum (int); -int isalpha (int); -int iscntrl (int); -int isdigit (int); -int isgraph (int); -int islower (int); -int isprint (int); -int ispunct (int); -int isspace (int); -int isupper (int); -int isxdigit (int); -int tolower (int); -int toupper (int); - - -int digittoint (int); -int isascii (int); -int isblank (int); -int ishexnumber (int); -int isideogram (int); -int isnumber (int); -int isphonogram (int); -int isrune (int); -int isspecial (int); -int toascii (int); - -} -extern "C" { -unsigned long ___runetype (int); -int ___tolower (int); -int ___toupper (int); -} -static inline int -__maskrune(int _c, unsigned long _f) -{ - return ((_c < 0 || _c >= (1 <<8 )) ? ___runetype(_c) : - _CurrentRuneLocale->runetype[_c]) & _f; -} - -static inline int -__istype(int c, unsigned long f) -{ - return !!(__maskrune(c, f)); -} - -static inline int -__isctype(int _c, unsigned long _f) -{ - return (_c < 0 || _c >= (1 <<8 )) ? 0 : - !!(_DefaultRuneLocale.runetype[_c] & _f); -} - -static inline int -__toupper(int _c) -{ - return (_c < 0 || _c >= (1 <<8 )) ? ___toupper(_c) : - _CurrentRuneLocale->mapupper[_c]; -} - -static inline int -__tolower(int _c) -{ - return (_c < 0 || _c >= (1 <<8 )) ? ___tolower(_c) : - _CurrentRuneLocale->maplower[_c]; -} -extern "C" { -extern int * __error (void); - -} - - - - - - -struct lconv { - char *decimal_point; - char *thousands_sep; - char *grouping; - char *int_curr_symbol; - char *currency_symbol; - char *mon_decimal_point; - char *mon_thousands_sep; - char *mon_grouping; - char *positive_sign; - char *negative_sign; - char int_frac_digits; - char frac_digits; - char p_cs_precedes; - char p_sep_by_space; - char n_cs_precedes; - char n_sep_by_space; - char p_sign_posn; - char n_sign_posn; -}; -extern "C" { -struct lconv *localeconv (void); -char *setlocale (int, const char *); -} -extern "C" { - - - - - - -typedef float float_t; -typedef double double_t; -enum { - FP_NAN = 1, - FP_INFINITE = 2, - FP_ZERO = 3, - FP_NORMAL = 4, - FP_SUBNORMAL = 5 -}; -extern unsigned int __math_errhandling ( void ); -extern long __fpclassifyd( double x ); -extern long __fpclassifyf( float x ); -extern long __fpclassify( long double x ); - - - inline long __fpclassify( long double x ) { return __fpclassifyd((double)( x )); } - - - - - - -extern long __isnormald( double x ); -extern long __isnormalf( float x ); -extern long __isnormal( long double x ); - - - inline long __isnormal( long double x ) { return __isnormald((double)( x )); } - - - - - -extern long __isfinited( double x ); -extern long __isfinitef( float x ); -extern long __isfinite( long double x ); - - - inline long __isfinite( long double x ) { return __isfinited((double)( x )); } - - - - - - -extern long __isinfd( double x ); -extern long __isinff( float x ); -extern long __isinf( long double x ); - - - inline long __isinf( long double x ) { return __isinfd((double)( x )); } - - - - - -extern long __isnand( double x ); -extern long __isnanf( float x ); -extern long __isnan( long double x ); - - - inline long __isnan( long double x ) { return __isnand((double)( x )); } - - - - - - -extern long __signbitd( double x ); -extern long __signbitf( float x ); -extern long __signbitl( long double x ); - - - inline long __signbitl( long double x ) { return __signbitd((double)( x )); } -extern double acos( double x ); -extern double asin( double x ); -extern double atan( double x ); -extern double atan2( double y, double x ); -extern double cos( double x ); -extern double sin( double x ); -extern double tan( double x ); -extern double acosh( double x ); -extern double asinh( double x ); -extern double atanh( double x ); -extern double cosh( double x ); -extern double sinh( double x ); -extern double tanh( double x ); - -extern double exp ( double x ); -extern double exp2 ( double x ); -extern double expm1 ( double x ); -extern double log ( double x ); -extern double log10 ( double x ); -extern double log2 ( double x ); -extern double log1p ( double x ); - -extern double logb ( double x ); -extern float logbf ( float x ); - -extern double modf ( double x, double *iptr ); -extern float modff ( float x, float *iptr ); - -extern double ldexp ( double value, int exp ); -extern float ldexpf ( float value, int exp ); - -extern double frexp ( double value, int *eptr ); -extern float frexpf ( float value, int *eptr ); - -extern int ilogb ( double x ); -extern int ilogbf ( float x ); - -extern double scalbn ( double x, int n ); -extern float scalbnf ( float x, int n ); - -extern double scalbln ( double x, long int n ); -extern float scalblnf ( float x, long int n ); - -extern double fabs( double x ); -extern float fabsf( float x ); - -extern double cbrt( double x ); -extern double hypot ( double x, double y ); -extern double pow ( double x, double y ); -extern double sqrt( double x ); - -extern double erf( double x ); -extern double erfc( double x ); -extern double lgamma( double x ); -extern double tgamma( double x ); - -extern double ceil ( double x ); -extern float ceilf ( float x ); - -extern double floor ( double x ); -extern float floorf ( float x ); - -extern double nearbyint ( double x ); -extern float nearbyintf ( float x ); - -extern double rint ( double x ); -extern float rintf ( float x ); - -extern long int lrint ( double x ); -extern long int lrintf ( float x ); - -extern long long int llrint ( double x ); -extern long long int llrintf ( float x ); - -extern double round ( double x ); -extern float roundf ( float x ); - -extern long int lround ( double x ); -extern long int lroundf ( float x ); - -extern long long int llround ( double x ); -extern long long int llroundf ( float x ); - -extern double trunc ( double x ); -extern float truncf ( float x ); - -extern double fmod ( double x, double y ); -extern float fmodf ( float x, float y ); - -extern double remainder ( double x, double y ); -extern float remainderf ( float x, float y ); - -extern double remquo ( double x, double y, int *quo ); -extern float remquof ( float x, float y, int *quo ); - -extern double copysign ( double x, double y ); -extern float copysignf ( float x, float y ); - -extern double nan( const char *tagp ); -extern float nanf( const char *tagp ); - -extern double nextafter ( double x, double y ); -extern float nextafterf ( float x, float y ); - -extern double fdim ( double x, double y ); -extern float fdimf ( float x, float y ); - -extern double fmax ( double x, double y ); -extern float fmaxf ( float x, float y ); - -extern double fmin ( double x, double y ); -extern float fminf ( float x, float y ); - -extern double fma ( double x, double y, double z ); -extern float fmaf ( float x, float y, float z ); -extern double __inf( void ); -extern float __inff( void ); -extern float __nan( void ); - - - - - - -extern long int rinttol ( double x ); - -extern long int roundtol ( double x ); - -typedef struct _complx { - double Real; - double Imag; -} _complex; -extern int signgam; - - -enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix}; -extern enum fdversion _fdlib_version; -extern int finite ( double x ); - -extern double gamma ( double x ); - -extern double j0 ( double x ); -extern double j1 ( double x ); -extern double jn ( int n, double x ); - -extern double y0 ( double x ); -extern double y1 ( double x ); -extern double yn ( int n, double x ); - - - -extern double scalb ( double x, int n ); -extern double significand ( double x ); - - - - -extern double cabs ( _complex z ); - -extern double drem ( double x, double y ); -} - - - - - - - -extern double acos (double); -extern double asin (double); -extern double atan (double); -extern double atan2 (double, double); -extern double ceil (double); -extern double cos (double); -extern double cosh (double); -extern double exp (double); -extern double fabs (double); -extern double floor (double); -extern double fmod (double, double); -extern double frexp (double, int *); -extern double ldexp (double, int); -extern double log10 (double); -extern double log (double); -extern double modf (double, double *); -extern double pow (double, double); -extern double sin (double); -extern double sinh (double); -extern double sqrt (double); -extern double tan (double); -extern double tanh (double); - - -typedef int ptrdiff_t; - - - -struct timespec { - time_t tv_sec; - long tv_nsec; -}; - - -struct tm { - int tm_sec; - int tm_min; - int tm_hour; - int tm_mday; - int tm_mon; - int tm_year; - int tm_wday; - int tm_yday; - int tm_isdst; - long tm_gmtoff; - char *tm_zone; -}; -extern char *tzname[]; - - -extern "C" { -char *asctime (const struct tm *); -clock_t clock (void); -char *ctime (const time_t *); -double difftime (time_t, time_t); -struct tm *gmtime (const time_t *); -struct tm *localtime (const time_t *); -time_t mktime (struct tm *); -size_t strftime (char *, size_t, const char *, const struct tm *); -time_t time (time_t *); - - -void tzset (void); - - - -char *asctime_r (const struct tm *, char *); -char *ctime_r (const time_t *, char *); -struct tm *gmtime_r (const time_t *, struct tm *); -struct tm *localtime_r (const time_t *, struct tm *); -char *strptime (const char *, const char *, struct tm *); -char *timezone (int, int); -void tzsetwall (void); -time_t timelocal (struct tm * const); -time_t timegm (struct tm * const); - - - -int nanosleep (const struct timespec *, struct timespec *); - -} extern "C" { diff --git a/src/org/xwt/plat/OpenGL.cc b/src/org/xwt/plat/OpenGL.cc index 8200b16..71870c7 100644 --- a/src/org/xwt/plat/OpenGL.cc +++ b/src/org/xwt/plat/OpenGL.cc @@ -17,7 +17,7 @@ #include #include #else -#warning I am not sure if these is correct +#warning I am not sure if these are correct #include #include #include