I am trying to dynamically set the `alwaysOnTop` p...
# compose-desktop
m
I am trying to dynamically set the
alwaysOnTop
property on
Window
, but it seems like every time I modify it my window moves a bit down and right. Here is example code that shows off this behaviour (at least on Windows, where I am currently working):
Copy code
fun main() = application {
    val coroutineScope = rememberCoroutineScope()

    val alwaysOnTop by remember {
        flow {
            while (true) {
                emit(true)
                delay(2.seconds)
                emit(false)
                delay(2.seconds)
            }
        }.shareIn(coroutineScope, SharingStarted.Lazily)
    }.collectAsState(false)

    Window(
        title = "Test",
        state = WindowState(width = 1200.dp, height = 900.dp),
        alwaysOnTop = alwaysOnTop,
        onCloseRequest = ::exitApplication
    ) {
        Text("hi")
    }
}
Visually this behaviour reminds me of the default behaviour on Windows when opening multiple windows after each other, where they are spaced apart a bit so they don't 100% overlap each other. Is the window getting recreated or something of the sort? Is there a way to disable this behaviour?
a
remember the WindowState
m
That does the trick, thanks!