--- a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java Wed Apr 24 21:15:54 2013 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java Sun Apr 28 09:35:25 2013 +0100
@@ -616,17 +616,16 @@
setBounds(x, y, w, h, SET_BOUNDS, false, false);
// Second, update the graphics config and surface data
- checkIfOnNewScreen();
- if (resized) {
+ final boolean isNewDevice = updateGraphicsDevice();
+ if (resized || isNewDevice) {
replaceSurfaceData();
- flushOnscreenGraphics();
}
// Third, COMPONENT_MOVED/COMPONENT_RESIZED/PAINT events
if (moved || invalid) {
handleMove(x, y, true);
}
- if (resized || invalid) {
+ if (resized || invalid || isNewDevice) {
handleResize(w, h, true);
repaintPeer();
}
@@ -648,7 +647,7 @@
}
if (!isTextured()) {
if (g instanceof SunGraphics2D) {
- SG2DConstraint((SunGraphics2D) g, getRegion());
+ ((SunGraphics2D) g).constrain(0, 0, w, h, getRegion());
}
g.setColor(getBackground());
g.fillRect(0, 0, w, h);
@@ -985,7 +984,7 @@
}
// If window's graphics config is changed from the app code, the
// config correspond to the same device as before; when the window
- // is moved by user, graphicsDevice is updated in checkIfOnNewScreen().
+ // is moved by user, graphicsDevice is updated in notifyReshape().
// In either case, there's nothing to do with screenOn here
graphicsConfig = gc;
}
@@ -993,11 +992,14 @@
return true;
}
- private void checkIfOnNewScreen() {
+ /**
+ * Returns true if the GraphicsDevice has been changed, false otherwise.
+ */
+ public boolean updateGraphicsDevice() {
GraphicsDevice newGraphicsDevice = platformWindow.getGraphicsDevice();
synchronized (getStateLock()) {
if (graphicsDevice == newGraphicsDevice) {
- return;
+ return false;
}
graphicsDevice = newGraphicsDevice;
}
@@ -1005,13 +1007,14 @@
// TODO: DisplayChangedListener stuff
final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration();
- if (!setGraphicsConfig(newGC)) return;
+ if (!setGraphicsConfig(newGC)) return false;
SunToolkit.executeOnEventHandlerThread(getTarget(), new Runnable() {
public void run() {
AWTAccessor.getComponentAccessor().setGraphicsConfiguration(getTarget(), newGC);
}
});
+ return true;
}
/*
@@ -1046,6 +1049,7 @@
oldData.flush();
}
}
+ flushOnscreenGraphics();
}
private void blitSurfaceData(final SurfaceData src, final SurfaceData dst) {
@@ -1053,14 +1057,15 @@
if (src != dst && src != null && dst != null
&& !(dst instanceof NullSurfaceData)
&& !(src instanceof NullSurfaceData)
- && src.getSurfaceType().equals(dst.getSurfaceType())) {
- final Rectangle size = getSize();
+ && src.getSurfaceType().equals(dst.getSurfaceType())
+ && src.getDefaultScale() == dst.getDefaultScale()) {
+ final Rectangle size = src.getBounds();
final Blit blit = Blit.locate(src.getSurfaceType(),
CompositeType.Src,
dst.getSurfaceType());
if (blit != null) {
- blit.Blit(src, dst, AlphaComposite.Src,
- getRegion(), 0, 0, 0, 0, size.width, size.height);
+ blit.Blit(src, dst, AlphaComposite.Src, null, 0, 0, 0, 0,
+ size.width, size.height);
}
}
}
@@ -1215,7 +1220,9 @@
if (!becomesFocused &&
(isGrabbing() || getOwnerFrameDialog(grabbingWindow) == this))
{
- focusLog.fine("ungrabbing on " + grabbingWindow);
+ if (focusLog.isLoggable(PlatformLogger.FINE)) {
+ focusLog.fine("ungrabbing on " + grabbingWindow);
+ }
// ungrab a simple window if its owner looses activation.
grabbingWindow.ungrab();
}