remove old key in WindowStateServiceImpl

This commit is contained in:
Anton Tarasov
2017-05-29 16:34:58 +03:00
parent 8d41530bab
commit dd0138b390
@@ -278,12 +278,15 @@ abstract class WindowStateServiceImpl extends WindowStateService implements Pers
boolean maximized, boolean maximizedSet,
boolean fullScreen, boolean fullScreenSet) {
WindowState state = myStateMap.get(keyPair.first);
if (state == null) {
// may be convert the old key state to the new key
state = myStateMap.remove(oldKeyPair.first);
// may be convert the old key state to the new key
WindowState oldState = myStateMap.remove(oldKeyPair.first);
if (oldState != null) {
oldState.scaleDown(oldKeyPair.second);
if (state != null) {
state.scaleDown(oldKeyPair.second);
myStateMap.put(keyPair.first, state);
state.merge(oldState);
} else {
myStateMap.put(keyPair.first, state = oldState);
}
}
if (state != null) {
@@ -459,6 +462,18 @@ abstract class WindowStateServiceImpl extends WindowStateService implements Pers
}
return myLocation != null || mySize != null;
}
/**
* Merges this state with the passed one, prefering this state.
*/
private void merge(@NotNull WindowState state) {
if (myLocation == null && state.myLocation != null) {
myLocation = state.myLocation.getLocation();
}
if (mySize == null && state.mySize != null) {
mySize = state.mySize.getSize();
}
}
}
private static boolean isVisible(WindowState state) {