<AWT Dev> RFR: 8258788: incorrect response to change in window insets [lanai] [v3]

Sergey Bylokhov serb at openjdk.java.net
Wed Apr 7 00:40:31 UTC 2021


On Mon, 5 Apr 2021 10:34:21 GMT, Alexey Ushakov <avu at openjdk.org> wrote:

>>> Can you check that it will work in the "new" tabbed mode on big sur as well?
>> 
>> Could you suggest any working test scenario? My simple test (below) just hangs even with OGL:
>> 
>> import java.awt.FlowLayout;
>> import java.util.Objects;
>> import javax.swing.*;
>> import javax.swing.border.EmptyBorder;
>> 
>> public class TestWindowInsets
>>   extends JDialog
>> {
>> 
>>     public TestWindowInsets()
>>     {
>>         JComponent contentPane = (JComponent) getContentPane();
>>         contentPane.setBorder(new EmptyBorder(50, 50, 50, 50));
>>         JButton b = new JButton("Test");
>>         b.addActionListener(e -> toggle());
>>         add(b);
>>         JButton c = new JButton("Win");
>>         c.addActionListener(e -> win());
>>         add(c);
>> 
>>         setLayout(new FlowLayout());
>>         setSize(800, 600);
>> 
>>         setVisible(true);
>> 
>>     }
>> 
>>     void toggle()
>>     {
>>         SwingUtilities.invokeLater(() -> {
>>             JRootPane rp = getRootPane();
>>             String name = "apple.awt.fullWindowContent";
>>             Object value = rp.getClientProperty(name);
>>             if (Objects.equals(value, "true")) {
>>                 value = "false";
>>             } else {
>>                 value = "true";
>>             }
>>             rp.putClientProperty(name, value);
>>         });
>>     }
>> 
>>     void win()
>>     {
>>         SwingUtilities.invokeLater(TestWindowInsets::new);
>>     }
>> 
>>     public static void main(String[] args)
>>     {
>>         SwingUtilities.invokeLater(TestWindowInsets::new);
>>     }
>> }
>
>> Probably it is possible to swap coordinates during rendering in the layer and get rid of this field?
> 
> I don't see a way how we can do it. Because of the inverted y coordinate in metal, we need to place the origin of the drawing with the appropriate offset that depends on the title height, even if we invert the y coordinate to match java2d coordinate system.

I am just not sure that this is the only place where the insets might be changed.

We need to add a "callback" which will be called every time the insets will be changed. Probably in the MTLLayer.replaceSurfaceData which should be called from the LWWindowsPeer#notifyReshape->replaceSurfaceData(). Currently, we skip that call if insets were changed. and this is why this bug arise.

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

PR: https://git.openjdk.java.net/jdk/pull/3308


More information about the awt-dev mailing list