mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
get rid of class casts to IdeFrameEx (part 1): move isInFullScreen to IdeFrame
isInFullScreen is a light method — returns boolean. GitOrigin-RevId: e793d5d5c562a8fec5d1deb38196df231bfd756e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
90e0f0d2be
commit
de75ce1609
@@ -31,7 +31,6 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.wm.*;
|
||||
import com.intellij.openapi.wm.ex.IdeFrameEx;
|
||||
import com.intellij.openapi.wm.impl.IdeFrameImpl;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -160,13 +159,9 @@ public class NewProjectUtil {
|
||||
ProjectUtil.updateLastProjectLocation(projectFilePath);
|
||||
|
||||
if (WindowManager.getInstance().isFullScreenSupportedInCurrentOS()) {
|
||||
IdeFocusManager instance = IdeFocusManager.findInstance();
|
||||
IdeFrame lastFocusedFrame = instance.getLastFocusedFrame();
|
||||
if (lastFocusedFrame instanceof IdeFrameEx) {
|
||||
boolean fullScreen = ((IdeFrameEx)lastFocusedFrame).isInFullScreen();
|
||||
if (fullScreen) {
|
||||
newProject.putUserData(IdeFrameImpl.SHOULD_OPEN_IN_FULL_SCREEN, Boolean.TRUE);
|
||||
}
|
||||
IdeFrame lastFocusedFrame = IdeFocusManager.findInstance().getLastFocusedFrame();
|
||||
if (lastFocusedFrame != null && lastFocusedFrame.isInFullScreen()) {
|
||||
newProject.putUserData(IdeFrameImpl.SHOULD_OPEN_IN_FULL_SCREEN, Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -6,10 +6,9 @@ import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.ui.AppUIUtil;
|
||||
import com.intellij.ui.ComponentUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -17,7 +16,7 @@ public abstract class AbstractTraverseWindowAction extends AnAction {
|
||||
|
||||
protected void doPerform(@NotNull Function<? super Window, ? extends Window> mapWindow) {
|
||||
Window w = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow();
|
||||
if (!w.isVisible() || UIUtil.isMinimized(w) || AppUIUtil.isInFullscreen(w)) return;
|
||||
if (!w.isVisible() || ComponentUtil.isMinimized(w) || AppUIUtil.isInFullscreen(w)) return;
|
||||
if (!IdeEventQueue.getInstance().isTheCurrentWindowOnTheActivatedList(w)) return;
|
||||
Window window = mapWindow.fun(w);
|
||||
Component recentFocusOwner = window.getMostRecentFocusOwner();
|
||||
|
||||
@@ -27,6 +27,10 @@ public interface IdeFrame {
|
||||
@Nullable
|
||||
BalloonLayout getBalloonLayout();
|
||||
|
||||
default boolean isInFullScreen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
interface Child extends IdeFrame {
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,6 @@ 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.AppUIUtil;
|
||||
@@ -88,7 +87,7 @@ public final class IdeEventQueue extends EventQueue {
|
||||
public static void updateActivatedWindowSet() {
|
||||
for (Iterator<Window> iter = activatedWindows.iterator(); iter.hasNext(); ) {
|
||||
Window window = iter.next();
|
||||
if (!window.isVisible() || UIUtil.isMinimized(window) || AppUIUtil.isInFullscreen(window)) {
|
||||
if (!window.isVisible() || ComponentUtil.isMinimized(window) || AppUIUtil.isInFullscreen(window)) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.intellij.openapi.ui.popup.IdePopupEventDispatcher;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.wm.ex.IdeFrameEx;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -57,8 +57,8 @@ public final class IdePopupManager implements IdeEventQueue.EventDispatcher {
|
||||
shouldCloseAllPopup = true;
|
||||
}
|
||||
|
||||
if (!shouldCloseAllPopup && ultimateParentForEventWindow instanceof IdeFrameEx) {
|
||||
IdeFrameEx ultimateParentWindowForEvent = (IdeFrameEx)ultimateParentForEventWindow;
|
||||
if (!shouldCloseAllPopup && ultimateParentForEventWindow instanceof IdeFrame) {
|
||||
IdeFrame ultimateParentWindowForEvent = (IdeFrame)ultimateParentForEventWindow;
|
||||
if (ultimateParentWindowForEvent.isInFullScreen()
|
||||
&& !ultimateParentForFocusedComponent.equals(ultimateParentForEventWindow)) {
|
||||
shouldCloseAllPopup = true;
|
||||
|
||||
@@ -14,8 +14,6 @@ import java.io.File;
|
||||
public interface IdeFrameEx extends IdeFrame {
|
||||
void setFileTitle(String fileTitle, File ioFile);
|
||||
|
||||
boolean isInFullScreen();
|
||||
|
||||
@NotNull
|
||||
Promise<?> toggleFullScreen(boolean state);
|
||||
|
||||
|
||||
@@ -135,6 +135,7 @@ public final class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider
|
||||
return (SystemInfo.isMac && isInFullScreen()) ? JBUI.emptyInsets() : super.getInsets();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInFullScreen() {
|
||||
return myFrameDecorator != null && myFrameDecorator.isInFullScreen();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.ex.IdeFrameEx;
|
||||
import com.intellij.openapi.wm.impl.status.ClockPanel;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.Gray;
|
||||
@@ -197,8 +196,8 @@ public class IdeMenuBar extends JMenuBar implements IdeEventQueue.EventDispatche
|
||||
private void updateState() {
|
||||
if (myAnimator != null) {
|
||||
Window window = SwingUtilities.getWindowAncestor(this);
|
||||
if (window instanceof IdeFrameEx) {
|
||||
boolean fullScreen = ((IdeFrameEx)window).isInFullScreen();
|
||||
if (window instanceof IdeFrame) {
|
||||
boolean fullScreen = ((IdeFrame)window).isInFullScreen();
|
||||
if (fullScreen) {
|
||||
setState(State.COLLAPSING);
|
||||
restartAnimator();
|
||||
@@ -602,9 +601,9 @@ public class IdeMenuBar extends JMenuBar implements IdeEventQueue.EventDispatche
|
||||
private MyExitFullScreenButton() {
|
||||
setFocusable(false);
|
||||
addActionListener(e -> {
|
||||
Window window = SwingUtilities.getWindowAncestor(this);
|
||||
if (window instanceof IdeFrameEx) {
|
||||
((IdeFrameEx)window).toggleFullScreen(false);
|
||||
ProjectFrameHelper frameHelper = ProjectFrameHelper.getFrameHelper(SwingUtilities.getWindowAncestor(this));
|
||||
if (frameHelper != null) {
|
||||
frameHelper.toggleFullScreen(false);
|
||||
}
|
||||
});
|
||||
addMouseListener(new MouseAdapter() {
|
||||
|
||||
@@ -25,8 +25,8 @@ import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.openapi.wm.ex.IdeFrameEx;
|
||||
import com.intellij.ui.AppIcon.MacAppIcon;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.ui.scale.JBUIScale;
|
||||
@@ -601,9 +601,7 @@ public final class AppUIUtil {
|
||||
AWTAccessor.getComponentAccessor().setGraphicsConfiguration(comp, gc);
|
||||
}
|
||||
|
||||
public static boolean isInFullscreen (Window window) {
|
||||
if (!(window instanceof IdeFrameEx)) return false;
|
||||
IdeFrameEx ideFrameEx = (IdeFrameEx) window;
|
||||
return ideFrameEx.isInFullScreen();
|
||||
public static boolean isInFullscreen(@Nullable Window window) {
|
||||
return window instanceof IdeFrame && ((IdeFrame)window).isInFullScreen();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,15 @@ import java.awt.*;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public final class ComponentUtil {
|
||||
public static boolean isMinimized(@Nullable Window window) {
|
||||
if (!(window instanceof Frame)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Frame frame = (Frame)window;
|
||||
return frame.getExtendedState() == Frame.ICONIFIED;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Component findUltimateParent(@NotNull Component c) {
|
||||
Component eachParent = c;
|
||||
|
||||
@@ -262,12 +262,6 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user