https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
a

Alex Styl

03/24/2024, 4:32 AM
Is there a way on Mac to remove the traffic lights (close, minimize, maximize), but keep the window roundness and shadows? I tried setting the window to undecorated and even though it removes the buttons, it also removes the shadows and window corner radius
t

Taha

03/24/2024, 9:10 PM
i just set both
undecorated
and
transparent
to true and wrap everything in a surface then i can control the shadow and radius throug the surface
Copy code
Window(
        onCloseRequest = ::exitApplication,
        undecorated = true,
        transparent = true
    ){
        Surface(
            modifier = Modifier
                .fillMaxSize()
                .padding(5.dp)
                .shadow(3.dp, RoundedCornerShape(10.dp)),
            color = MaterialTheme.colorScheme.surface,
            shape = RoundedCornerShape(10.dp),
            elevation = 40.dp
        ) {
            WindowDraggableArea {
            App()
            }
        }
    }
image.png
g

Garret Yoder

03/25/2024, 12:53 PM
I'm doing the same thing as above. You'll have to make your own titlebar, but thats very easy with WindowDraggableArea.
a

Alex Styl

03/27/2024, 2:47 AM
that's not ideal because the shadows don't look the same. native windows change the shadow according to the window being focused or not.
g

Garret Yoder

03/27/2024, 1:52 PM
So there's focus listeners for the window object that you could just change the shadow depth based on a state.
If you want to replicate 100% the original system window styling minus the titlebar then I remember coming across a way you could do it by interfacing with the macos WM via JNI. Let me see if I can find it again.
a

Alex Styl

03/28/2024, 12:29 AM
that's interesting. never used jni though. how do i call the objective c code from kotlin?
5 Views