mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
store window bounds in project-based WindowStateService
GitOrigin-RevId: dbb569bf7b1dc567d4db4bfce5e2dea3a826e827
This commit is contained in:
committed by
intellij-monorepo-bot
parent
060237cf1e
commit
f5af4de06b
@@ -26,6 +26,7 @@ import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.DimensionService;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.WindowStateService;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
@@ -663,8 +664,10 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer {
|
||||
|
||||
if (myDimensionServiceKey != null) {
|
||||
final Project projectGuess = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(this));
|
||||
location = DimensionService.getInstance().getLocation(myDimensionServiceKey, projectGuess);
|
||||
Dimension size = DimensionService.getInstance().getSize(myDimensionServiceKey, projectGuess);
|
||||
location = getWindowStateService(projectGuess).getLocation(myDimensionServiceKey);
|
||||
if (location == null) location = DimensionService.getInstance().getLocation(myDimensionServiceKey, projectGuess);
|
||||
Dimension size = getWindowStateService(projectGuess).getSize(myDimensionServiceKey);
|
||||
if (size == null) size = DimensionService.getInstance().getSize(myDimensionServiceKey, projectGuess);
|
||||
if (size != null) {
|
||||
myInitialSize = new Dimension(size);
|
||||
_setSizeForLocation(myInitialSize.width, myInitialSize.height, location);
|
||||
@@ -808,10 +811,12 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer {
|
||||
|
||||
// Save location
|
||||
Point location = getLocation();
|
||||
getWindowStateService(projectGuess).putLocation(myDimensionServiceKey, location);
|
||||
DimensionService.getInstance().setLocation(myDimensionServiceKey, location, projectGuess);
|
||||
// Save size
|
||||
Dimension size = getSize();
|
||||
if (!myInitialSize.equals(size)) {
|
||||
getWindowStateService(projectGuess).putSize(myDimensionServiceKey, size);
|
||||
DimensionService.getInstance().setSize(myDimensionServiceKey, size, projectGuess);
|
||||
}
|
||||
myOpened = false;
|
||||
@@ -966,6 +971,11 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer {
|
||||
return wrapper != null && PlatformDataKeys.UI_DISPOSABLE.is(dataId) ? wrapper.getDisposable() : null;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static WindowStateService getWindowStateService(@Nullable Project project) {
|
||||
return project == null ? WindowStateService.getInstance() : WindowStateService.getInstance(project);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setupSelectionOnPreferredComponent(final JComponent component) {
|
||||
|
||||
@@ -527,8 +527,8 @@ public class AbstractPopup implements JBPopup, ScreenAreaConsumer {
|
||||
|
||||
private Dimension getSizeForPositioning() {
|
||||
Dimension size = getSize();
|
||||
if (size == null && myDimensionServiceKey != null) {
|
||||
size = DimensionService.getInstance().getSize(myDimensionServiceKey, myProject);
|
||||
if (size == null) {
|
||||
size = getStoredSize();
|
||||
}
|
||||
if (size == null) {
|
||||
size = myContent.getPreferredSize();
|
||||
@@ -654,10 +654,8 @@ public class AbstractPopup implements JBPopup, ScreenAreaConsumer {
|
||||
if (myForcedSize != null) {
|
||||
return myForcedSize;
|
||||
}
|
||||
if (myDimensionServiceKey != null) {
|
||||
final Dimension dimension = DimensionService.getInstance().getSize(myDimensionServiceKey, myProject);
|
||||
if (dimension != null) return dimension;
|
||||
}
|
||||
Dimension size = getStoredSize();
|
||||
if (size != null) return size;
|
||||
return myComponent.getPreferredSize();
|
||||
}
|
||||
|
||||
@@ -785,12 +783,7 @@ public class AbstractPopup implements JBPopup, ScreenAreaConsumer {
|
||||
prepareToShow();
|
||||
installWindowHook(this);
|
||||
|
||||
Dimension sizeToSet = null;
|
||||
|
||||
if (myDimensionServiceKey != null) {
|
||||
sizeToSet = DimensionService.getInstance().getSize(myDimensionServiceKey, myProject);
|
||||
}
|
||||
|
||||
Dimension sizeToSet = getStoredSize();
|
||||
if (myForcedSize != null) {
|
||||
sizeToSet = myForcedSize;
|
||||
}
|
||||
@@ -829,8 +822,8 @@ public class AbstractPopup implements JBPopup, ScreenAreaConsumer {
|
||||
|
||||
Point xy = new Point(aScreenX, aScreenY);
|
||||
boolean adjustXY = true;
|
||||
if (myUseDimServiceForXYLocation && myDimensionServiceKey != null) {
|
||||
final Point storedLocation = DimensionService.getInstance().getLocation(myDimensionServiceKey, myProject);
|
||||
if (myUseDimServiceForXYLocation) {
|
||||
Point storedLocation = getStoredLocation();
|
||||
if (storedLocation != null) {
|
||||
xy = storedLocation;
|
||||
adjustXY = false;
|
||||
@@ -1475,12 +1468,14 @@ public class AbstractPopup implements JBPopup, ScreenAreaConsumer {
|
||||
if (myDimensionServiceKey != null) {
|
||||
Dimension size = myContent.getSize();
|
||||
JBInsets.removeFrom(size, myContent.getInsets());
|
||||
getWindowStateService(myProject).putSize(myDimensionServiceKey, size);
|
||||
DimensionService.getInstance().setSize(myDimensionServiceKey, size, myProject);
|
||||
}
|
||||
}
|
||||
|
||||
private void storeLocation(final Point xy) {
|
||||
if (myDimensionServiceKey != null) {
|
||||
getWindowStateService(myProject).putLocation(myDimensionServiceKey, xy);
|
||||
DimensionService.getInstance().setLocation(myDimensionServiceKey, xy, myProject);
|
||||
}
|
||||
}
|
||||
@@ -2003,4 +1998,23 @@ public class AbstractPopup implements JBPopup, ScreenAreaConsumer {
|
||||
Window focused = event.getWindow();
|
||||
return focused != window && (focused == null || window != focused.getOwner());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Point getStoredLocation() {
|
||||
if (myDimensionServiceKey == null) return null;
|
||||
Point location = getWindowStateService(myProject).getLocation(myDimensionServiceKey);
|
||||
return location != null ? location : DimensionService.getInstance().getLocation(myDimensionServiceKey, myProject);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Dimension getStoredSize() {
|
||||
if (myDimensionServiceKey == null) return null;
|
||||
Dimension size = getWindowStateService(myProject).getSize(myDimensionServiceKey);
|
||||
return size != null ? size : DimensionService.getInstance().getSize(myDimensionServiceKey, myProject);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static WindowStateService getWindowStateService(@Nullable Project project) {
|
||||
return project == null ? WindowStateService.getInstance() : WindowStateService.getInstance(project);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user