From 3064d7633b84387f032cc256247b4d9fd06fc313 Mon Sep 17 00:00:00 2001 From: Vassiliy Kudryashov Date: Mon, 26 Mar 2012 12:34:09 +0400 Subject: [PATCH] IDEA-66794 Help Topics window opens behind main IDEA frame with certain conditions (cherry picked from commit 9bad095) --- .../intellij/help/impl/IdeaHelpBroker.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/help/impl/IdeaHelpBroker.java b/platform/platform-impl/src/com/intellij/help/impl/IdeaHelpBroker.java index a7555f94361f..5df8dd779802 100644 --- a/platform/platform-impl/src/com/intellij/help/impl/IdeaHelpBroker.java +++ b/platform/platform-impl/src/com/intellij/help/impl/IdeaHelpBroker.java @@ -15,7 +15,10 @@ */ package com.intellij.help.impl; +import com.intellij.openapi.wm.IdeFocusManager; +import com.intellij.openapi.wm.impl.IdeFocusManagerHeadless; import com.intellij.ui.AppUIUtil; +import com.intellij.util.Alarm; import org.jetbrains.annotations.NotNull; import javax.help.*; @@ -207,6 +210,9 @@ class IdeaHelpBroker extends DefaultHelpBroker implements KeyListener{ //myFrame.setLocationRelativeTo(null); myFrame.setVisible(visible); myFrame.setState(JFrame.NORMAL); + IdeFocusManager focusManager = IdeFocusManager.findInstance(); + JComponent target = focusManager.getFocusTargetFor(myFrame.getRootPane()); + focusManager.requestFocus(target != null ? target : myFrame, true); } } @@ -671,8 +677,9 @@ class IdeaHelpBroker extends DefaultHelpBroker implements KeyListener{ if(myDialog.isShowing()){ myDialog.hide(); } - if(myOwnerWindow!=null) + if (myOwnerWindow != null) { myOwnerWindow.removeWindowListener(dl); + } myOwnerWindow=null; modalDeactivated=true; } @@ -694,22 +701,24 @@ class IdeaHelpBroker extends DefaultHelpBroker implements KeyListener{ } } } else{ - if(myFrame==null){ - myFrame=new JFrame(helpTitle); + if (myFrame == null) { + myFrame = new JFrame(helpTitle); resize = true; AppUIUtil.updateFrameIcon(myFrame); - WindowListener l=new WindowAdapter(){ - public void windowClosing(WindowEvent e){ + WindowListener l = new WindowAdapter() { + public void windowClosing(WindowEvent e) { myFrame.setVisible(false); } - public void windowClosed(WindowEvent e){ + public void windowClosed(WindowEvent e) { myFrame.setVisible(false); } }; myFrame.addWindowListener(l); - } else + } + else { pos = myFrame.getLocation(); + } if(myDialog!=null){ pos=myDialog.getLocation(); size=myDialog.getSize();