Skip to content

Commit

Permalink
Update WindowInfo.containerSize on both window and container resizes.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-sasha committed Apr 30, 2024
1 parent 2414ff1 commit 161fa84
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,14 @@ internal class ComposeContainer(
}

/**
* The listener to [_windowContainer] size and position changes.
* The listener to [windowContainer] size and position changes.
*/
private val windowContainerComponentListener = object : ComponentAdapter() {
override fun componentResized(e: ComponentEvent?) {
if (!container.isDisplayable) return

mediator.onChangeComponentSize()
windowContext.setContainerSize(this@ComposeContainer.windowContainer.sizeInPx)

// Sometimes Swing displays interop views in incorrect order after resizing,
// so we need to force re-validate it.
Expand Down Expand Up @@ -243,7 +244,11 @@ internal class ComposeContainer(
private fun onChangeWindowSize() {
if (!container.isDisplayable) return

// When the window is moved to a display with a different density, componentResized will
// be called on the window, but not on `windowContainer`, so we need to update the size here
// too.
windowContext.setContainerSize(windowContainer.sizeInPx)

layers.fastForEach(DesktopComposeSceneLayer::onChangeWindowSize)
}

Expand Down

0 comments on commit 161fa84

Please sign in to comment.