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

Do not revalidate window after resizing. #1565

Merged
merged 1 commit into from
Sep 16, 2024

Conversation

m-sasha
Copy link
Member

@m-sasha m-sasha commented Sep 16, 2024

This revalidation was added in #442, but that problem no longer reproduces.

I'm not really sure why this revalidation causes Resizing the window using WindowState breaks the UI, but it doesn't appear to be needed.

Fixes https://youtrack.jetbrains.com/issue/CMP-6550/Resizing-the-window-using-WindowState-breaks-the-UI

Testing

Tested manually with

@OptIn(ExperimentalComposeUiApi::class)
fun main() {
    application {
        val state = rememberWindowState()
        var value by remember { mutableStateOf(0) }

        Window(onCloseRequest = ::exitApplication, state = state, undecorated = true) {
            Box(Modifier.fillMaxSize().background(Color.Yellow)) {
                Box(
                    contentAlignment = Alignment.Center,
                    modifier = Modifier.size(200.dp).offset(x = 10.dp, y = 10.dp).background(Color.Red)
                ) {
                    val windowInfo = LocalWindowInfo.current
                    Column(horizontalAlignment = Alignment.CenterHorizontally) {
                        Text("$value")
                        Text("${windowInfo.containerSize}")
                    }
                }
            }

            LaunchedEffect(Unit) {
                while (true) {
                    state.size = DpSize(700.dp, 500.dp)
                    value += 1
                    delay(DELAY)
                    state.size = DpSize(800.dp, 600.dp)
                    value += 1
                    delay(DELAY)
                }
            }
        }
    }
}

const val DELAY = 300L

This could be tested by QA

Release Notes

Fixes - Desktop

  • Fix UI glitch when resizing a Compose window via its WindowState.

@m-sasha m-sasha merged commit 13c6cad into jb-main Sep 16, 2024
5 of 6 checks passed
@m-sasha m-sasha deleted the m-sasha/fix-position-glitch-on-window-resize branch September 16, 2024 16:32
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