From 0a675d99a84272aba045db96d1a15c5bdedcf4af Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 26 Jul 2016 19:47:13 +0300 Subject: [PATCH] AbstractPopup: fix storeLocation if myLocateByContent is true --- .../com/intellij/ui/popup/AbstractPopup.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java index 3e2f9493eac3..44400278e7c6 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java @@ -646,7 +646,7 @@ public class AbstractPopup implements JBPopup { if (root != null) { final Container popupWindow = root.getParent(); if (popupWindow != null && popupWindow.isShowing()) { - storeLocation(popupWindow.getLocationOnScreen()); + storeLocation(fixLocateByContent(popupWindow.getLocationOnScreen(), true)); } } } @@ -804,10 +804,7 @@ public class AbstractPopup implements JBPopup { xy = myForcedLocation; } - if (myLocateByContent) { - final Dimension captionSize = myHeaderPanel.getPreferredSize(); - xy.y -= captionSize.height; - } + fixLocateByContent(xy, false); Rectangle targetBounds = new Rectangle(xy, myContent.getPreferredSize()); Rectangle original = new Rectangle(targetBounds); @@ -1555,14 +1552,9 @@ public class AbstractPopup implements JBPopup { @Override public Point getLocationOnScreen() { - Dimension headerCorrectionSize = myLocateByContent ? myHeaderPanel.getPreferredSize() : null; Point screenPoint = myContent.getLocation(); SwingUtilities.convertPointToScreen(screenPoint, myContent); - if (headerCorrectionSize != null) { - screenPoint.y -= headerCorrectionSize.height; - } - - return screenPoint; + return fixLocateByContent(screenPoint, false); } @@ -1884,6 +1876,12 @@ public class AbstractPopup implements JBPopup { return e != null && e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_ESCAPE && e.getModifiers() == 0; } + private Point fixLocateByContent(Point location, boolean save) { + Dimension size = !myLocateByContent ? null : myHeaderPanel.getPreferredSize(); + if (size != null) location.y -= save ? -size.height : size.height; + return location; + } + private boolean isBusy() { return myResizeListener != null && myResizeListener.isBusy() || myMoveListener != null && myMoveListener.isBusy(); }