RFR: 8279879: [macos] ActionEvent triggered when right-clicking TrayIcon

Alexander Zvegintsev azvegint at openjdk.java.net
Wed Jan 12 22:57:25 UTC 2022


On Wed, 12 Jan 2022 16:53:00 GMT, Alisen Chung <achung at openjdk.org> wrote:

>> test/jdk/java/awt/TrayIcon/RightClickWhenBalloonDisplayed/RightClickWhenBalloonDisplayed.java line 113:
>> 
>>> 111:         robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);
>>> 112:         robot.delay(1000);
>>> 113:         robot.waitForIdle();
>> 
>> The purpose of the test is to check the action event while the balloon is visible after the left click (the balloon is shown on the mouse click event), so removing the left click does not seem correct, no?
>
> Oh, I misunderstood the test. Based on a previous version of this test that was failing I thought the issue was the ActionEvent firing on a TrayIcon right-click that also brought up the balloon message..
> 
> I have a few questions about the expected behavior of TrayIcon:
> Should ActionEvent be triggered on a normal left-click? How about a normal right-click?
> When should ActionEvent not be triggered? Not on right-click during a balloon message? What about left-click during a balloon message?

It is platform dependent:
https://github.com/openjdk/jdk/blob/d70545d71080d534fefd3c9652656549f689f620/src/java.desktop/share/classes/java/awt/TrayIcon.java#L565-L566
Current behavior of OpenJDK is:
* Linux sends it on left button click
* macOS send it on right button click.
* On Windows it can be triggered by a second mouse click on a tray icon(doesn't matter which mouse key is used), left mouse click on the balloon, or enter keypress on it.

https://github.com/openjdk/jdk/blob/d70545d71080d534fefd3c9652656549f689f620/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp#L412-L457

[JDK-8195991](https://bugs.openjdk.java.net/browse/JDK-8195991) introduced this test, but its description does not conform with its code:

> Right clicking on TrayIcon shouldn't trigger ActionEvent when balloon is displayed.

Given the info above this will be true only for Linux, which does not trigger `ACTION_PERFORMED` on right mouse click. 

> int actionPerformedCount = -1;
...
if (actionPerformedCount > 0

So the test code expects to receive 0 or 1  `ACTION_PERFORMED` events. It allows the test to pass with our current implementation.



The original test was written along with a fix for Windows back in [2005](https://bugs.openjdk.java.net/browse/JDK-6271624). 

The Windows UI have changed since this time, so may be the expectation of not receiving of `ACTION_PERFORMED` is no longer valid.

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

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



More information about the client-libs-dev mailing list