Skip to content

Comments

Register mouse wheel listeners on the container rather than the compose content#2486

Merged
m-sasha merged 5 commits intojb-mainfrom
m-sasha/fix-swing-panel-scrolling
Oct 29, 2025
Merged

Register mouse wheel listeners on the container rather than the compose content#2486
m-sasha merged 5 commits intojb-mainfrom
m-sasha/fix-swing-panel-scrolling

Conversation

@m-sasha
Copy link

@m-sasha m-sasha commented Oct 15, 2025

The container is the common parent of the compose content (skia layer) and the interop views. This is needed to receive them even when they occur over an interop view.

Fixes https://youtrack.jetbrains.com/issue/CMP-1062/SwingPanel-breaks-vertical-scrolling

In WindowInputEventTest.receive buttons and modifiers I changed the check from exactly matching the keyboard modifiers to verifying that the expected modifiers are on. Because of a problem in AWT.

Testing

Tested manually and added a unit tests.

fun main() = singleWindowApplication {
    val scrollState = rememberScrollState()
    Box(
        modifier = Modifier
            .fillMaxSize()
            .verticalScroll(scrollState)
    ) {
        Row(Modifier.fillMaxSize().height(2000.dp)) {
            SwingPanel(
                background = Color.Red,
                modifier = Modifier
                    .weight(1f)
                    .height(400.dp),
                factory = {
                    JPanel(BorderLayout()).also {
                        it.add(JLabel("Swing content"))
                    }
                },
            )
            Box(
                Modifier.weight(1f).height(400.dp).background(Color.Blue),
                contentAlignment = Alignment.Center
            ) {
                Text("Compose content")
            }
            VerticalScrollbar(
                modifier = Modifier.fillMaxHeight(),
                adapter = rememberScrollbarAdapter(scrollState)
            )
        }
    }
}

This should be tested by QA

Release Notes

Fixes - Desktop

  • Fix SwingPanel blocking mouse wheel scroll events from going to its parent.

@m-sasha m-sasha force-pushed the m-sasha/fix-swing-panel-scrolling branch from 4c825c6 to b3246fd Compare October 22, 2025 10:20
@m-sasha m-sasha changed the base branch from jb-main to m-sasha/fix-flaky-tests October 22, 2025 10:42
@m-sasha m-sasha force-pushed the m-sasha/fix-swing-panel-scrolling branch from b3246fd to 278e327 Compare October 22, 2025 11:35
@MatkovIvan MatkovIvan force-pushed the m-sasha/fix-flaky-tests branch from d50c500 to ef7982d Compare October 22, 2025 11:50
@m-sasha m-sasha changed the base branch from m-sasha/fix-flaky-tests to jb-main October 22, 2025 11:57
@m-sasha m-sasha force-pushed the m-sasha/fix-swing-panel-scrolling branch from 278e327 to 63456d7 Compare October 23, 2025 08:58
@m-sasha m-sasha changed the title [WIP] Register mouse wheel listeners on the container rather than the compose content Register mouse wheel listeners on the container rather than the compose content Oct 23, 2025
…pose content and interop views) to receive them even when they occur over an interop view.
@m-sasha m-sasha force-pushed the m-sasha/fix-swing-panel-scrolling branch from 63456d7 to f97407a Compare October 28, 2025 12:31
@m-sasha m-sasha requested a review from MatkovIvan October 28, 2025 12:33
@m-sasha m-sasha requested a review from MatkovIvan October 29, 2025 09:23
@m-sasha m-sasha merged commit 0ea0532 into jb-main Oct 29, 2025
16 checks passed
@m-sasha m-sasha deleted the m-sasha/fix-swing-panel-scrolling branch October 29, 2025 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants