experimental dev commit: optionally do not focus app on startup
authorKirill Kalishev <kirill.kalishev@jetbrains.com>
Tue, 9 Mar 2010 13:10:18 +0000 (16:10 +0300)
committerKirill Kalishev <kirill.kalishev@jetbrains.com>
Tue, 9 Mar 2010 13:10:18 +0000 (16:10 +0300)
platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java
platform/platform-resources-en/src/misc/registry.properties

index 437798bfb9127b1bc1127693d182ca04bca30b5c..46ab77865013f1db1efdf8d534f4c669036d7c56 100644 (file)
@@ -33,6 +33,7 @@ import com.intellij.openapi.keymap.KeymapManager;
 import com.intellij.openapi.project.DumbAwareRunnable;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectManager;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.wm.IdeFrame;
 import com.intellij.openapi.wm.ex.LayoutFocusTraversalPolicyExt;
 import com.intellij.openapi.wm.ex.StatusBarEx;
@@ -84,6 +85,32 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider {
     new MnemonicHelper().register(this);
 
     myBalloonLayout = new BalloonLayout(myRootPane.getLayeredPane(), new Insets(8, 8, 8, 8));
+
+    if (!Registry.is("ide.windowSystem.focusAppOnStartup") && !isThereActiveFrame()) {
+      setFocusableWindowState(false);
+    }
+
+  }
+
+  private boolean isThereActiveFrame() {
+    Frame[] all = Frame.getFrames();
+    for (Frame each : all) {
+      if (each.isActive()) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+
+  @Override
+  public void show() {
+    super.show();
+    SwingUtilities.invokeLater(new Runnable() {
+      public void run() {
+        setFocusableWindowState(true);
+      }
+    });
   }
 
   /**
index 3e416e34df5556f663d21922073adc72c19d30bb..07c58ae7873f39a5c83dc289caec114b057271ed 100644 (file)
@@ -30,6 +30,7 @@ ide.consumeKnownToolkitBugs=true
 
 ide.windowSystem.hScrollChars=15
 ide.windowSystem.vScrollChars=5
+ide.windowSystem.focusAppOnStartup=true
 
 ide.tree.yeildingUiUpdate=true
 ide.tree.showBusyIndicator=true