diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java index 883250bf3442..52f7509a082b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java @@ -59,6 +59,8 @@ import javax.swing.*; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.io.File; /** @@ -118,6 +120,48 @@ public class IdeFrameImpl extends JFrame implements IdeFrameEx, DataProvider { MouseGestureManager.getInstance().add(this); myFrameDecorator = IdeFrameDecorator.decorate(this); + addWindowStateListener(new WindowAdapter() { + @Override + public void windowStateChanged(WindowEvent e) { + updateBorder(); + } + }); + Toolkit.getDefaultToolkit().addPropertyChangeListener("win.xpstyle.themeActive", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + updateBorder(); + } + }); + } + + private void updateBorder() { + int state = getExtendedState(); + if (!WindowManager.getInstance().isFullScreenSupportedInCurrentOS() || !SystemInfo.isWindows) { + return; + } + + boolean isNotClassic = Boolean.parseBoolean(String.valueOf(Toolkit.getDefaultToolkit().getDesktopProperty("win.xpstyle.themeActive"))); + if (isNotClassic && (state & MAXIMIZED_BOTH) != 0) { + IdeFrame[] projectFrames = WindowManager.getInstance().getAllProjectFrames(); + GraphicsDevice device = ScreenUtil.getScreenDevice(getBounds()); + + for (IdeFrame frame : projectFrames) { + if (frame == this) continue; + if (((IdeFrameImpl)frame).isInFullScreen() && ScreenUtil.getScreenDevice(((IdeFrameImpl)frame).getBounds()) == device) { + Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(device.getDefaultConfiguration()); + int mask = SideBorder.NONE; + if (insets.top != 0) mask |= SideBorder.TOP; + if (insets.left != 0) mask |= SideBorder.LEFT; + if (insets.bottom != 0) mask |= SideBorder.BOTTOM; + if (insets.right != 0) mask |= SideBorder.RIGHT; + myRootPane.setBorder(new SideBorder(JBColor.BLACK, mask, false, 3)); + break; + } + } + } + else { + myRootPane.setBorder(null); + } } protected IdeRootPane createRootPane(ActionManagerEx actionManager, diff --git a/platform/util/src/com/intellij/ui/SideBorder.java b/platform/util/src/com/intellij/ui/SideBorder.java index 28637482fb49..760ff2143a31 100644 --- a/platform/util/src/com/intellij/ui/SideBorder.java +++ b/platform/util/src/com/intellij/ui/SideBorder.java @@ -42,7 +42,11 @@ public class SideBorder extends LineBorder { } public SideBorder(Color color, @SideMask int mask, boolean dotted) { - super(color, 1); + this(color, mask, dotted, 1); + } + + public SideBorder(Color color, @SideMask int mask, boolean dotted, int thickness) { + super(color, thickness); mySideMask = mask; myDotted = dotted; } @@ -73,16 +77,16 @@ public class SideBorder extends LineBorder { g.setColor(getLineColor()); for(int i = 0; i < getThickness(); i++){ if ((mySideMask & LEFT) != 0){ - drawLine(g, x + i, y + i, x + i, y + height - i - i - 1); + drawLine(g, x + i, y, x + i, y + height - 1); } if ((mySideMask & TOP) != 0){ - drawLine(g, x + i, y + i, x + width - i - i - 1, y + i); + drawLine(g, x, y + i, x + width - 1, y + i); } if ((mySideMask & RIGHT) != 0){ - drawLine(g, x + width - i - i - 1, y + i, x + width - i - i - 1, y + height - i - i - 1); + drawLine(g, x + width - 1 - i, y, x + width - 1 - i, y + height - 1); } if ((mySideMask & BOTTOM) != 0){ - drawLine(g, x + i, y + height - i - i - 1, x + width - i - i - 1, y + height - i - i - 1); + drawLine(g, x, y + height - 1 - i, x + width - 1, y + height - 1 - i); } } g.setColor(oldColor);