theapache64
03/19/2022, 8:24 AMtheapache64
03/19/2022, 8:26 AMIgor Demin
03/19/2022, 9:12 AMval 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.theapache64
03/19/2022, 11:57 AMS.
03/19/2022, 2:13 PMtheapache64
03/19/2022, 2:14 PMdecoration
flag. i was looking if there’s any easy API to do thattheapache64
03/19/2022, 4:10 PMapplication {
Window(
// ...
) {
val skiaLayer = window.contentPane.getComponent(0) as SkiaLayer
throws
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
theapache64
03/19/2022, 5:06 PMwindow.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.Igor Demin
03/19/2022, 6:32 PMimport 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)theapache64
03/19/2022, 6:34 PM