RFR: 8288325: [windows] Actual and Preferred Size of AWT Non-resizable frame are different

Alexey Ivanov aivanov at openjdk.org
Mon Aug 22 21:59:27 UTC 2022


On Mon, 22 Aug 2022 21:12:58 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:

>> 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?
>
>> Does it mean that now we will always request the insets from the platform?
> 
> **_Yes the following block of code runs when window isn't sized yet (first time) or when the incoming taget is a frame to obtain platform insets_**
> 
>> Was this code run before the frame was changed from resizeable to non-resizeable? Therefore the insets weren't updated correctly.
> 
>  _**It was not going into this block for resizable frames. The issue was with the cached insets. The first time when frame,pack() is called on non-resizable frame the correct insets associated with it is returned and the frame is sized accordingly. But any subsequent calls to frame.getInsets() or frame.getPreferredSize() which gets the cached insets from [WPanelPeer](https://github.com/openjdk/jdk/blob/27af0144ea57e86d9b81c2b328fad66e4a046f61/src/java.desktop/windows/classes/sun/awt/windows/WPanelPeer.java#L62) was returning the cached insets of Resizable frame and not that of the Non-Resizable frame**_

And this is unclear to me. The frame is set to non-resizeable, `frame.pack()` is called. This, I assume, results in this code block being executed, so the calculated insets should be cached.

Why do the following calls to `getInsets` or `getPreferredSize` return the *resizeable* insets if the cached ones are *non-resizeable*?

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

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



More information about the client-libs-dev mailing list