8232433: [macos 10.15] java/awt/Window/LocationAtScreenCorner/LocationAtScreenCorner.java may fail
authorserb
Thu, 14 Nov 2019 15:13:29 -0800
changeset 59189 b5cdba232fca
parent 59188 9db62a092725
child 59190 88ddd6943a06
8232433: [macos 10.15] java/awt/Window/LocationAtScreenCorner/LocationAtScreenCorner.java may fail Reviewed-by: prr
src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
test/jdk/java/awt/Window/LocationAtScreenCorner/LocationAtScreenCorner.java
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Thu Nov 14 10:59:45 2019 +0530
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Thu Nov 14 15:13:29 2019 -0800
@@ -1237,6 +1237,15 @@
         // ensure we repaint the whole window after the resize operation
         // (this will also re-enable screen updates, which were disabled above)
         // TODO: send PaintEvent
+
+        // the macOS may ignore our "setFrame" request, in this, case the
+        // windowDidMove() will not come and we need to manually resync the
+        // "java.awt.Window" and NSWindow locations, because "java.awt.Window"
+        // already uses location ignored by the macOS.
+        // see sun.lwawt.LWWindowPeer#notifyReshape()
+        if (!NSEqualRects(rect, [nsWindow frame])) {
+            [window _deliverMoveResizeEvent];
+        }
     }];
 
 JNF_COCOA_EXIT(env);
--- a/test/jdk/java/awt/Window/LocationAtScreenCorner/LocationAtScreenCorner.java	Thu Nov 14 10:59:45 2019 +0530
+++ b/test/jdk/java/awt/Window/LocationAtScreenCorner/LocationAtScreenCorner.java	Thu Nov 14 15:13:29 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,6 +21,7 @@
  * questions.
  */
 
+import java.awt.AWTException;
 import java.awt.Frame;
 import java.awt.GraphicsDevice;
 import java.awt.GraphicsEnvironment;
@@ -31,15 +32,21 @@
 /**
  * @test
  * @key headful
- * @bug 8201364
+ * @bug 8201364 8232433
  * @summary Component.getLocation() should returns correct location if
  *          Component.setBounds() was ignored by the OS
  */
 public final class LocationAtScreenCorner {
 
     public static void main(final String[] args) throws Exception {
+        test(true);
+        test(false);
+    }
+
+    private static void test(final boolean undecorated) throws AWTException {
         Robot robot = new Robot();
         Frame frame = new Frame();
+        frame.setUndecorated(undecorated);
         frame.setSize(200, 200);
         frame.setLocationRelativeTo(null);
         frame.setVisible(true);