Hey! What would be the best way to have a native l...
# compose-desktop
m
Hey! What would be the best way to have a native look&feel
title bar
on MacOS and Windows for my Compose Desktop window? Meaning: • 🌙 dark mode if system is in dark mode • 📏 Double the height, like default macOS title bar For Comparison the Slack app title bar on top, Compose Desktop below.
m
Have you tried
Copy code
val isMac = System.getProperty("os.name").startsWith("Mac")

if ( isMac ) {
    System.setProperty("apple.awt.application.appearance", "system")
}
in your desktop main method already?
m
@Michael Paus just tried it, by forcefully adding the line (
System.setProperty("apple.awt.application.appearance", "system")
), the window didn’t change however.
m
In my application it does. When I switch the theme from light to dark in the macOS settings, the color of the title bar changes in the running application.
m
@Michael Paus this is my most basic code:
Copy code
fun main() = application {
    System.setProperty("apple.awt.application.appearance", "system")

    Window(
        onCloseRequest = ::exitApplication,
        title = "KMP-Template-Project",
    ) {
        Box(
            modifier = Modifier
                .width(400.dp)
                .height(300.dp)
               
        )
    }
}
Could you maybe share your entrance
main.kt
file?
m
Copy code
fun main(args: Array<String>) {

    val isMac = System.getProperty("os.name").startsWith("Mac")

    if ( isMac ) {
        System.setProperty("apple.awt.application.appearance", "system")
    }

    application {
    ...
Maybe it has to moved out of “application”.
m
Copy code
System.setProperty("apple.awt.application.appearance", "system")
Has to be outside the
application{}
tag, then it works👍 cool, looks better already. Thanks! Do you know if we can also increase the size of the toolbar? I will later check if i find more useful flags inside
apple.awt.application.appearance
m
m
Perfect! Thx!
For anyone interested: add inside the Window element:
Copy code
window.rootPane.putClientProperty("apple.awt.fullWindowContent", true)
window.rootPane.putClientProperty("apple.awt.transparentTitleBar", true)
For full native feel
👀 1
d
FWIW, here is how I set up my app:
Copy code
fun main() {
    System.setProperty("apple.awt.application.appearance", "system")
    System.setProperty("skiko.rendering.laf.global", "true")
    System.setProperty("skiko.rendering.useScreenMenuBar", "true")
    System.setProperty("skiko.linux.autodpi", "true")

    application {
        Window(
            onCloseRequest = ::exitApplication,
            title = "My App",
        ) {
            App()
        }
    }
}
I don't think you need to check if it is apple beefore setting the properties btw. They are just ignored if not applicable.
👍 2
🙏 1
m
@Daniel Pitts Can you provide any pointer to some documentation for these skiko properties?
d
I don’t remember where I found them, but searching google probably will take you there.
m
I tried Google already but did not find anything relevant.
d
Hmm, you're right. I really don't recall where I figure it out, probably source spelunking. Just found some more interesting things in org.jetbrains.skiko.SkikoProperties
Also, apparently you can just call
androidx.compose.ui.configureSwingGlobalsForCompose
for the same effect.