From 80e82433fb92366d007d63d4ba44b25dfa9f4425 Mon Sep 17 00:00:00 2001 From: megacz Date: Fri, 30 Jan 2004 07:06:00 +0000 Subject: [PATCH] 2003/09/08 20:40:48 darcs-hash:20040130070600-2ba56-539a53dd5b3778b5092f404ffee9ec583e080cc0.gz --- Makefile | 24 +++++---- src/org/xwt/plat/Darwin.cc | 120 ++++++++++++++++++++++---------------------- 2 files changed, 73 insertions(+), 71 deletions(-) diff --git a/Makefile b/Makefile index becfcd7..f3e1e35 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ JVM: build/JVM/xwt.jar Linux: ; make gcj platform=Linux target=i686-pc-linux-gnu link_flags="-lX11 -lXext --static" Solaris: ; make gcj platform=Solaris target=sparc-sun-solaris2.7 link_flags="-lX11 -lXext" Win32: ; make gcj platform=Win32 target=i686-pc-mingw32 link_flags="-Wl,--subsystem,windows -lcomdlg32" target_bin=xwt.exe -Darwin: ; make gcj platform=Darwin target=powerpc-apple-darwin link_flags=-Wl,-framework,Carbon,-framework,OpenGL,-framework,AGL,-framework,SystemConfiguration +Darwin: ; make gcj platform=Darwin target=powerpc-apple-darwin link_flags="-lgcj -lSystem -lgcc -lmathCommon.A upstream/install/powerpc-apple-darwin/lib/crt1.o" ############################################################################# @@ -20,10 +20,10 @@ jikes_flags := -nowarn -sourcepath src/ gcc_optimizations := -O2 #gcc_optimizations := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls #gcc_optimizations += -finline-functions -funroll-loops -ffunction-sections -fdata-sections -gcc_flags := -nostdinc $(gcc_optimizations) -Ibuild/h -Iupstream/jpeg-6b/src/ +gcc_flags := -nostdinc $(gcc_optimizations) -Ibuild/h -Iupstream/jpeg-6b/src/ -Iupstream/jpeg-6b/build-$(target)/ gcj_flags := -fCLASSPATH=build/java gcj := upstream/install/bin/$(target)-gcj $(gcc_flags) $(gcj_flags) -g++ := upstream/install/bin/$(target)-g++ $(gcc_flags) +g++ := upstream/install/bin/$(target)-gcj $(gcc_flags) gcc := upstream/install/bin/$(target)-gcc $(gcc_flags) jar := $(shell ((type fastjar &>/dev/null) && echo fastjar) || echo jar) @@ -33,11 +33,10 @@ include Makefile.upstream jpeg_c_sources := jdapimin.c jdapistd.c jcomapi.c jcparam.c jdmaster.c jdinput.c jdmainct.c jdcoefct.c jdpostct.c jdmarker.c jpeg_c_sources += jdhuff.c jdphuff.c jddctmgr.c jidctint.c jidctfst.c jidctflt.c jidctred.c jdsample.c jdcolor.c jdmerge.c jpeg_c_sources += jquant1.c jquant2.c jerror.c jutils.c jmemnobs.c jmemmgr.c - -upstream/jpeg-6b/src/%.c: download_jpeg-6b +upstream/jpeg-6b/src/%.c: .download_jpeg-6b freetype_sources := ftsystem.c ftmm.c ftbbox.c ftinit.c ftdebug.c ftbase.c ftglyph.c smooth.c sfnt.c truetype.c -upstream/freetype-2.1.4/%.c: download_freetype-2.1.4 +upstream/freetype-2.1.4/%.c: .download_freetype-2.1.4 java_sources := $(patsubst src/%.java, build/java/%.java, $(shell find src -name \*.java)) java_sources += $(patsubst src/%.java.pp, build/java/%.java, $(shell find src -name \*.java.pp)) @@ -80,18 +79,20 @@ build/h/%.h: build/class/%.class .compile sed s_build/class/__ | sed s/.class\$$//g | sed s_/_._g | (cd build/class; xargs ../../upstream/install/bin/$(target)-gcjh -d ../h --classpath .) # a hack since we've disabled gcj's awt implementation -build/$(platform)/org/xwt/plat/Java2.java.o: ; mkdir -p $(@D); touch $@ -build/$(platform)/org/xwt/plat/AWT.java.o: ; mkdir -p $(@D); touch $@ +build/$(platform)/org/xwt/plat/Java2.java.o: + touch .empty.c; mkdir -p $(@D); $(gcc) -c .empty.c -o $@; +build/$(platform)/org/xwt/plat/AWT.java.o: + touch .empty.c; mkdir -p $(@D); $(gcc) -c .empty.c -o $@; build/$(platform)/%.java.o: build/java/%.java @echo -e "\n\033[1mcompiling .java -> .o: $<\033[0m" mkdir -p `dirname $@` $(gcj) -c $< -o $@ -build/$(platform)/org/xwt/plat/$(platform).cc.o: src/org/xwt/plat/$(platform).cc src/org/xwt/plat/*.cc $(java_headers) +build/$(platform)/org/xwt/plat/$(platform).cc.o: src/org/xwt/plat/$(platform).cc src/org/xwt/plat/*.cc $(java_headers) .configure_jpeg-6b_$(target) @echo -e "\n\033[1mcompiling .cc -> .o: $<\033[0m" mkdir -p `dirname $@` - $(g++) -I/usr/X11R6/include/ -Iupstream/install/include -Ibuild/h -Iupstream/$(target)/include -Wno-multichar -c $< -o $@ + $(g++) -Iupstream/install/lib/gcc-lib/$(target)/3.3/include/ -Iupstream/install/$(target)/include -I/usr/X11R6/include/ -Ibuild/h -Wno-multichar -Iupstream/install/include -c $< -o $@ build/$(platform)/jpeg-6b/%.c.o: upstream/jpeg-6b/src/%.c @echo -e "\n\033[1mcompiling .c -> .o: $<\033[0m" @@ -103,11 +104,12 @@ $(target_bin).ar: $(java_sources:build/java/%.java=build/$(platform)/%.java.o) b @echo -e "\n\033[1marchiving .o -> $(target_bin).ar\033[0m" rm -f $(target_bin).ar upstream/install/$(target)/bin/ar -cq $(target_bin).ar $^ + upstream/install/$(target)/bin/ranlib $(target_bin).ar $(target_bin): $(target_bin).ar @echo -e "\n\033[1mlinking .o -> $(target_bin)\033[0m" mkdir -p build/$(platform) - $(gcj) -nostdlib --main=org.xwt.Main -o build/$(platform)/$(target_bin) $(target_bin).ar -Lupstream/install/$(target)/lib $(link_flags) + PATH=upstream/install/bin:$$PATH $(gcj) -nostdlib --main=org.xwt.Main -o build/$(platform)/$(target_bin) $(target_bin).ar -Lupstream/install/$(target)/lib $(link_flags) ############################################################################## diff --git a/src/org/xwt/plat/Darwin.cc b/src/org/xwt/plat/Darwin.cc index 914ba77..76c4fd6 100644 --- a/src/org/xwt/plat/Darwin.cc +++ b/src/org/xwt/plat/Darwin.cc @@ -13,13 +13,13 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -42,13 +42,13 @@ using java::lang::Object; namespace org { namespace xwt { namespace plat { -namespace carbon { } -using namespace carbon; +namespace darwin { } +using namespace darwin; #pragma mark ------ Carbon Namespace ------ -namespace carbon { - // We put everything that isn't in org.xwt.plat.Carbon in - // org.xwt.plat.carbon to prevent namespace conflicts +namespace darwin { + // 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; } @@ -125,19 +125,19 @@ namespace carbon { const static UInt32 kEventCarbonMessage = 'xwtb'; const static UInt32 kEventParamCarbonMessage = 'xwtc'; - pascal OSStatus carbon::carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData); + pascal OSStatus darwin::carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData); void fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData); } // end namespace -jboolean Carbon::isJaguar() { +jboolean Darwin::isJaguar() { SInt32 version; OSStatus r = Gestalt(gestaltSystemVersion, &version); checkStatus(r,"Gestalt"); return version >= 0x1020; } -void Carbon$CarbonMessage::natInit() { +void Darwin$CarbonMessage::natInit() { OSStatus r; EventHandlerUPP upp = NewEventHandlerUPP(carbonMessageEventHandler); @@ -146,7 +146,7 @@ void Carbon$CarbonMessage::natInit() { checkStatus(r,"InstallEventHandler"); } -void Carbon$CarbonMessage::add(Carbon$CarbonMessage *msg) { +void Darwin$CarbonMessage::add(Darwin$CarbonMessage *msg) { EventRef event; OSStatus r; @@ -162,11 +162,11 @@ void Carbon$CarbonMessage::add(Carbon$CarbonMessage *msg) { } -pascal OSStatus carbon::carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) { +pascal OSStatus darwin::carbonMessageEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) { UInt32 eKind = GetEventKind(e); UInt32 eClass = GetEventClass(e); OSStatus r; - Carbon$CarbonMessage *msg; + Darwin$CarbonMessage *msg; if(eClass != kEventClassCarbonMessage || eKind != kEventCarbonMessage) return eventNotHandledErr; r = GetEventParameter(e,kEventParamCarbonMessage,typeVoidPtr,NULL,sizeof(msg),NULL,&msg); @@ -179,7 +179,7 @@ pascal OSStatus carbon::carbonMessageEventHandler(EventHandlerCallRef handler, E #pragma mark ------ Utility Functions ------ -void carbon::funcFailed(char *func,int r){ +void darwin::funcFailed(char *func,int r){ fprintf(stderr,"%s() failed (%d)\n",func,r); exit(EXIT_FAILURE); } @@ -189,7 +189,7 @@ void carbon::funcFailed(char *func,int r){ #pragma mark ----- Carbon Surface Methods ---- -void Carbon$CarbonSurface::natSyncCursor(jint n) { +void Darwin$CarbonSurface::natSyncCursor(jint n) { ThemeCursor c; // see Carbon.java for what these numbers mean switch(n) { @@ -204,46 +204,46 @@ void Carbon$CarbonSurface::natSyncCursor(jint n) { SetThemeCursor(c); } -void Carbon$CarbonSurface::natSetInvisible(jboolean b) { +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); } -void Carbon$CarbonSurface::nat_setMaximized(jboolean b) { +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"); } -void Carbon$CarbonSurface::nat_setMinimized(jboolean b) { +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"); } -void Carbon$CarbonSurface::natSetTitleBarText(jstring js) { +void Darwin$CarbonSurface::natSetTitleBarText(jstring js) { SmartCFString s = js; WindowRef window = (WindowRef) rawWindowRef; SetWindowTitleWithCFString(window,s); } -void Carbon$CarbonSurface::natToBack() { +void Darwin$CarbonSurface::natToBack() { WindowRef window = (WindowRef) rawWindowRef; SendBehind(window,NULL); } -void Carbon$CarbonSurface::natToFront() { +void Darwin$CarbonSurface::natToFront() { WindowRef window = (WindowRef) rawWindowRef; fprintf(stderr,"SelectWindow()\n"); SelectWindow(window); } #pragma mark ---- Window Event Handler ---- -namespace carbon { +namespace darwin { static const EventTypeSpec eventTypeSpecs[] = { // kEventClassCommand // { kEventClassCommand, ??? }, @@ -274,7 +274,7 @@ static const EventTypeSpec eventTypeSpecs[] = { }; pascal OSStatus windowEventHandler(EventHandlerCallRef handler, EventRef e, void *userData) { - Carbon$CarbonSurface *surface = (Carbon$CarbonSurface*) userData; + Darwin$CarbonSurface *surface = (Darwin$CarbonSurface*) userData; UInt32 eKind = GetEventKind(e); UInt32 eClass = GetEventClass(e); OSStatus r; @@ -453,11 +453,11 @@ pascal OSStatus windowEventHandler(EventHandlerCallRef handler, EventRef e, void r = GetEventParameter(e,kEventParamDirectObject,typeWindowRef,NULL,sizeof(window),NULL,&window); checkStatus(r,"kEventClassWindow/GetEventParameter"); - if((RawData*)window != surface->rawWindowRef) Carbon::abort(JvNewStringLatin1("window != surface->window")); + if((RawData*)window != surface->rawWindowRef) Darwin::abort(JvNewStringLatin1("window != surface->window")); switch(eKind) { case kEventWindowUpdate: { - surface->Dirty(0,0,surface->width,surface->height); + surface->Dirty(0,0,surface->root->width,surface->root->height); return noErr; } case kEventWindowBoundsChanged: { @@ -517,7 +517,7 @@ pascal OSStatus windowEventHandler(EventHandlerCallRef handler, EventRef e, void } } // end namespace -void Carbon$CarbonSurface::natInit(jboolean framed) { +void Darwin$CarbonSurface::natInit(jboolean framed) { WindowRef window; Rect rect; WindowClass wc = framed ? kDocumentWindowClass : kPlainWindowClass; @@ -541,15 +541,15 @@ void Carbon$CarbonSurface::natInit(jboolean framed) { rawEventHandlerUPP = (RawData*) upp; } -void Carbon$CarbonSurface::natDispose() { +void Darwin$CarbonSurface::natDispose() { WindowRef window = (WindowRef) rawWindowRef; DisposeWindow(window); } -void Carbon$CarbonSurface::natSetIcon(org::xwt::Picture *_p) { +void Darwin$CarbonSurface::natSetIcon(org::xwt::Picture *_p) { } -void Carbon$CarbonSurface::natSetLocation(jint x, jint y) { +void Darwin$CarbonSurface::natSetLocation(jint x, jint y) { WindowRef window = (WindowRef) rawWindowRef; Rect rect; OSStatus r = GetWindowBounds(window,kWindowStructureRgn,&rect); @@ -564,7 +564,7 @@ void Carbon$CarbonSurface::natSetLocation(jint x, jint y) { checkStatus(r,"ConstrainWindowToScreen"); } -void Carbon$CarbonSurface::natSetSize(jint w, jint h) { +void Darwin$CarbonSurface::natSetSize(jint w, jint h) { WindowRef window = (WindowRef) rawWindowRef; Rect rect; OSStatus r = GetWindowBounds(window,kWindowStructureRgn,&rect); @@ -577,7 +577,7 @@ void Carbon$CarbonSurface::natSetSize(jint w, jint h) { checkStatus(r,"ConstrainWindowToScreen"); } -void Carbon$CarbonSurface::natSetLimits(jint minw, jint minh, jint maxw, jint maxh) { +void Darwin$CarbonSurface::natSetLimits(jint minw, jint minh, jint maxw, jint maxh) { WindowRef window = (WindowRef) rawWindowRef; const int maxMax = 32767; const int minMinW = 80; @@ -593,8 +593,8 @@ void Carbon$CarbonSurface::natSetLimits(jint minw, jint minh, jint maxw, jint ma #pragma mark ------ Carbon Methods ------ -void carbon::fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData) { - Carbon$FileDialogHelper *helper = (Carbon$FileDialogHelper*) userData; +void darwin::fileDialogEventHandler(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void *userData) { + Darwin$FileDialogHelper *helper = (Darwin$FileDialogHelper*) userData; NavDialogRef dialog = callBackParms->context; OSStatus r; switch(callBackSelector) { @@ -629,7 +629,7 @@ void carbon::fileDialogEventHandler(NavEventCallbackMessage callBackSelector, Na } } -void Carbon::natFileDialog(Carbon$FileDialogHelper *helper,jstring suggestion_, jboolean write) { +void Darwin::natFileDialog(Darwin$FileDialogHelper *helper,jstring suggestion_, jboolean write) { NavDialogRef dlg; SmartCFString suggestion = suggestion_; CFStringRef message = CFSTR("By selecting a file in this dialog you are giving this XWT application permission to access that file."); @@ -637,7 +637,7 @@ void Carbon::natFileDialog(Carbon$FileDialogHelper *helper,jstring suggestion_, WindowRef window = FrontWindow(); NavDialogCreationOptions options; - NavEventUPP handler = NewNavEventUPP(carbon::fileDialogEventHandler); + NavEventUPP handler = NewNavEventUPP(darwin::fileDialogEventHandler); NavGetDefaultDialogCreationOptions(&options); options.optionFlags = @@ -660,7 +660,7 @@ void Carbon::natFileDialog(Carbon$FileDialogHelper *helper,jstring suggestion_, NavDialogRun(dlg); } -jstring Carbon::natGetClipBoard() { +jstring Darwin::natGetClipBoard() { ScrapRef scrap; OSStatus r; Size size,size2; @@ -685,7 +685,7 @@ jstring Carbon::natGetClipBoard() { return js; } -void Carbon::natSetClipBoard(jstring js) { +void Darwin::natSetClipBoard(jstring js) { unsigned int length = js->length(); ScrapRef scrap; OSStatus r; @@ -697,7 +697,7 @@ void Carbon::natSetClipBoard(jstring js) { checkStatus(r,"PutScrapFlavor"); } -Proxy *Carbon::natDetectProxy() { +Proxy *Darwin::natDetectProxy() { using org::xwt::Proxy; Proxy *p=0; CFStringRef string; @@ -806,15 +806,15 @@ doproto(SOCKS,socks) */ } -jint Carbon::cgScreenWidth() { +jint Darwin::cgScreenWidth() { return CGDisplayPixelsWide(kCGDirectMainDisplay); } -jint Carbon::cgScreenHeight() { +jint Darwin::cgScreenHeight() { return CGDisplayPixelsHigh(kCGDirectMainDisplay); } -void Carbon::_newBrowserWindow(jstring js) { +void Darwin::_newBrowserWindow(jstring js) { SmartCFString cfs = js; CFURLRef url = CFURLCreateWithString(kCFAllocatorDefault,cfs,NULL); SmartCFString scheme = CFURLCopyScheme(url); @@ -823,7 +823,7 @@ void Carbon::_newBrowserWindow(jstring js) { CFRelease(url); } -void Carbon::_exit() { +void Darwin::_exit() { QuitApplicationEventLoop(); } @@ -834,7 +834,7 @@ extern "C" { OSErr CPSSetFrontProcess(ProcessSerialNumber *psn); } #endif -void Carbon::natInit() { +void Darwin::natInit() { OSStatus r; #ifdef XWT_CARBON_NO_BUNDLE_HACK { @@ -862,19 +862,19 @@ void Carbon::natInit() { #endif } -void Carbon::_running() { +void Darwin::_running() { RunApplicationEventLoop(); ExitToShell(); } #pragma mark ------ OpenGL Functions ----- -void Carbon$CarbonOpenGL::activateSharedContext() { +void Darwin$CarbonOpenGL::activateSharedContext() { AGLContext ctx = (AGLContext) rawSharedContext; aglSetCurrentContext(ctx); } -jboolean Carbon$CarbonOpenGL::initPixelFormat() { +jboolean Darwin$CarbonOpenGL::initPixelFormat() { GLint attr[] = { AGL_NO_RECOVERY, AGL_RGBA, @@ -890,13 +890,13 @@ jboolean Carbon$CarbonOpenGL::initPixelFormat() { return rawPixelFormat != 0; } -void Carbon$CarbonOpenGL::initSharedContext() { +void Darwin$CarbonOpenGL::initSharedContext() { AGLPixelFormat fmt = (AGLPixelFormat) rawPixelFormat; rawSharedContext = (RawData*) aglCreateContext(fmt,NULL); checkStatus(rawSharedContext,"aglCreateContext"); } -void Carbon$GLCarbonDoubleBuffer::natInit() { +void Darwin$GLCarbonDoubleBuffer::natInit() { WindowClass wc = kPlainWindowClass; WindowAttributes attr = 0; WindowRef window; @@ -945,19 +945,19 @@ void Carbon$GLCarbonDoubleBuffer::natInit() { rawCTX = (RawData*) ctx; } -void Carbon$GLCarbonDoubleBuffer::activateContext() { +void Darwin$GLCarbonDoubleBuffer::activateContext() { AGLContext ctx = (AGLContext) rawCTX; aglSetCurrentContext(ctx); } -void Carbon$GLCarbonDoubleBuffer::natCleanup(RawData* rawWindowRef, RawData* rawCTX) { +void Darwin$GLCarbonDoubleBuffer::natCleanup(RawData* rawWindowRef, RawData* rawCTX) { WindowRef window = (WindowRef) rawWindowRef; AGLContext ctx = (AGLContext) rawCTX; aglDestroyContext(ctx); DisposeWindow(window); } -void Carbon$GLCarbonSurface::natBlit(Carbon$GLCarbonDoubleBuffer *db, jint sx1, jint sy1, jint dx1, jint dy1, jint dx2, jint dy2) { +void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonDoubleBuffer *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); @@ -1011,7 +1011,7 @@ void Carbon$GLCarbonSurface::natBlit(Carbon$GLCarbonDoubleBuffer *db, jint sx1, glFlush(); } -void Carbon$GLCarbonSurface::natReshape(jint w, jint h) { +void Darwin$GLCarbonSurface::natReshape(jint w, jint h) { AGLContext ctx = (AGLContext) rawCTX; aglSetCurrentContext (ctx); @@ -1027,7 +1027,7 @@ void Carbon$GLCarbonSurface::natReshape(jint w, jint h) { checkGLError(); } -void Carbon$GLCarbonSurface::natInit() { +void Darwin$GLCarbonSurface::natInit() { WindowRef window = (WindowRef) rawWindowRef; AGLContext ctx,shared; AGLPixelFormat fmt; @@ -1052,10 +1052,10 @@ void Carbon$GLCarbonSurface::natInit() { glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); } -void Carbon$GLCarbonSurface::natDispose() { +void Darwin$GLCarbonSurface::natDispose() { AGLContext ctx = (AGLContext) rawCTX; aglDestroyContext(ctx); - Carbon$CarbonSurface::natDispose(); + Darwin$CarbonSurface::natDispose(); } } } } // end namepsace org::xwt::plat -- 1.7.10.4