Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interop initial z-order placement on Windows #1774

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -131,25 +131,6 @@ internal class SwingInteropContainer(

private val scheduledUpdatesSwapchain = ScheduledUpdatesSwapchain(requestRedraw)

/**
* Index of last interop component in [root].
*
* [ComposeSceneMediator] might keep extra components in the same container.
* So based on [placeInteropAbove] they should go below or under all interop views.
*
* @see ComposeSceneMediator.contentComponent
* @see ComposeSceneMediator.invisibleComponent
*/
private val lastInteropIndex: Int
get() {
var lastInteropIndex = interopComponents.size - 1
if (!placeInteropAbove) {
val nonInteropComponents = root.componentCount - interopComponents.size
lastInteropIndex += nonInteropComponents
}
return lastInteropIndex
}

override fun contains(holder: InteropViewHolder): Boolean =
interopComponents.contains(holder.group)

@@ -168,6 +149,10 @@ internal class SwingInteropContainer(
snapshotObserver.start()
}

// [ComposeSceneMediator] might keep extra components in the same container.
// Reed it before modifying both [interopComponents] and [root] to get consistent result
val nonInteropComponents = root.componentCount - interopComponents.size

// Add this component to [interopComponents] to track count and clip rects
val alreadyAdded = group in interopComponents
if (!alreadyAdded) {
@@ -177,6 +162,13 @@ internal class SwingInteropContainer(
// Iterate through a Compose layout tree in draw order and count interop view below this one
val countBelow = countInteropComponentsBelow(holder)

// Index of last interop component in [root]
var lastInteropIndex = interopComponents.size - 1
// Based on [placeInteropAbove] interop views should go below or under all interop views
if (!placeInteropAbove) {
lastInteropIndex += nonInteropComponents
}

// AWT/Swing uses the **REVERSE ORDER** for drawing and events
val awtIndex = lastInteropIndex - countBelow