X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FSurface.java;h=5e517c834d0f0653676a1eabbcce6c297e275049;hb=7e9239a7088d4cd772a31a76e1a53e1c681638bc;hp=eca0dee05bd586cef2d6b24a56b7ca9379147e60;hpb=97daadb9ac5a453889da76c8c4c72f8f6badcba2;p=org.ibex.core.git diff --git a/src/org/xwt/Surface.java b/src/org/xwt/Surface.java index eca0dee..5e517c8 100644 --- a/src/org/xwt/Surface.java +++ b/src/org/xwt/Surface.java @@ -1,4 +1,4 @@ -// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] package org.xwt; import org.bouncycastle.util.encoders.Base64; @@ -29,7 +29,11 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { public static Vec allSurfaces = new Vec(); /** When set to true, render() should abort as soon as possible and restart the rendering process */ - static volatile boolean abort = false; + volatile boolean abort = false; + volatile int pendingWidth = -1; + volatile int pendingHeight = -1; + volatile int actualWidth = -1; + volatile int actualHeight = -1; public static boolean alt = false; ///< true iff the alt button is pressed down, in real time public static boolean control = false; ///< true iff the control button is pressed down, in real time @@ -77,6 +81,12 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { public abstract void _dispose(); ///< Destroy the surface public void setLimits(int min_width, int min_height, int max_width, int max_height) { /* FIXME */ } + protected void setSize(int w, int h) { + if (w == actualWidth && h == actualHeight) return; + actualWidth = w; + actualHeight = h; + _setSize(w, h); + } // Helper methods for subclasses //////////////////////////////////////////////////////////// @@ -140,8 +150,8 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { try { root.putAndTriggerTraps("_Move", T); } catch (JSExn e) { - Log.log(Surface.class, "Exception thrown from Move message handler"); - Log.logJS(e); + Log.info(Surface.class, "Exception thrown from Move message handler"); + JS.log(e); } if (!cursor.equals(oldcursor)) syncCursor(); } @@ -158,22 +168,13 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { Scheduler.add(this); } - private Scheduler.Task nextSizeChange = null; - // FEATURE: can we avoid creating objects here? /** subclasses should invoke this method when the user resizes the window */ protected final void SizeChange(final int width, final int height) { - if (root.maxwidth == width && root.maxheight == height) return; - nextSizeChange = new Scheduler.Task() { public void perform() { - if (nextSizeChange != this) return; - // dirty the place where the scar used to be - root.dirty(0, root.maxheight - Main.scarImage.height, Main.scarImage.width, Main.scarImage.height); - root.setMaxWidth(JS.N(width)); - root.setMaxHeight(JS.N(height)); - nextSizeChange = null; - Refresh(); - }}; - Scheduler.addAtFront(nextSizeChange); + if (pendingWidth == width && pendingHeight == height) return; + actualWidth = pendingWidth = width; + actualHeight = pendingHeight = height; abort = true; + Scheduler.renderAll(); } // FEATURE: can we avoid creating objects here? @@ -193,19 +194,7 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { protected final void Minimized(boolean b) { minimized = b; new SimpleMessage("Minimized", b ? T : F, root); } protected final void Maximized(boolean b) { maximized = b; new SimpleMessage("Maximized", b ? T : F, root); } protected final void Focused(boolean b) { new SimpleMessage("Focused", b ? T : F, root); } - public static void Refresh() { needRender = true; Scheduler.add(new Scheduler.Task() { public void perform() { } }); } - - public static boolean needRender = false; - public static final Scheduler.Task renderAll = new Scheduler.Task() { - public void perform() { - for(int i=0; i