public void setFullScreen(IdeFrameImpl frame, boolean fullScreen) { if (!isFullScreenSupportedInCurrentOS() || frame.isInFullScreen() == fullScreen) return; try { if (SystemInfo.isMacOSLion) { frame.getFrameDecorator().toggleFullScreen(fullScreen); return; } if (SystemInfo.isWindows) { GraphicsDevice device = ScreenUtil.getScreenDevice(frame.getBounds()); if (device == null) return; try { frame.getRootPane().putClientProperty(ScreenUtil.DISPOSE_TEMPORARY, Boolean.TRUE); if (fullScreen) { frame.getRootPane().putClientProperty("oldBounds", frame.getBounds()); } frame.dispose(); frame.setUndecorated(fullScreen); } finally { if (fullScreen) { frame.setBounds(device.getDefaultConfiguration().getBounds()); } else { Object o = frame.getRootPane().getClientProperty("oldBounds"); if (o instanceof Rectangle) { frame.setBounds((Rectangle) o); } } frame.setVisible(true); frame.getRootPane().putClientProperty(ScreenUtil.DISPOSE_TEMPORARY, null); } } } finally { frame.storeFullScreenStateIfNeeded(fullScreen); } }
public final void writeExternal(final Element element) { // Save frame bounds final Element frameElement = new Element(FRAME_ELEMENT); element.addContent(frameElement); final Project[] projects = ProjectManager.getInstance().getOpenProjects(); final Project project; if (projects.length > 0) { project = projects[projects.length - 1]; } else { project = null; } final IdeFrameImpl frame = getFrame(project); if (frame != null) { int extendedState = frame.getExtendedState(); if (SystemInfo.isMacOSLion && frame.getPeer() instanceof FramePeer) { // frame.state is not updated by jdk so get it directly from peer extendedState = ((FramePeer) frame.getPeer()).getState(); } boolean usePreviousBounds = extendedState == Frame.MAXIMIZED_BOTH || isFullScreenSupportedInCurrentOS() && WindowManagerEx.getInstanceEx().isFullScreen(frame); Rectangle rectangle = usePreviousBounds ? myFrameBounds : frame.getBounds(); if (rectangle == null) { // frame is out of the screen? rectangle = ScreenUtil.getScreenRectangle(0, 0); } frameElement.setAttribute(X_ATTR, Integer.toString(rectangle.x)); frameElement.setAttribute(Y_ATTR, Integer.toString(rectangle.y)); frameElement.setAttribute(WIDTH_ATTR, Integer.toString(rectangle.width)); frameElement.setAttribute(HEIGHT_ATTR, Integer.toString(rectangle.height)); frameElement.setAttribute(EXTENDED_STATE_ATTR, Integer.toString(extendedState)); // Save default layout final Element layoutElement = new Element(DesktopLayout.TAG); element.addContent(layoutElement); myLayout.writeExternal(layoutElement); } }