When I'm in darkmode, and I resize the window quic...
# compose-desktop
u
When I'm in darkmode, and I resize the window quickly, it seems that the compose ui is not keeping up & I'm seeing flashes of the "window" underneath. Am I doing something wrong?
Copy code
fun main(args: Array<String>) {
    singleWindowApplication(
        title = "Git Gooey",
        state = WindowState(size = DpSize(width = 1600.dp, 960.dp))
    ) {
        App()
    }
}

@Composable
private fun App() {
    AppTheme {
        Surface(color = MaterialTheme.colorScheme.background) {
            MainPanes()
        }
    }
}
Code I believe is nothing special. Any way around that?
j
The white is the java swing/awt window background, you can make it transparent or the same color as your compose app
u
how? i was trying window.backgroundColor and nothing happened
j
You have access to the window through the
FrameWindowScope
, you should be able to do something like
window.background = Color(<r>, <g>, <b>, <a>)
a
It鈥檚 a known issue, and the workaround is indeed to use something like
Copy code
/**
 * A hack to work around the window flashing its background color when closed
 * (<https://youtrack.jetbrains.com/issue/CMP-5651>).
 */
@Composable
fun WindowScope.windowBackgroundFlashingOnCloseWorkaround(background: Color) {
    LaunchedEffect(window, background) {
        window.background = java.awt.Color(background.toArgb())
    }
}
馃憤 1
馃ぉ 2
put that inside your
Window
or
DialogWindow
content
u
Yea thank you, I did have the right api but my dumbass called that before setting the
MaterialTheme
Copy code
AppTheme {
    val background = MaterialTheme.colorScheme.background
    LaunchedEffect(window, background) {
        window.background = java.awt.Color(background.toArgb())
    }
    MainPanes(graph)
}
this works, thank you both
u
it's work on macos but not on windows 馃槹
and it's work too on linux