On Fri, 19 Aug 2022 23:47:49 GMT, Harshitha Onkar <hon...@openjdk.org> wrote:

> On Windows, the insets obtained for a Non-Resizable AWT Frame was different 
> when frame.pack() was called and subsequent call to frame.getInsets() or 
> frame.getPreferredSize(). Due to this, the actual and preferred size differed 
> when frame.pack() was called for Non-Resizable frame (on Windows).  
> 
> Earlier the insets returned when frame.getInsets() was called, was that of a 
> Resizable frame and not the correct insets associated with Non-Resizable 
> frame. Fix is added to native code to get the correct insets. The test - 
> AwtFramePackTest.java has been updated to test actual and expected/preferred 
> size for both Resizable and Non-Resizable Frames.
> 
> The test is generic though the issue and fix is on Windows platform because 
> the condition 
> `frame.getSize() == frame.getPreferredSize()` should be true all platforms 
> when frame.pack() is called.

src/java.desktop/windows/native/libawt/windows/awt_Window.cpp line 1413:

> 1411:     if (m_insets.left < 0 || m_insets.top < 0 ||
> 1412:         m_insets.right < 0 || m_insets.bottom < 0 ||
> 1413:         JNU_IsInstanceOfByName(env, target, "java/awt/Frame") > 0) {

Does it mean that now we will always request the insets from the platform?

Was this code run before the frame was changed from resizeable to 
non-resizeable? Therefore the insets weren't updated correctly.

Is this applicable to windows?

test/jdk/java/awt/Frame/AwtFramePackTest.java line 101:

> 99:                 System.out.println("Actual frame size: " + 
> actualFrameSize);
> 100:                 saveScreenCapture(frameType + ".png");
> 101:                 errorLog.append(frameType + ": Expected and Actual frame 
> size" +

`frameType` is used only inside this failure block, so it's declaration can be 
moved here before it's used for the first time.

-------------

PR: https://git.openjdk.org/jdk/pull/9954

Reply via email to