RFR: 8296972: [macos13] java/awt/Frame/MaximizedToIconified/MaximizedToIconified.java: getExtendedState() != 6 as expected. [v2]

Dmitry Markov dmarkov at openjdk.org
Tue Jun 13 14:33:09 UTC 2023


On Mon, 12 Jun 2023 22:29:25 GMT, Alisen Chung <achung at openjdk.org> wrote:

>> added displayChanged call to CPlatformWindow when frame first needs to deiconify or unmaximize
>> All client tests passed after change
>
> Alisen Chung has updated the pull request incrementally with one additional commit since the last revision:
> 
>   use realsync to flush native queue

Changes requested by dmarkov (Reviewer).

src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java line 989:

> 987:                     // the zoom call toggles between the normal and the max states
> 988:                     unmaximize();
> 989:                     peer.getLWToolkit().realSync();

Well.. `realSync()` works here but I am not sure if that invocation really fixes the issue or just hides it by introducing a delay.
I believe we need some function which ensures that the frame is in correct (`NORMAL`) state right after `unmaximize()` call and before `execute(CWrapper.NSWindow::miniaturize)` invocation.

Possible implementation of that method below:


private void waitForWindowState(int state) {
        Object lock = new Object();
        target.addWindowStateListener(new WindowStateListener() {
            public void windowStateChanged(WindowEvent e) {
                synchronized(lock) {
                    if (e.getNewState() == state) {
                        lock.notifyAll();
                    }
                }
            }
        });
        if (peer.getState() != state) {
            synchronized(lock) {
                try {
                    lock.wait();
                } catch(InterruptedException ie) {}
            }
        }
    }


So in code you will call `waitForWindowState(Frame.NORMAL)` instead of `realSync()`

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

PR Review: https://git.openjdk.org/jdk/pull/14226#pullrequestreview-1477327791
PR Review Comment: https://git.openjdk.org/jdk/pull/14226#discussion_r1228226627



More information about the client-libs-dev mailing list