JAL-2779 patch so closing most recent frame doesn’t transfer focus to oldest frame...
authorJim Procter <jprocter@issues.jalview.org>
Wed, 18 Oct 2017 16:12:51 +0000 (17:12 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 18 Oct 2017 16:12:51 +0000 (17:12 +0100)
src/jalview/gui/AquaInternalFrameManager.java

index a97d8ec..aeb1e5f 100644 (file)
@@ -57,6 +57,11 @@ import com.apple.laf.AquaInternalFramePaneUI;
  * Downloaded from
  * https://raw.githubusercontent.com/frohoff/jdk8u-jdk/master/src/macosx/classes/com/apple/laf/AquaInternalFrameManager.java
  * 
+ * Patch from Jim Procter - when the most recently opened frame is closed,
+ * correct behaviour is to go to the next most recent frame, rather than wrap
+ * around to the bottom of the window stack (as the original implementation
+ * does)
+ * 
  * @see com.sun.java.swing.plaf.windows.WindowsDesktopManager
  */
 public class AquaInternalFrameManager extends DefaultDesktopManager
@@ -86,7 +91,16 @@ public class AquaInternalFrameManager extends DefaultDesktopManager
   {
     if (f == fCurrentFrame)
     {
-      activateNextFrame();
+      boolean mostRecentFrame = fChildFrames
+              .indexOf(f) == fChildFrames.size() - 1;
+      if (!mostRecentFrame)
+      {
+        activateNextFrame();
+      }
+      else
+      {
+        activatePreviousFrame();
+      }
     }
     fChildFrames.removeElement(f);
     super.closeFrame(f);