IDEA-205497 QuickDoc popup appears on another monitor if invoked from "Brief Info" popup

This commit is contained in:
Dmitry Batrak
2019-01-29 12:08:27 +03:00
parent fb619ab6a1
commit 7c1d6df2b5
2 changed files with 17 additions and 4 deletions
@@ -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);
}
@@ -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());