diff --git a/platform/platform-api/src/com/intellij/ui/ScreenUtil.java b/platform/platform-api/src/com/intellij/ui/ScreenUtil.java index 712e9e8bbc5b..8b97f964aeaf 100644 --- a/platform/platform-api/src/com/intellij/ui/ScreenUtil.java +++ b/platform/platform-api/src/com/intellij/ui/ScreenUtil.java @@ -77,6 +77,39 @@ public class ScreenUtil { return area; } + /** + * Returns the smallest rectangle that encloses a visible area of every screen. + * + * @return the smallest rectangle that encloses a visible area of every screen + */ + public static Rectangle getAllScreensRectangle() { + GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); + int minX = 0; + int maxX = 0; + int minY = 0; + int maxY = 0; + for (GraphicsDevice device : devices) { + Rectangle rectangle = getScreenRectangle(device); + int x = rectangle.x; + if (minX > x) { + minX = x; + } + x += rectangle.width; + if (maxX < x) { + maxX = x; + } + int y = rectangle.y; + if (minY > y) { + minY = y; + } + y += rectangle.height; + if (maxY < y) { + maxY = y; + } + } + return new Rectangle(minX, minY, maxX - minX, maxY - minY); + } + public static Rectangle getScreenRectangle(@NotNull Point p) { return getScreenRectangle(p.x, p.y); } 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 6a326f1a70d4..de1790b6dee2 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 @@ -225,7 +225,7 @@ public final class WindowManagerImpl extends WindowManagerEx implements NamedCom @Override public final Rectangle getScreenBounds() { - return ScreenUtil.getAllScreensShape().getBounds(); + return ScreenUtil.getAllScreensRectangle(); } @Override diff --git a/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java b/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java index ce24352c953f..353e0878e1b1 100644 --- a/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java +++ b/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java @@ -301,10 +301,18 @@ public abstract class AbstractExpandableItemsHandler visMaxY) return null; + + int cellMaxX = cellBounds.x + cellBounds.width; + int visMaxX = visibleRect.x + visibleRect.width; + + Point location = new Point(visMaxX, cellBounds.y); + SwingUtilities.convertPointToScreen(location, myComponent); + + Rectangle screen = !Registry.is("ide.expansion.hints.on.all.screens") + ? ScreenUtil.getScreenRectangle(location) + : ScreenUtil.getAllScreensRectangle(); + + int width = Math.min(screen.width + screen.x - location.x, cellMaxX - visMaxX); int height = cellBounds.height; if (width <= 0 || height <= 0) return null; - if (cellBounds.y < visibleRect.y) return null; - if (cellBounds.y + cellBounds.height > visibleRect.y + visibleRect.height) return null; Dimension size = getImageSize(width, height); myImage = UIUtil.createImage(size.width, size.height, BufferedImage.TYPE_INT_RGB); @@ -401,10 +393,9 @@ public abstract class AbstractExpandableItemsHandler