focus stealing issue: isActive() is more accurate + removed direct call to requestFoc...
authorKirill Kalishev <kirillk@kirillk-ubuntu10.(none)>
Sat, 6 Feb 2010 08:28:56 +0000 (11:28 +0300)
committerKirill Kalishev <kirillk@kirillk-ubuntu10.(none)>
Sat, 6 Feb 2010 08:28:56 +0000 (11:28 +0300)
platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java
platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java

index 13d055d66a7ede7ef3891e3dc539246e86a30041..6010b0e857bcfaa139ab56d7e2b9bef9952fd067 100644 (file)
@@ -63,6 +63,7 @@ import com.intellij.openapi.vfs.JarFileSystem;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VfsUtil;
 import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.wm.IdeFocusManager;
 import com.intellij.openapi.wm.ToolWindow;
 import com.intellij.openapi.wm.ToolWindowId;
 import com.intellij.openapi.wm.ToolWindowManager;
@@ -405,7 +406,7 @@ public final class ProjectViewImpl extends ProjectView implements PersistentStat
     newPane.setTreeChangeListener(myTreeChangeListener);
     myAutoScrollToSourceHandler.install(newPane.myTree);
 
-    newPane.getComponentToFocus().requestFocus();
+    IdeFocusManager.getInstance(myProject).requestFocus(newPane.getComponentToFocus(), false);
     updateToolWindowTitle();
 
     newPane.restoreExpandedPaths();
index 5defc2f4615de733af1cbf478403b0c42c3fb301..910dfab558bdcb371e6e38118a53fcaa73b83743 100644 (file)
@@ -139,7 +139,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
   private boolean myIsFiringLoadingEvent = false;
   @NonNls private static final String WAS_EVER_SHOWN = "was.ever.shown";
 
-  private boolean myActive = true;
+  private Boolean myActive;
 
   protected void boostrapPicoContainer() {
     super.boostrapPicoContainer();
@@ -911,8 +911,8 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
 
     if (frame instanceof IdeFrame) {
       final IdeFrame ideFrame = (IdeFrame)frame;
-      if (myActive != active) {
-        myActive = active;
+      if (isActive() != active) {
+        myActive = Boolean.valueOf(active);
         System.setProperty("idea.active", Boolean.valueOf(myActive).toString());
         if (active) {
           myDispatcher.getMulticaster().applicationActivated(ideFrame);
@@ -928,6 +928,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
   }
 
   public boolean isActive() {
+    if (isUnitTestMode()) return true;
+
+    if (myActive == null) {
+      Window active = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
+      return active != null;
+    }
+
     return myActive;
   }