diff --git a/platform/platform-api/src/com/intellij/ui/ScreenUtil.java b/platform/platform-api/src/com/intellij/ui/ScreenUtil.java index 456282c1cc0e..65570b83dd67 100644 --- a/platform/platform-api/src/com/intellij/ui/ScreenUtil.java +++ b/platform/platform-api/src/com/intellij/ui/ScreenUtil.java @@ -24,6 +24,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; +import java.awt.geom.Area; import java.util.Map; /** @@ -79,6 +80,15 @@ public class ScreenUtil { return result; } + public static Shape getAllScreensShape() { + Rectangle[] rectangles = getAllScreenBounds(); + Area area = new Area(); + for (Rectangle rectangle : rectangles) { + area.add(new Area(rectangle)); + } + return area; + } + public static Rectangle getScreenRectangle(@NotNull Point p) { double distance = -1; Rectangle answer = null; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java index 03cc488f45df..36012ed2c66a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java @@ -98,11 +98,6 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat private final EventDispatcher myEventDispatcher = EventDispatcher.create(WindowManagerListener.class); - /** - * Union of bounds of all available default screen devices. - */ - private final Rectangle myScreenBounds; - private final CommandProcessor myCommandProcessor; private final WindowWatcher myWindowWatcher; /** @@ -164,18 +159,6 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat myDialogsToDispose = new HashMap>(); myFrameExtendedState = Frame.NORMAL; - // Calculate screen bounds. - - Rectangle screenBounds = new Rectangle(); - if (!application.isHeadlessEnvironment()) { - final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); - final GraphicsDevice[] devices = env.getScreenDevices(); - for (final GraphicsDevice device : devices) { - screenBounds = screenBounds.union(device.getDefaultConfiguration().getBounds()); - } - } - myScreenBounds = screenBounds; - myActivationListener = new WindowAdapter() { @Override public void windowActivated(WindowEvent e) { @@ -245,7 +228,7 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat @Override public final Rectangle getScreenBounds() { - return myScreenBounds; + return ScreenUtil.getAllScreensShape().getBounds(); } @Override @@ -265,16 +248,12 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat @Override public final boolean isInsideScreenBounds(final int x, final int y, final int width) { - return - x >= myScreenBounds.x + 50 - width && - y >= myScreenBounds.y - 50 && - x <= myScreenBounds.x + myScreenBounds.width - 50 && - y <= myScreenBounds.y + myScreenBounds.height - 50; + return ScreenUtil.getAllScreensShape().contains(x, y, width, 1); } @Override public final boolean isInsideScreenBounds(final int x, final int y) { - return myScreenBounds.contains(x, y); + return ScreenUtil.getAllScreensShape().contains(x, y); } @Override