2003/09/24 07:33:33
[org.ibex.core.git] / src / org / xwt / plat / Darwin.java
index 34030ca..0812a3d 100644 (file)
@@ -13,11 +13,6 @@ public class Darwin extends POSIX {
     private CarbonOpenGL openGL;
     boolean jaguar; // true if we are on OS X >= 10.2
     
-    // TEMPORARY HACKS (remove these when we ditch platform fonts)
-    protected int _stringWidth(String font, String text) { return (int)Math.round(6.5 * text.length()); }
-    protected int _getMaxAscent(String font) { return 10; }
-    protected int _getMaxDescent(String font) { return 2; }
-    
     // General Methods
     protected String _getAltKeyName() { return "Option"; }
     protected boolean _needsAutoClick() { return false; }
@@ -32,9 +27,8 @@ public class Darwin extends POSIX {
     private native static int cgScreenWidth();
     private native static int cgScreenHeight();
     protected native void   _newBrowserWindow(String url);
-    protected native Proxy   natDetectProxy();
+    protected native HTTP.Proxy   natDetectProxy();
     private   native void    natInit();
-    protected native void   _exit();
 
     private native String natGetClipBoard();
     private native void natSetClipBoard(String text);
@@ -67,9 +61,6 @@ public class Darwin extends POSIX {
     }
 
     
-    // Called by main thread after initialization, this is the event handler
-    protected native void _running();
-    
     static void abort(String err) {
         throw new Error(err);
     }
@@ -81,26 +72,32 @@ public class Darwin extends POSIX {
         }
     }
     
-    protected synchronized Proxy _detectProxy() {
+    protected synchronized HTTP.Proxy _detectProxy() {
         return natDetectProxy();
     }
     
     private static native final boolean isJaguar();
-    private static native final void linkMe();
+    
+    // Called by main thread after initialization, this is the event handler
+    protected native void runApplicationEventLoop();
     
     public void init() {
         super.init();
-       linkMe();
         jaguar = isJaguar();
         try {
             openGL = new CarbonOpenGL();
             openGL.init();
         } catch(OpenGL.NotSupportedException e) {
             Log.log(this,"WARNING: OpenGL support not available: " + e);
-            // FIXME: We need to fallback to Quartz2D
+            // FEATURE: fall back to quartz 2d
             throw new Error("No OpenGL support");
         }
         natInit();
+        new Thread() {
+            public void run() {
+                runApplicationEventLoop();
+            }
+        }.start();
     }
     
     private final class CarbonOpenGL extends OpenGL {
@@ -133,7 +130,7 @@ public class Darwin extends POSIX {
         protected native void activateSharedContext();
     }
     
-    static abstract class CarbonSurface extends Surface {  
+    static abstract class CarbonSurface extends Surface.DoubleBufferedSurface {  
         RawData rawWindowRef;
         RawData rawEventHandlerUPP;
         int modifiers;
@@ -150,8 +147,8 @@ public class Darwin extends POSIX {
         public void setTitleBarText(final String s) { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetTitleBarText(s); } }); }
         private native void natSetSize(int w, int h);
         public void setSize(final int w, final int h) { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetSize(w,h); } }); }
-        private native void natSetLocation(int x, int y);
-        public void setLocation(final int x, final int y) { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetLocation(x,y); } }); }
+        private native void natSetLocation();
+        public void setLocation() { CarbonMessage.add(new CarbonMessage() { public void perform() { natSetLocation(); } }); }
         private native void natToFront();
         public void toFront() { CarbonMessage.add(new CarbonMessage() { public void perform() { natToFront(); } }); }
         private native void natToBack();
@@ -196,7 +193,7 @@ public class Darwin extends POSIX {
         public void reshape(int w, int h) { }
     }
     
-    static class GLCarbonPixelBuffer extends OpenGL.GLDoubleBuffer {
+    static class GLCarbonPixelBuffer extends OpenGL.GLPixelBuffer {
         RawData rawCTX;
         RawData rawWindowRef;
         int textureName;
@@ -267,7 +264,7 @@ public class Darwin extends POSIX {
         public native void natDispose();
     }
 
-    /*private class QZCarbonPixelBuffer extends DoubleBuffer {
+    /*private class QZCarbonPixelBuffer extends PixelBuffer {
         
         public QZCarbonPixelBuffer(int width, int height) {
         }
@@ -292,7 +289,7 @@ public class Darwin extends POSIX {
         }
     }*/
     
-    protected PixelBuffer _createDoubleBuffer(int w, int h, Surface owner) {
+    protected PixelBuffer _createPixelBuffer(int w, int h, Surface owner) {
         if(openGL != null)
             return new GLCarbonPixelBuffer(w,h,openGL);
         else