diff -r 108d0c7b60f9 -r aec7e8963c3e jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java --- a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java Wed May 01 12:25:43 2013 +0100 +++ b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java Wed May 08 11:22:25 2013 +0100 @@ -41,7 +41,8 @@ public class LWWindowPeer extends LWContainerPeer - implements WindowPeer, FramePeer, DialogPeer, FullScreenCapable, PlatformEventNotifier { + implements FramePeer, DialogPeer, FullScreenCapable, DisplayChangedListener, PlatformEventNotifier +{ public static enum PeerType { SIMPLEWINDOW, FRAME, @@ -205,6 +206,7 @@ if (getSurfaceData() == null) { replaceSurfaceData(false); } + activateDisplayListener(); } // Just a helper method @@ -217,15 +219,11 @@ return this; } - @Override - protected void initializeContainerPeer() { - // No-op as LWWindowPeer doesn't have any containerPeer - } - // ---- PEER METHODS ---- // @Override protected void disposeImpl() { + deactivateDisplayListener(); SurfaceData oldData = getSurfaceData(); synchronized (surfaceDataLock){ surfaceData = null; @@ -940,6 +938,18 @@ // ---- UTILITY METHODS ---- // + private void activateDisplayListener() { + final GraphicsEnvironment ge = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + ((SunGraphicsEnvironment) ge).addDisplayChangedListener(this); + } + + private void deactivateDisplayListener() { + final GraphicsEnvironment ge = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + ((SunGraphicsEnvironment) ge).removeDisplayChangedListener(this); + } + private void postWindowStateChangedEvent(int newWindowState) { if (getTarget() instanceof Frame) { AWTAccessor.getFrameAccessor().setExtendedState( @@ -1004,7 +1014,6 @@ graphicsDevice = newGraphicsDevice; } - // TODO: DisplayChangedListener stuff final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration(); if (!setGraphicsConfig(newGC)) return false; @@ -1017,6 +1026,20 @@ return true; } + @Override + public final void displayChanged() { + updateGraphicsDevice(); + // Replace surface unconditionally, because internal state of the + // GraphicsDevice could be changed. + replaceSurfaceData(); + repaintPeer(); + } + + @Override + public final void paletteChanged() { + // components do not need to react to this event. + } + /* * May be called by delegate to provide SD to Java2D code. */