JDK-8231991 : Mouse wheel change focus on awt/swing windows
  • Type: Bug
  • Component: client-libs
  • Affected Version: 11,13,14
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • Submitted: 2019-10-08
  • Updated: 2020-06-01
  • Resolved: 2019-11-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 13 JDK 14 Other
11.0.6Fixed 13u-cpuFixed 14 b25Fixed openjdk8u252Fixed
Related Reports
Relates :  
Description
There is an issue with the way mouse wheel events carry focus to background components on Linux with X11, for example if we have two frames one in front and focused and the other in the background and we move the mouse cursor over the background frame and start scrolling with the mouse wheel up or down the background frame now receive focus, it is however not raised, leaving the foreground frame in an inconsistent state.

A simple reproducer demonstrate the problem:

import java.awt.Dimension;
import javax.swing.JFrame;

public class Foo {
    public static void main(String[] args) {
    JFrame w1 = new JFrame("Window 1"), w2 = new JFrame("Window 2");
    w1.setPreferredSize(new Dimension(600, 600));
    w1.pack();
    w1.setVisible(true);
    w2.setPreferredSize(new Dimension(600, 600));
    w2.pack();
    w2.setVisible(true);
    }
}

Slight move one of the windows and use mouse wheel. The window will gain focus, but not be raised.

It should either get focus and be raised, or not get focus.

Comments
Patch applies cleanly (with shuffling), is in 11u, and fixes a customer bug (https://bugzilla.redhat.com/show_bug.cgi?id=1741676) Restoring jdk8u-fix-request, approving and pushing. JDK-8234107 should also be approved to avoid test breakage.
14-01-2020

I don't see a "Fix Request" comment explaining why this backport is needed, whether the patch applies cleanly, what the assumed risk is, whether or not the backport patch passed review, who reviewed it, etc. Please add that and re-apply for approval. Removing jdk8u-fix-request for the time being.
20-12-2019

URL: https://hg.openjdk.java.net/jdk/jdk/rev/d5af26ef7b95 User: psadhukhan Date: 2019-11-21 09:06:33 +0000
21-11-2019

Backport requested: https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2019-November/002138.html https://mail.openjdk.java.net/pipermail/jdk8u-dev/2019-November/010620.html
20-11-2019

URL: https://hg.openjdk.java.net/jdk/client/rev/d5af26ef7b95 User: neugens Date: 2019-11-12 14:58:41 +0000
12-11-2019

Review thread: https://mail.openjdk.java.net/pipermail/awt-dev/2019-October/015434.html
08-10-2019

Proposed fix: http://cr.openjdk.java.net/~neugens/JDK-8231991/webrev.00/
08-10-2019