mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
IDEA-344769 Account for invisible insets for tool window floating bounds
Now that we have a separate property for external decorator bounds, implement it for both decorators to account for invisible insets. As there seems to be no API for getting those invisible insets, we use guesswork: the top inset is usually the window header, and it's visible; the other insets are usually invisible drag zones. Insets aren't available until the window is connected to an actual display (the peer is created), so the new property will work incorrectly before the window is shown for the first time, but thankfully we already have a helper class to fix the insets after the window is shown, so it works as expected, even though it's still a dirty hack and not a proper fix. GitOrigin-RevId: efd75de13d070a6873bda05898803cc533259194
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e1c49b476b
commit
057fe7af19
@@ -18,6 +18,7 @@ import com.intellij.ui.*;
|
||||
import com.intellij.ui.paint.LinePainter2D;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.MathUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import kotlin.Unit;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -200,13 +201,17 @@ public final class FloatingDecorator extends JDialog implements FloatingDecorato
|
||||
@NotNull
|
||||
@Override
|
||||
public Rectangle getVisibleWindowBounds() {
|
||||
return getBounds();
|
||||
var result = getBounds();
|
||||
JBInsets.removeFrom(result, ToolWindowExternalDecoratorKt.getInvisibleInsets(this));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibleWindowBounds(@NotNull Rectangle r) {
|
||||
myBoundsHelper.setBounds(r);
|
||||
super.setBounds(r);
|
||||
var newBounds = new Rectangle(r);
|
||||
JBInsets.addTo(newBounds, ToolWindowExternalDecoratorKt.getInvisibleInsets(this));
|
||||
super.setBounds(newBounds);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.wm.ToolWindowType
|
||||
import com.intellij.openapi.wm.WindowInfo
|
||||
import java.awt.Component
|
||||
import java.awt.Insets
|
||||
import java.awt.Rectangle
|
||||
import java.awt.Window
|
||||
|
||||
@@ -32,3 +33,7 @@ internal interface ToolWindowExternalDecorator {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal val Window.invisibleInsets: Insets
|
||||
// guesswork: the top inset is typically visible (window header), others are typically invisible drag zones
|
||||
get() = insets.apply { top = 0 }
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.openapi.wm.WindowInfo
|
||||
import com.intellij.openapi.wm.impl.ToolWindowExternalDecorator.Companion.DECORATOR_PROPERTY
|
||||
import com.intellij.toolWindow.InternalDecoratorImpl
|
||||
import com.intellij.ui.ClientProperty
|
||||
import com.intellij.util.ui.JBInsets
|
||||
import java.awt.Component
|
||||
import java.awt.Rectangle
|
||||
import java.awt.Window
|
||||
@@ -71,10 +72,16 @@ internal class WindowedDecorator(
|
||||
}
|
||||
|
||||
override var visibleWindowBounds: Rectangle
|
||||
get() = getFrame().bounds
|
||||
get() {
|
||||
val result = getFrame().bounds
|
||||
JBInsets.removeFrom(result, getFrame().invisibleInsets)
|
||||
return result
|
||||
}
|
||||
set(value) {
|
||||
boundsHelper.bounds = value
|
||||
getFrame().bounds = value
|
||||
val newBounds = Rectangle(value)
|
||||
JBInsets.addTo(newBounds, getFrame().invisibleInsets)
|
||||
getFrame().bounds = newBounds
|
||||
}
|
||||
|
||||
override fun log(): Logger = LOG
|
||||
|
||||
Reference in New Issue
Block a user