Help for fixing JDK-8227366

Thiago Milczarek Sayao thiago.sayao at clamed.com.br
Sun Jul 28 20:00:22 UTC 2019


Hi,

I have been investigating:
https://bugs.openjdk.java.net/browse/JDK-8227366

The problem is the focus event gets fired for all windows when a window is closed, so it messes up with "last window" tracking. It also causes unnecessary events.


On com.sun.javafx.tk.quantum.GlassStage:

    void windowsSetEnabled(boolean enabled) {
        // TODO: Need to solve RT-12605:
        // If Window #1 pops up an APPLICATION modal dialog #2 it should block
        // Window #1, but will also block Window #3, #4, etc., unless those
        // windows are descendants of #2.

        // Make a copy of the windows list, since it could change as the result
        // of a child window being closed when the parent is closed.
        for (GlassStage window : windows.toArray(new GlassStage[windows.size()])) {
            if (window != this && windows.contains(window)) {
                window.setPlatformEnabled(enabled);
            }
        }
    }

It loops thru windows and calls setPlatformEnabled.

On com.sun.javafx.tk.quantum.WindowStage:

    protected void setPlatformEnabled(boolean enabled) {
        super.setPlatformEnabled(enabled);
        if (platformWindow != null) {
            platformWindow.setEnabled(enabled);
        }
        if (enabled) {
            // Check if window is really enabled - to handle nested case
            if (platformWindow != null && platformWindow.isEnabled()) {
                requestToFront();
            }
        } else {
            removeActiveWindow(this);
        }
    }

It calls requestToFront();

    // Note: This method is required to workaround a glass issue mentioned in RT-12607
    protected void requestToFront() {
        if (platformWindow != null) {
            platformWindow.toFront();
            platformWindow.requestFocus();
        }
    }

Which calls requestFocus();

As it's called on each window, it will bring each window to front.

I find this weird.

Any ideas why this is necessary?

        if (enabled) {
            // Check if window is really enabled - to handle nested case
            if (platformWindow != null && platformWindow.isEnabled()) {
                requestToFront();
            }
        } 

Seems wrong to me.




More information about the openjfx-dev mailing list