JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.26k stars 1.18k forks source link

How to hide application icon from taskbar? #1767

Closed habibg1232191 closed 2 years ago

habibg1232191 commented 2 years ago

Here is an example in awt.

avdim commented 2 years ago

This question is about Windows target

avdim commented 2 years ago

I think, @habibg1232191, want to achieve something like this: https://roundwide.com/implementing-system-tray-app-with-wpf-and-mvvm/ (section Hiding and Restoring Window) In WPF XAML it configures with ShowInTaskbar="{Binding ShowInTaskbar}" Maybe in JVM it can be difficult...

habibg1232191 commented 2 years ago

@avdim that's right. What I wanted

avdim commented 2 years ago

I made sample with the desired behaviour https://github.com/avdim/compose-desktop-not-shown-in-task-bar @habibg1232191 Can you please check it?

igordmn commented 2 years ago

Is the question about how to hide the window from taskbar, when it is opened, or - how to hide the window into tray instead of closing it?

If the second, then - as avdim described (or this way with Composable API).

If the first, then it is probably impossible with AWT/Swing API. We need to use a native API: retrieve ComposeWindow.windowHandle, and write platform-specific logic via JNI. I don't know exactly what API is needed for that, but it is possible, as Toolbox has the same issue, and have fixed it. There is another issue will arise - we can hide window from the taskbar only if it is already visible. So there will be a small glitch - window appears on the taskbar for 300ms. It probably can't be avoided as far as we use Swing as implementation for Compose.

avdim commented 2 years ago

Is the question about how to hide the window from taskbar, when it is opened, or - how to hide the window into tray instead of closing it?

If the second, then - as avdim described (or this way with Composable API).

If the first, then it is probably impossible with AWT/Swing API. We need to use a native API: retrieve ComposeWindow.windowHandle, and write platform-specific logic via JNI. I don't know exactly what API is needed for that, but it is possible, as Toolbox has the same issue, and have fixed it. There is another issue will arise - we can hide window from the taskbar only if it is already visible. So there will be a small glitch - window appears on the taskbar for 300ms. It probably can't be avoided as far as we use Swing as implementation for Compose.

My sample hide window from taskbar only in Windows OS and some Linux distributions. It achieves with usage JDialog() instead of JFrame()

I found this solution on StackOverflow https://stackoverflow.com/questions/2054347/show-jframe-but-not-show-title-bar-on-task-bar

igordmn commented 2 years ago

It achieves with usage JDialog() instead of JFrame()

Indeed, thanks!

Interesting, ComposeDialog shows the icon in the taskbar. I have fixed that here.

okushnikov commented 4 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.