From ef186195ccfb99210eaec3fccfbc6425386e9301 Mon Sep 17 00:00:00 2001 From: Denis Fokin Date: Tue, 23 Jul 2019 13:09:42 +0300 Subject: [PATCH] IDEA-218792 Skip minimised and fullscreen windows in Activate Next Window action GitOrigin-RevId: a3f6963bdefbb9b0aef698617f3177a308c8eec5 --- .../src/com/intellij/ide/IdeEventQueue.java | 11 +++++++++-- platform/util/ui/src/com/intellij/util/ui/UIUtil.java | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java index 52447e44c5c7..de7d428da6f9 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java @@ -31,6 +31,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.IdeFrame; import com.intellij.openapi.wm.WindowManager; +import com.intellij.openapi.wm.ex.IdeFrameEx; import com.intellij.openapi.wm.ex.WindowManagerEx; import com.intellij.openapi.wm.impl.FocusManagerImpl; import com.intellij.ui.ComponentUtil; @@ -81,11 +82,17 @@ public final class IdeEventQueue extends EventQueue { private static void updateActivatedWindowSet() { for (Iterator iter = activatedWindows.iterator(); iter.hasNext(); ) { Window window = iter.next(); - if (!window.isVisible()) { + if (!window.isVisible() || UIUtil.isMinimized(window) || isInFullscreen(window)) { iter.remove(); } } - assert !activatedWindows.isEmpty(); + // The list can be empty if all windows are in fullscreen or minimized state + } + + private static boolean isInFullscreen (Window window) { + if (!(window instanceof IdeFrameEx)) return false; + IdeFrameEx ideFrameEx = (IdeFrameEx) window; + return ideFrameEx.isInFullScreen(); } public Window nextWindowAfter (@NotNull Window w) { diff --git a/platform/util/ui/src/com/intellij/util/ui/UIUtil.java b/platform/util/ui/src/com/intellij/util/ui/UIUtil.java index 705239967e0c..8cd8623d5db7 100644 --- a/platform/util/ui/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/ui/src/com/intellij/util/ui/UIUtil.java @@ -252,6 +252,12 @@ public final class UIUtil extends StartupUiUtil { return GrayFilter.namedFilter("text.grayFilter", new GrayFilter(20, 0, 100)); } + public static boolean isMinimized(Window window) { + if (!(window instanceof Frame)) return false; + Frame frame = (Frame)window; + return frame.getExtendedState() == Frame.ICONIFIED; + } + @ApiStatus.Experimental public static class GrayFilter extends RGBImageFilter { private float brightness;