From b478a4dc367b828ef98c7b705fbbbf37a19aacfd Mon Sep 17 00:00:00 2001 From: Sergei Tachenov Date: Fri, 29 Mar 2024 11:18:33 +0200 Subject: [PATCH] IDEA-317864 Fix coordinate checks in SimpleToolWindowPanel The top/left insets weren't taken into account: the toolbar height isn't always the same as its bottom-edge coordinate. Get its bounds and convert them to the panel's coordinate system to make code more generic and layout-agnostic. This also factors in the insets automatically. Use case: the Remote Host tool window, it has a top border on the panel. GitOrigin-RevId: 04574d8a0f2b64a08e012fa600023e9b6891b971 --- .../src/com/intellij/openapi/ui/SimpleToolWindowPanel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/SimpleToolWindowPanel.java b/platform/platform-api/src/com/intellij/openapi/ui/SimpleToolWindowPanel.java index 17a42d294335..1931570b35f5 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/SimpleToolWindowPanel.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/SimpleToolWindowPanel.java @@ -257,7 +257,8 @@ public class SimpleToolWindowPanel extends JBPanelWithEmptyText implements Quick if (toolbar == null || !toolbar.isVisible() || !component.isShowing()) { return false; } - var expectedCoordinate = (myVertical ? toolbar.getHeight() : toolbar.getWidth()) + GAP; + var toolbarBounds = SwingUtilities.convertRectangle(toolbar.getParent(), toolbar.getBounds(), this); + var expectedCoordinate = (myVertical ? toolbarBounds.y + toolbarBounds.height : toolbarBounds.x + toolbarBounds.width) + GAP; var paneLocation = SwingUtilities.convertPoint(component.getParent(), component.getLocation(), this); var actualCoordinate = myVertical ? paneLocation.y : paneLocation.x; return expectedCoordinate == actualCoordinate;