diff -Nru gcc-4.0.2.orig/libjava/java/awt/Window.java gcc-4.0.2/libjava/java/awt/Window.java --- gcc-4.0.2.orig/libjava/java/awt/Window.java 2005-10-25 12:54:05.000000000 +0200 +++ gcc-4.0.2/libjava/java/awt/Window.java 2005-10-25 16:19:42.000000000 +0200 @@ -15,8 +15,8 @@ You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and @@ -45,6 +45,7 @@ import java.awt.event.WindowFocusListener; import java.awt.event.WindowListener; import java.awt.event.WindowStateListener; +import java.awt.image.BufferStrategy; import java.awt.peer.WindowPeer; import java.lang.ref.Reference; import java.lang.ref.WeakReference; @@ -90,7 +91,8 @@ private transient boolean shown; - private transient Component windowFocusOwner; + // This is package-private to avoid an accessor method. + transient Component windowFocusOwner; /* * The number used to generate the name returned by getName. @@ -153,6 +155,9 @@ } } }); + + GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment(); + graphicsConfiguration = g.getDefaultScreenDevice().getDefaultConfiguration(); } Window(GraphicsConfiguration gc) @@ -617,6 +622,8 @@ || windowStateListener != null || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0)) processEvent(e); + else if (e.id == ComponentEvent.COMPONENT_RESIZED) + validate (); else super.dispatchEventImpl(e); } @@ -739,7 +746,25 @@ if (activeWindow == this) return manager.getFocusOwner (); else - return windowFocusOwner; + return null; + } + + /** + * Returns the child component of this window that would receive + * focus if this window were to become focused. If the window + * already has the top-level focus, then this method returns the + * same component as getFocusOwner. If no child component has + * requested focus within the window, then the initial focus owner + * is returned. If this is a non-focusable window, this method + * returns null. + * + * @return the child component of this window that most recently had + * the focus, or null + * @since 1.4 + */ + public Component getMostRecentFocusOwner () + { + return windowFocusOwner; } /** @@ -771,12 +796,16 @@ /** * Tests whether or not this window is visible on the screen. * + * In contrast to the normal behaviour of Container, which is that + * a container is showing if its parent is visible and showing, a Window + * is even showing, if its parent (i.e. an invisible Frame) is not showing. + * * @return true if this window is visible, false * otherwise. */ public boolean isShowing() { - return super.isShowing(); + return isVisible(); } public void setLocationRelativeTo (Component c) @@ -796,6 +825,157 @@ } /** + * A BltBufferStrategy for windows. + */ + private class WindowBltBufferStrategy extends BltBufferStrategy + { + /** + * Creates a block transfer strategy for this window. + * + * @param numBuffers the number of buffers in this strategy + * @param accelerated true if the buffer should be accelerated, + * false otherwise + */ + WindowBltBufferStrategy(int numBuffers, boolean accelerated) + { + super(numBuffers, + new BufferCapabilities(new ImageCapabilities(accelerated), + new ImageCapabilities(accelerated), + BufferCapabilities.FlipContents.COPIED)); + } + } + + /** + * A FlipBufferStrategy for windows. + */ + private class WindowFlipBufferStrategy extends FlipBufferStrategy + { + /** + * Creates a flip buffer strategy for this window. + * + * @param numBuffers the number of buffers in this strategy + * + * @throws AWTException if the requested number of buffers is not + * supported + */ + WindowFlipBufferStrategy(int numBuffers) + throws AWTException + { + super(numBuffers, + new BufferCapabilities(new ImageCapabilities(true), + new ImageCapabilities(true), + BufferCapabilities.FlipContents.COPIED)); + } + } + + /** + * Creates a buffering strategy that manages how this window is + * repainted. This method attempts to create the optimum strategy + * based on the desired number of buffers. Hardware or software + * acceleration may be used. + * + * createBufferStrategy attempts different levels of optimization, + * but guarantees that some strategy with the requested number of + * buffers will be created even if it is not optimal. First it + * attempts to create a page flipping strategy, then an accelerated + * blitting strategy, then an unaccelerated blitting strategy. + * + * Calling this method causes any existing buffer strategy to be + * destroyed. + * + * @param numBuffers the number of buffers in this strategy + * + * @throws IllegalArgumentException if requested number of buffers + * is less than one + * @throws IllegalStateException if this window is not displayable + * + * @since 1.4 + */ + public void createBufferStrategy(int numBuffers) + { + if (numBuffers < 1) + throw new IllegalArgumentException("Window.createBufferStrategy: number" + + " of buffers is less than one"); + + if (!isDisplayable()) + throw new IllegalStateException("Window.createBufferStrategy: window is" + + " not displayable"); + + BufferStrategy newStrategy = null; + + // try a flipping strategy + try + { + newStrategy = new WindowFlipBufferStrategy(numBuffers); + } + catch (AWTException e) + { + } + + // fall back to an accelerated blitting strategy + if (newStrategy == null) + newStrategy = new WindowBltBufferStrategy(numBuffers, true); + + bufferStrategy = newStrategy; + } + + /** + * Creates a buffering strategy that manages how this window is + * repainted. This method attempts to create a strategy based on + * the specified capabilities and throws an exception if the + * requested strategy is not supported. + * + * Calling this method causes any existing buffer strategy to be + * destroyed. + * + * @param numBuffers the number of buffers in this strategy + * @param caps the requested buffering capabilities + * + * @throws AWTException if the requested capabilities are not + * supported + * @throws IllegalArgumentException if requested number of buffers + * is less than one or if caps is null + * + * @since 1.4 + */ + public void createBufferStrategy(int numBuffers, + BufferCapabilities caps) + { + if (numBuffers < 1) + throw new IllegalArgumentException("Window.createBufferStrategy: number" + + " of buffers is less than one"); + + if (caps == null) + throw new IllegalArgumentException("Window.createBufferStrategy:" + + " capabilities object is null"); + + // a flipping strategy was requested + if (caps.isPageFlipping()) + { + try + { + bufferStrategy = new WindowFlipBufferStrategy(numBuffers); + } + catch (AWTException e) + { + } + } + else + bufferStrategy = new WindowBltBufferStrategy(numBuffers, true); + } + + /** + * Returns the buffer strategy used by the window. + * + * @return the buffer strategy. + * @since 1.4 + */ + public BufferStrategy getBufferStrategy() + { + return bufferStrategy; + } + + /** * @since 1.2 * * @deprecated @@ -913,44 +1093,6 @@ this.focusableWindowState = focusableWindowState; } - // setBoundsCallback is needed so that when a user moves a window, - // the Window's location can be updated without calling the peer's - // setBounds method. When a user moves a window the peer window's - // location is updated automatically and the windowing system sends - // a message back to the application informing it of its updated - // dimensions. We must update the AWT Window class with these new - // dimensions. But we don't want to call the peer's setBounds - // method, because the peer's dimensions have already been updated. - // (Under X, having this method prevents Configure event loops when - // moving windows: Component.setBounds -> peer.setBounds -> - // postConfigureEvent -> Component.setBounds -> ... In some cases - // Configure event loops cause windows to jitter back and forth - // continuously). - void setBoundsCallback (int x, int y, int w, int h) - { - if (this.x == x && this.y == y && width == w && height == h) - return; - invalidate(); - boolean resized = width != w || height != h; - boolean moved = this.x != x || this.y != y; - this.x = x; - this.y = y; - width = w; - height = h; - if (resized && isShowing ()) - { - ComponentEvent ce = - new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED); - getToolkit().getSystemEventQueue().postEvent(ce); - } - if (moved && isShowing ()) - { - ComponentEvent ce = - new ComponentEvent(this, ComponentEvent.COMPONENT_MOVED); - getToolkit().getSystemEventQueue().postEvent(ce); - } - } - /** * Generate a unique name for this window. *