Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Fix fake windows positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
ARTI1208 committed Mar 22, 2022
1 parent 9570b86 commit 0e94b8f
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.jetbrains.projector.awt.peer.PComponentPeer
import org.jetbrains.projector.awt.peer.PDesktopPeer
import org.jetbrains.projector.awt.peer.PMouseInfoPeer
import org.jetbrains.projector.common.misc.Do
import org.jetbrains.projector.common.protocol.data.CommonRectangle
import org.jetbrains.projector.common.protocol.data.ImageData
import org.jetbrains.projector.common.protocol.data.ImageId
import org.jetbrains.projector.common.protocol.data.UserKeymap
Expand Down Expand Up @@ -301,7 +302,7 @@ class ProjectorServer private constructor(
icons = window.icons?.map { it as ImageId },
isShowing = window.target.isShowing,
zOrder = i,
bounds = window.target.shiftBounds(PGraphicsEnvironment.defaultDevice.clientShift),
bounds = window.shifted(),
headerHeight = window.headerHeight,
cursorType = window.cursor?.type?.toCursorType(),
resizable = window.resizable,
Expand Down Expand Up @@ -872,6 +873,15 @@ class ProjectorServer private constructor(
}
}

private fun PWindow.shifted(): CommonRectangle {
val shift = when {
isFakeWindow -> SwingUtilities.getWindowAncestor(target)?.insets?.let { java.awt.Point(it.left, it.top) } ?: java.awt.Point()
else -> PGraphicsEnvironment.defaultDevice.clientShift
}

return bounds.shift(shift)
}

private fun resize(width: Int, height: Int) {
val ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
if (ge is PGraphicsEnvironment) {
Expand Down

0 comments on commit 0e94b8f

Please sign in to comment.