JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.17k stars 1.11k forks source link

When the window width is adjusted, the width of the Button component also scales along with the container. #4521

Closed uiexp closed 1 month ago

uiexp commented 2 months ago

Describe the bug When the window width is adjusted, the width of the Button component also scales along with the container.

Affected platforms

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior:

fun main() = application {
    Window(
        onCloseRequest = ::exitApplication, title = "MultiDesk"
    ) {

        MaterialTheme {
            Surface(color = MaterialTheme.colors.background) {
                Row {
                    Button(onClick = {}) {
                        Text("test")
                    }
                    Button(onClick = {}) {
                        Text("test")
                    }
                }
            }

        }

    }
}

Adjust window width after running

m-sasha commented 2 months ago

Could you provide a screen recording and the full source code (include imports)? This doesn't reproduce on my Mac, but there's nothing here that is OS-specific.

https://github.com/JetBrains/compose-multiplatform/assets/5230206/b9808547-eadc-4fa3-8c36-aec6824b4b11

uiexp commented 2 months ago

I'm running on Windows 10. This is a video recording. I'll test on Mac later.

libs.versions.toml [versions] compose = "1.6.2" compose-plugin = "1.6.1" junit = "4.13.2" kotlin = "1.9.23"

https://github.com/JetBrains/compose-multiplatform/assets/1586326/7d0bdaac-34b6-487a-9ca9-86a5fb9f0f08

changhexuefei commented 2 months ago

The following is the performance of the above code on Windows 11.

https://github.com/JetBrains/compose-multiplatform/assets/19502034/c79cfa22-98e3-471f-96c0-8dac2434ced5

m-sasha commented 2 months ago

This is a problem at the level of skiko and seems to be the result of how we tell Windows to scale the contents of the window until we update the picture here.

There's no easy fix for this. We could tell Windows not to stretch the picture, but then you'd probably see black bars when resizing. The real fix would be to make sure we update the picture before the next screen refresh.

uiexp commented 2 months ago

This is a problem at the level of skiko and seems to be the result of how we tell Windows to scale the contents of the window until we update the picture here.

There's no easy fix for this. We could tell Windows not to stretch the picture, but then you'd probably see black bars when resizing. The real fix would be to make sure we update the picture before the next screen refresh.

Thank you for your answer. I hope it can be optimized!

MatkovIvan commented 1 month ago

Found issues about "black bars" instead of streaching - #2925 It's essentially the same, so let's track it there