ugly hacks to accomodate Apple's buggy AWT implementation
authoradam <adam@megacz.com>
Tue, 18 Jan 2005 04:38:25 +0000 (04:38 +0000)
committeradam <adam@megacz.com>
Tue, 18 Jan 2005 04:38:25 +0000 (04:38 +0000)
darcs-hash:20050118043825-5007d-ed4edc3aa524ca83c0e4ca58d99a46e099b5c945.gz

src/org/ibex/core/Box.java
src/org/ibex/core/Main.java
src/org/ibex/graphics/Surface.java
src/org/ibex/plat/AWT.java
src/org/ibex/plat/Java2.java
src/org/ibex/plat/Java4.java

index 5133251..8696839 100644 (file)
@@ -445,7 +445,6 @@ public final class Box extends JS.Obj implements Callable {
     
     
     // Methods to implement org.ibex.js.JS //////////////////////////////////////
     
     
     // Methods to implement org.ibex.js.JS //////////////////////////////////////
-
   
     public JS call(JS method, JS[] args) throws JSExn {
         switch (args.length) {
   
     public JS call(JS method, JS[] args) throws JSExn {
         switch (args.length) {
index 4fd76f0..39e23d2 100644 (file)
@@ -15,6 +15,17 @@ import org.ibex.graphics.*;
 /** Entry point for the Ibex Engine; handles splash screen, initial xwar loading, and argument processing */
 public class Main {
 
 /** Entry point for the Ibex Engine; handles splash screen, initial xwar loading, and argument processing */
 public class Main {
 
+    // ugly hack: we have to set these properties before AWT loads
+    static {
+        System.setProperty("apple.awt.showGrowBox", "false");
+        System.setProperty("apple.awt.graphics.EnableLazyDrawing", "40");
+        System.setProperty("apple.awt.graphics.EnableLazyDrawing", "true");
+        System.setProperty("apple.awt.window.position.forceSafeUserPositioning", "true");
+        System.setProperty("apple.awt.window.position.forceSafeCreation", "true");
+        System.setProperty("com.apple.hwaccel", "true");
+        System.setProperty("com.apple.forcehwaccel", "true");
+    }
+
     /**
      *  FEATURE: this should be implemented using self-emulation
      *  Used for security checks. If this is null, it means that only
     /**
      *  FEATURE: this should be implemented using self-emulation
      *  Used for security checks. If this is null, it means that only
index 0f29914..ebf4670 100644 (file)
@@ -173,7 +173,7 @@ public abstract class Surface implements Callable {
         pendingHeight = height;
         syncRootBoxToSurface = true;
         abort = true;
         pendingHeight = height;
         syncRootBoxToSurface = true;
         abort = true;
-        Platform.Scheduler.renderAll();
+        Refresh();
     }
 
     // FEATURE: can we avoid creating objects here?
     }
 
     // FEATURE: can we avoid creating objects here?
@@ -412,8 +412,9 @@ public abstract class Surface implements Callable {
 
         // This is how subclasses signal a 'shallow dirty', indicating that although the backbuffer is valid, the screen is not
         public final void Dirty(int x, int y, int w, int h) {
 
         // This is how subclasses signal a 'shallow dirty', indicating that although the backbuffer is valid, the screen is not
         public final void Dirty(int x, int y, int w, int h) {
-            screenDirtyRegions.dirty(x, y, w, h);
-            Platform.Scheduler.renderAll();
+            //screenDirtyRegions.dirty(x, y, w, h);
+            //Refresh();
+            blit(x,y,w,h);
         }
 
         public void dirty(int x, int y, int w, int h) {
         }
 
         public void dirty(int x, int y, int w, int h) {
index d937588..f3f53d2 100644 (file)
@@ -302,7 +302,8 @@ public class AWT extends JVM {
         public void setIcon(Picture i) { if (frame != null) frame.setIconImage(((AWTPicture)i).i); }
         public void _setSize(int width, int height) {
             g = null;
         public void setIcon(Picture i) { if (frame != null) frame.setIconImage(((AWTPicture)i).i); }
         public void _setSize(int width, int height) {
             g = null;
-            window.setSize(width + (insets.left + insets.right), height + (insets.top + insets.bottom)); }
+            //window.setSize(width + (insets.left + insets.right), height + (insets.top + insets.bottom));
+        }
         public void setInvisible(boolean b) { window.setVisible(!b); }
         protected void _setMinimized(boolean b) { if (Log.on) Log.info(this, "JDK 1.1 platforms cannot minimize or unminimize windows"); }
         protected void _setMaximized(boolean b) {
         public void setInvisible(boolean b) { window.setVisible(!b); }
         protected void _setMinimized(boolean b) { if (Log.on) Log.info(this, "JDK 1.1 platforms cannot minimize or unminimize windows"); }
         protected void _setMaximized(boolean b) {
@@ -318,22 +319,29 @@ public class AWT extends JVM {
         class InnerFrame extends Frame {
             public InnerFrame() throws java.lang.UnsupportedOperationException { }
             public Dimension getMinimumSize() { return new Dimension(root.minwidth(), root.minheight()); }
         class InnerFrame extends Frame {
             public InnerFrame() throws java.lang.UnsupportedOperationException { }
             public Dimension getMinimumSize() { return new Dimension(root.minwidth(), root.minheight()); }
-            public void update(Graphics gr) { paint(gr); }
+            public void update(Graphics gr) {
+                Rectangle r = gr.getClipBounds();
+                super.update(gr);
+                dirtify(r);
+            }
             public void paint(Graphics gr) {
                 // Mac OS X Jdk1.4 Bug: after a componentResized(), you must wait for the paint() before you redraw
                 Rectangle r = gr.getClipBounds();
             public void paint(Graphics gr) {
                 // Mac OS X Jdk1.4 Bug: after a componentResized(), you must wait for the paint() before you redraw
                 Rectangle r = gr.getClipBounds();
-
+                super.paint(gr);
+                dirtify(r);
+            }
+            private void dirtify(java.awt.Rectangle r) {
+                if (r != null) {
+                    Dirty(r.x - insets.left, r.y - insets.top, r.width, r.height);
+                } else {
+                    Dirty(0, 0,
+                          Math.max(getWidth() - insets.left - insets.right, root.width),
+                          Math.min(getHeight() - insets.top - insets.bottom, root.height));
+                }
                 // ugly hack for Java1.4 dynamicLayout on Win32 -- this catches expansions during smooth resize
                 // ugly hack for Java1.4 dynamicLayout on Win32 -- this catches expansions during smooth resize
-                int newwidth = Math.max(r.x - insets.left + r.width, root.width);
-                int newheight = Math.max(r.y - insets.top + r.height, root.height);
-                if (newwidth > root.width || newheight > root.height)
-                    componentResized(window.getWidth() - insets.left - insets.right,
-                                     window.getHeight() - insets.top - insets.bottom);
-
-                //Dirty(r.x - insets.left, r.y - insets.top, r.width, r.height);
-                g = gr;
-                blit(r.x - insets.left, r.y - insets.top, r.width, r.height);
-                g.setClip(0, 0, getWidth(), getHeight());
+                int newwidth = Math.max(getWidth() - insets.left - insets.right, root.width);
+                int newheight = Math.max(getHeight() - insets.top - insets.bottom, root.height);
+                if (newwidth != root.width || newheight != root.height) componentResized(newwidth, newheight);
             }
         }
 
             }
         }
 
@@ -448,6 +456,7 @@ public class AWT extends JVM {
             SizeChange(newwidth, newheight);
             //if (newwidth > root.width) Dirty(root.width, 0, newwidth-root.width, newheight);
             //if (newheight > root.height) Dirty(0, root.height, newwidth, newheight-root.height);
             SizeChange(newwidth, newheight);
             //if (newwidth > root.width) Dirty(root.width, 0, newwidth-root.width, newheight);
             //if (newheight > root.height) Dirty(0, root.height, newwidth, newheight-root.height);
+            Refresh();
         }
 
         public void keyTyped(KeyEvent k) { }
         }
 
         public void keyTyped(KeyEvent k) { }
index fd6b216..b91eeba 100644 (file)
@@ -21,13 +21,6 @@ public class Java2 extends AWT {
 
     protected String getDescriptiveName() { return "Java 1.2+ JVM"; }
     public Java2() {
 
     protected String getDescriptiveName() { return "Java 1.2+ JVM"; }
     public Java2() {
-        // Properties for Apple JDK 1.3
-        System.setProperty("apple.awt.showGrowBox", "false");
-        System.setProperty("com.apple.hwaccel", "true");
-        System.setProperty("com.apple.forcehwaccel", "true");
-        System.setProperty("apple.awt.window.position.forceSafeUserPositioning", "true");
-        System.setProperty("apple.awt.window.position.forceSafeCreation", "true");
-
         // disable the focus manager so we can intercept the tab key
         javax.swing.FocusManager.setCurrentManager(new javax.swing.FocusManager() {
                 public void processKeyEvent(Component focusedComponent, KeyEvent anEvent) { }
         // disable the focus manager so we can intercept the tab key
         javax.swing.FocusManager.setCurrentManager(new javax.swing.FocusManager() {
                 public void processKeyEvent(Component focusedComponent, KeyEvent anEvent) { }
index 8b8dcd7..65833e2 100644 (file)
@@ -18,14 +18,6 @@ public class Java4 extends Java2 {
     protected String getDescriptiveName() { return "Java 1.4+ JVM"; }
     public Java4() {
         java.awt.Toolkit.getDefaultToolkit().setDynamicLayout(true);
     protected String getDescriptiveName() { return "Java 1.4+ JVM"; }
     public Java4() {
         java.awt.Toolkit.getDefaultToolkit().setDynamicLayout(true);
-        /*
-        // Properties for Apple JDK 1.4
-        System.setProperty("apple.awt.showGrowBox", "false");
-        System.setProperty("apple.awt.graphics.EnableLazyDrawing", "40");
-        System.setProperty("apple.awt.graphics.EnableLazyDrawing", "true");
-        System.setProperty("apple.awt.window.position.forceSafeUserPositioning", "true");
-        System.setProperty("apple.awt.window.position.forceSafeCreation", "true");
-        */
     }
     protected Surface __createSurface(final Box root, final boolean framed) { return new Java4Surface(root, framed); }
     public static class Java4Surface extends Java2Surface implements WindowStateListener, MouseWheelListener {
     }
     protected Surface __createSurface(final Box root, final boolean framed) { return new Java4Surface(root, framed); }
     public static class Java4Surface extends Java2Surface implements WindowStateListener, MouseWheelListener {