Fix clicking tray icon not bringing client to front on macOS

This commit is contained in:
testing-ongithub
2022-01-02 10:26:06 -06:00
committed by Adam
parent 45f744fa2b
commit a4b10d99d8

View File

@@ -184,6 +184,18 @@ public class SwingUtil
@Override
public void mouseClicked(MouseEvent e)
{
if (OSType.getOSType() == OSType.MacOS)
{
// On macOS, frame.setVisible(true) only restores focus when the visibility was previously false.
// The frame's visibility is not set to false when the window loses focus, so we set it manually.
// Additionally, in order to bring the window to the foreground,
// frame.setVisible(true) calls CPlatformWindow::nativePushNSWindowToFront.
// However, this native method is not called with activateIgnoringOtherApps:YES,
// so any other active window will prevent our window from being brought to the front.
// To work around this, we use our macOS-specific requestForeground().
frame.setVisible(false);
OSXUtil.requestForeground();
}
frame.setVisible(true);
frame.setState(Frame.NORMAL); // Restore
}