From 1f0a62306ca964e73c4f7b83afd94ad9b9e37f53 Mon Sep 17 00:00:00 2001 From: serb Date: Wed, 21 Nov 2012 15:54:41 +0400 Subject: [PATCH] 7193214: Consider simplifying CPlatformWindow.setResizable() Reviewed-by: anthony, denis --- .../classes/sun/lwawt/macosx/CPlatformWindow.java | 14 +++----------- src/macosx/native/sun/awt/AWTWindow.m | 6 +++++- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index 63ff829a8..919f499ea 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -257,7 +257,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor validateSurface(); } - protected int getInitialStyleBits() { + private int getInitialStyleBits() { // defaults style bits int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE; @@ -284,7 +284,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false); styleBits = SET(styleBits, RESIZABLE, resizable); if (!resizable) { - styleBits = SET(styleBits, RESIZABLE, false); styleBits = SET(styleBits, ZOOMABLE, false); } } @@ -379,7 +378,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor } // this is the counter-point to -[CWindow _nativeSetStyleBit:] - protected void setStyleBits(final int mask, final boolean value) { + private void setStyleBits(final int mask, final boolean value) { nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0); } @@ -656,15 +655,8 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor } @Override - public void setResizable(boolean resizable) { + public void setResizable(final boolean resizable) { setStyleBits(RESIZABLE, resizable); - - // Re-apply the size constraints and the size to ensure the space - // occupied by the grow box is counted properly - peer.updateMinimumSize(); - - Rectangle bounds = peer.getBounds(); - setBounds(bounds.x, bounds.y, bounds.width, bounds.height); } @Override diff --git a/src/macosx/native/sun/awt/AWTWindow.m b/src/macosx/native/sun/awt/AWTWindow.m index 3e25a6cb6..7adbd360b 100644 --- a/src/macosx/native/sun/awt/AWTWindow.m +++ b/src/macosx/native/sun/awt/AWTWindow.m @@ -160,6 +160,10 @@ AWT_NS_WINDOW_IMPLEMENTATION BOOL resizable = IS(bits, RESIZABLE); [self updateMinMaxSize:resizable]; [self.nsWindow setShowsResizeIndicator:resizable]; + // Zoom button should be disabled, if the window is not resizable, + // otherwise button should be restored to initial state. + BOOL zoom = resizable && IS(bits, ZOOMABLE); + [[self.nsWindow standardWindowButton:NSWindowZoomButton] setEnabled:zoom]; } if (IS(mask, HAS_SHADOW)) { @@ -784,7 +788,7 @@ AWT_ASSERT_NOT_APPKIT_THREAD; // calls methods on NSWindow to change other properties, based on the mask if (mask & MASK(_METHOD_PROP_BITMASK)) { - [window setPropertiesForStyleBits:bits mask:mask]; + [window setPropertiesForStyleBits:newBits mask:mask]; } window.styleBits = newBits; -- GitLab