2
0

Java Client: Fix window restore after close to background in Windows

This commit is contained in:
Michael Ziminsky (Z) 2018-10-29 13:27:20 -07:00
parent e9ad781ebe
commit 8300d48b66
3 changed files with 16 additions and 10 deletions

View File

@ -91,9 +91,9 @@ public final class MasterPassword {
frame.setAlwaysOnTop( true );
frame.setVisible( true );
frame.setExtendedState( Frame.NORMAL );
Platform.get().requestForeground();
frame.setAlwaysOnTop( false );
frame.restore();
} );
}

View File

@ -65,8 +65,10 @@ public class JDK9Platform implements IPlatform {
@Override
public boolean requestForeground() {
final boolean supported = desktop.isSupported(Desktop.Action.APP_REQUEST_FOREGROUND);
if (supported)
desktop.requestForeground( true );
return true;
return supported;
}
@Override

View File

@ -38,6 +38,17 @@ public class MasterPasswordFrame extends JFrame {
userPanel.add( userContent.getUserToolbar(), BorderLayout.LINE_START );
userPanel.add( userContent.getSiteToolbar(), BorderLayout.LINE_END );
restore();
final WindowHandler windowHandler = new WindowHandler();
addWindowListener(windowHandler);
addWindowStateListener(windowHandler);
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(windowHandler);
addComponentListener(new ResizeHandler());
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
public void restore() {
final MPGuiConfig config = MPGuiConfig.get();
if (config.getWindowSize() != null) {
@ -58,13 +69,6 @@ public class MasterPasswordFrame extends JFrame {
if (config.getWindowMaximized())
setExtendedState(MAXIMIZED_BOTH);
final WindowHandler windowHandler = new WindowHandler();
addWindowListener(windowHandler);
addWindowStateListener(windowHandler);
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(windowHandler);
addComponentListener(new ResizeHandler());
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}