2002/05/16 04:24:03
[org.ibex.core.git] / src / org / xwt / Surface.java
index 4cc5f59..d8b944d 100644 (file)
@@ -132,6 +132,9 @@ public abstract class Surface {
     /** Destroy the surface */
     public abstract void _dispose();
 
+    /** Notifies the surface that limits have been imposed on the surface's size */
+    public void setLimits(int min_width, int min_height, int max_width, int max_height) { }
+
 
     // Helper methods for subclasses ////////////////////////////////////////////////////////////
 
@@ -185,7 +188,7 @@ public abstract class Surface {
     /** sends a KeyPressed message; subclasses should not add the C- or A- prefixes, nor should they capitalize alphabet characters */
     protected final void KeyPressed(String key) {
         if (key == null) return;
-        
+
         if (key.equals("alt")) alt = true;
         else if (alt) key = "A-" + key;
 
@@ -205,8 +208,12 @@ public abstract class Surface {
         public KMessage(String k) { key = k; }
         public void perform() {
             if (key.equals("C-v") || key.equals("A-v")) Platform.clipboardReadEnabled = true;
-            for(int i=0; i<keywatchers.size(); i++)
-                ((Box)keywatchers.elementAt(i)).put("KeyPressed", null, key);
+            outer: for(int i=0; i<keywatchers.size(); i++) {
+                Box b = (Box)keywatchers.elementAt(i);
+                for(Box cur = b; cur != null; cur = cur.getParent())
+                    if (cur.invisible) continue outer;
+                b.put("KeyPressed", null, key);
+            }
             Platform.clipboardReadEnabled = false;
         }
     }
@@ -218,8 +225,12 @@ public abstract class Surface {
         else if (key.equals("control")) control = false;
         else if (key.equals("shift")) shift = false;
         MessageQueue.add(new Message() { public void perform() {
-            for(int i=0; i<keywatchers.size(); i++)
-                ((Box)keywatchers.elementAt(i)).put("KeyReleased", null, key);
+            outer: for(int i=0; i<keywatchers.size(); i++) {
+                Box b = (Box)keywatchers.elementAt(i);
+                for(Box cur = b; cur != null; cur = cur.getParent())
+                    if (cur.invisible) continue outer;
+                b.put("KeyReleased", null, key);
+            }
         }});
     }
 
@@ -258,7 +269,9 @@ public abstract class Surface {
         this.width = width;
         this.height = height;
         abort = true;
-        lastResizeTime = System.currentTimeMillis();
+        long lastResizeTime = System.currentTimeMillis();
+        lastResizeTimeTop = (int)(lastResizeTime >> 32);
+        lastResizeTimeBottom = (int)(lastResizeTime & 0xffffffff);
         Refresh();
     }
 
@@ -274,14 +287,18 @@ public abstract class Surface {
     protected final void Focused(boolean b) { new SimpleMessage("Focused", b ? Boolean.TRUE : Boolean.FALSE, null); }
     public static void Refresh() { MessageQueue.refresh(); }
 
+    // the following value is split into two int's to work around GCJ bug java/6393
+
     /** used in conjunction with Platform.supressDirtyOnResize() */
-    private long lastResizeTime = 0;
+    private int lastResizeTimeTop = 0;
+    private int lastResizeTimeBottom = 0;
 
     /** 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) {
+        long lastResizeTime = (((long)lastResizeTimeTop) << 32) | (long)lastResizeTimeBottom;
         if (Platform.supressDirtyOnResize() && System.currentTimeMillis() - lastResizeTime < 100 && (w >= width - 1 || h >= height - 1)) return;
         screenDirtyRegions.dirty(x, y, w, h);
-        blitDirtyScreenRegions();
+        Refresh();
     }
 
 
@@ -299,12 +316,6 @@ public abstract class Surface {
     /** A list of all the Boxes on this Surface that should be notified of keyboard events */
     Vec keywatchers = new Vec();
 
-    /**
-     *  this is incremented every time we render; it acts as a sort of 'timestamp' to let Boxes to know if they have
-     *  been dirtied since the last rendering began (and hence should not propagate up dirty() requests from their children)
-     */
-    volatile int dirtiedTimeStamp = 0;
-
     /** When set to true, render() should abort as soon as possible and restart the rendering process */
     volatile boolean abort = false;
 
@@ -388,8 +399,6 @@ public abstract class Surface {
     /** runs the prerender() and render() pipelines in the root Box to regenerate the backbuffer, then blits it to the screen */
     public synchronized void render() {
 
-        if (++dirtiedTimeStamp == Integer.MAX_VALUE - 1) dirtiedTimeStamp = 0;
-
         // if the window size changed as a result of a user action, we have to update the root box's size
         if (root.size(0) != width || root.size(1) != height) {