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 adding external components to ComposePanel #1214

Draft
wants to merge 1 commit into
base: jb-main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
Expand Up @@ -183,7 +183,7 @@ public fun <T : Component> SwingPanel(
* @param key The unique identifier for the panel container.
* @param focusComponent The component that should receive focus.
*/
private class SwingPanelContainer(
internal class SwingPanelContainer(
key: Int,
private val focusComponent: Component
): JPanel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.ui.ComposeFeatureFlags
import androidx.compose.ui.awt.AwtEventListener
import androidx.compose.ui.awt.OnlyValidPrimaryMouseButtonFilter
import androidx.compose.ui.awt.SwingInteropContainer
import androidx.compose.ui.awt.SwingPanelContainer
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.geometry.Offset
Expand Down Expand Up @@ -155,6 +156,10 @@ internal class ComposeSceneMediator(

override fun componentAdded(e: ContainerEvent) {
val component = e.child
if (component !is SwingPanelContainer) {
Copy link
Collaborator

@igordmn igordmn Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you describe the issue? I thought that this method is supposed to work for all components, not only for SwingPanelContainer. Don't we need addClipComponent and subscribeToMouseEvents for them?

Copy link
Collaborator

@igordmn igordmn Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test would be helpful for understanding

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was fixed a while ago, so I decided to make PR to not forget about it. Converted to draft for now - I'll document/test-cover it once I have time

// It means that some external component was added to [ComposePanel]
return
}
if (useInteropBlending) {
// In case of interop blending, compose might draw content above this [component].
// But due to implementation of [JLayeredPane]'s lightweight/heavyweight mixing
Expand Down
Loading