From 7c1d6df2b50ebcfe81a75472f903e30a7d0f7412 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Tue, 29 Jan 2019 12:06:30 +0300 Subject: [PATCH] IDEA-205497 QuickDoc popup appears on another monitor if invoked from "Brief Info" popup --- .../documentation/DocumentationComponent.java | 12 +++++++++--- .../src/com/intellij/ui/popup/AbstractPopup.java | 9 ++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java index 6b24a804ee35..c7f171be40e3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java @@ -856,9 +856,15 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr } private DataContext getDataContext() { - Component referenceComponent = SoftReference.dereference(myReferenceComponent); - if (referenceComponent == null) referenceComponent = IdeFocusManager.getInstance(myManager.myProject).getFocusOwner(); - if (myReferenceComponent == null) myReferenceComponent = new WeakReference<>(referenceComponent); + Component referenceComponent; + if (myReferenceComponent == null) { + referenceComponent = IdeFocusManager.getInstance(myManager.myProject).getFocusOwner(); + myReferenceComponent = new WeakReference<>(referenceComponent); + } + else { + referenceComponent = SoftReference.dereference(myReferenceComponent); + if (referenceComponent == null || ! referenceComponent.isShowing()) referenceComponent = myHint.getComponent(); + } return DataManager.getInstance().getDataContext(referenceComponent); } 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 df4ed1a7d937..2abccc18c34d 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java @@ -505,7 +505,14 @@ public class AbstractPopup implements JBPopup { return relativePointWithDominantRectangle(layeredPane, dominantArea); } } - RelativePoint location = JBPopupFactory.getInstance().guessBestPopupLocation(dataContext); + RelativePoint location; + Component contextComponent = dataContext.getData(PlatformDataKeys.CONTEXT_COMPONENT); + if (contextComponent == myComponent) { + location = new RelativePoint(myComponent, new Point()); + } + else { + location = JBPopupFactory.getInstance().guessBestPopupLocation(dataContext); + } if (myLocateWithinScreen) { Point screenPoint = location.getScreenPoint(); Rectangle rectangle = new Rectangle(screenPoint, getSizeForPositioning());