RFR: 8325435: [macos] Menu or JPopupMenu not closed when main window is resized
Abhishek Kumar
abhiscxk at openjdk.org
Fri May 31 10:57:02 UTC 2024
On Thu, 30 May 2024 12:05:25 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
> Issue is in macosx, when a JMenu or JPopupmenu is opened and then window is resized from the lower right corner, then the Menu / JPopupmenu stays open unlike in native osx apps like Notes, Mail etc..
>
> This is because when LMouseButton is pressed on non-client area, the window should get a UngrabEvent for it to close/cancel the popupmenu (as is done in [windows](https://github.com/openjdk/jdk/blob/f608918df3f887277845db383cf07b0863bba615/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp#L618-L620)) but it was seen that the mac AWTWindow code only recognizes the title-bar as the non-client area so [notifyNCMouseDown](https://github.com/openjdk/jdk/blob/f608918df3f887277845db383cf07b0863bba615/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java#L797-L804) is not called.
> Fix is made to recognize the edges of the window as non-client area
test/jdk/javax/swing/JMenu/TestUngrab.java line 68:
> 66:
> 67: frame.setJMenuBar(mb);
> 68: frame.setSize(300,300);
Suggestion:
frame.setSize(300, 300);
test/jdk/javax/swing/JMenu/TestUngrab.java line 81:
> 79: robot.delay(1000);
> 80: Point point = menu.getLocationOnScreen();
> 81: Dimension dim = menu.getSize();
Should it be accessed on EDT?
test/jdk/javax/swing/JMenu/TestUngrab.java line 82:
> 80: Point point = menu.getLocationOnScreen();
> 81: Dimension dim = menu.getSize();
> 82: robot.mouseMove(point.x + dim.width/2, point.y + dim.height/2);
Suggestion:
robot.mouseMove(point.x + dim.width / 2, point.y + dim.height / 2);
test/jdk/javax/swing/JMenu/TestUngrab.java line 101:
> 99: }
> 100: } finally {
> 101: SwingUtilities.invokeAndWait(() -> frame.dispose());
may add `null` check for _frame_ before `dispose`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19474#discussion_r1622225422
PR Review Comment: https://git.openjdk.org/jdk/pull/19474#discussion_r1622226476
PR Review Comment: https://git.openjdk.org/jdk/pull/19474#discussion_r1622226864
PR Review Comment: https://git.openjdk.org/jdk/pull/19474#discussion_r1622228685
More information about the client-libs-dev
mailing list