*[*:white_check_mark: SOLVED] Is it possible to hi...
# compose-desktop
t
[ SOLVED] Is it possible to hide the title bar entirely, but leave the traffic lights and the draggable zone? 🤔
@olonho any idea?
i
Not sure, but probably this method will help: https://github.com/JetBrains/skiko/blob/82bfb2d6db2aaade6e84231ae116454fb3cf5a9b/skiko/src/awtMain/kotlin/org/jetbrains/skiko/SkiaLayer.awt.kt#L554 SkiaLayer isn't exposed in Compose, but you can use a hack to access it. Something like:
Copy code
val window = ComposeWindow()
val skiaLayer = window.contentPane.getComponent(0).getComponent(0) as SkiaLayer
(I haven't tested it, but the idea stays the same). The feature without this hack is possible, but not in the near future.
t
Understood. Thanks 👍
s
you can always hide it and add the buttons/WindowDraggableArea manually
t
yeah, am aware of the
decoration
flag. i was looking if there’s any easy API to do that
@Igor Demin
Copy code
application {
            Window(
            // ...
            ) {
                val skiaLayer = window.contentPane.getComponent(0) as SkiaLayer
throws
Copy code
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: class androidx.compose.ui.awt.ComposeWindowDelegate$pane$1 cannot be cast to class org.jetbrains.skiko.SkiaLayer
Update: Calling
Copy code
window.rootPane.apply {
    rootPane.putClientProperty("apple.awt.fullWindowContent", true)
    rootPane.putClientProperty("apple.awt.transparentTitleBar", true)
}
did the job, but I think this will only work in macOS.
i
This code also works:
Copy code
import androidx.compose.ui.awt.ComposeWindow
import org.jetbrains.skiko.SkiaLayer
import org.jetbrains.skiko.disableTitleBar
import java.awt.Component
import java.awt.Container
import java.awt.Dimension
import javax.swing.SwingUtilities

fun main() = SwingUtilities.invokeLater {
    val window = ComposeWindow()
    window.preferredSize = Dimension(300, 300)
    window.pack()
    val layer = window.contentPane.findSkiaLayer()!!
    layer.disableTitleBar(40f)
    window.isVisible = true
}

private fun Component.findSkiaLayer(): SkiaLayer? {
    if (this is SkiaLayer) return this
    if (this is Container) {
        for (i in 0 until componentCount) {
            val child = getComponent(i)
            val skiaLayer = child.findSkiaLayer()
            if (skiaLayer != null) {
                return skiaLayer
            }
        }
    }
    return null
}
But your approach is better, because it doesn’t use hacks. And you are right, it only for macOs. I don’t know how to support it for other os’es. If native platform allows it, you can retrieve a native handle (
window.windowHandle
), and call some native function which will do what you want. To call a native function, you need to either write a native code on C, or use some helper java library (after some googling I found Jawin library for Windows)
t
Aah. interesting. Thanks for the lib