src/macosx/classes/sun/lwawt/LWWindowPeer.java

Print this page

        

*** 39,49 **** import sun.java2d.pipe.Region; import sun.util.logging.PlatformLogger; public class LWWindowPeer extends LWContainerPeer<Window, JComponent> ! implements WindowPeer, FramePeer, DialogPeer, FullScreenCapable { public static enum PeerType { SIMPLEWINDOW, FRAME, DIALOG, --- 39,49 ---- import sun.java2d.pipe.Region; import sun.util.logging.PlatformLogger; public class LWWindowPeer extends LWContainerPeer<Window, JComponent> ! implements FramePeer, DialogPeer, FullScreenCapable, DisplayChangedListener { public static enum PeerType { SIMPLEWINDOW, FRAME, DIALOG,
*** 187,196 **** --- 187,197 ---- updateInsets(platformWindow.getInsets()); if (getSurfaceData() == null) { replaceSurfaceData(false); } + activateDisplayListener(); } // Just a helper method public PlatformWindow getPlatformWindow() { return platformWindow;
*** 208,217 **** --- 209,219 ---- // ---- PEER METHODS ---- // @Override protected void disposeImpl() { + deactivateDisplayListener(); SurfaceData oldData = getSurfaceData(); synchronized (surfaceDataLock){ surfaceData = null; } if (oldData != null) {
*** 878,887 **** --- 880,901 ---- } // ---- 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( (Frame)getTarget(), newWindowState); }
*** 939,949 **** return false; } graphicsDevice = newGraphicsDevice; } - // TODO: DisplayChangedListener stuff final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration(); if (!setGraphicsConfig(newGC)) return false; SunToolkit.executeOnEventHandlerThread(getTarget(), new Runnable() { --- 953,962 ----
*** 952,961 **** --- 965,988 ---- } }); 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. */ public SurfaceData getSurfaceData() { synchronized (surfaceDataLock) {