Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions desktopApp/flatpak/com.artemchep.keyguard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ finish-args:
- --filesystem=xdg-download
- --filesystem=xdg-run/gnupg:create
- --talk-name=org.kde.StatusNotifierWatcher
# The tray backend requests this well-known name before it registers the
# icon with the watcher, and the number in it is the PID of the app inside
# of the sandbox. Can be dropped once the backend registers the icon under
# the unique connection name instead.
- --own-name=org.kde.StatusNotifierItem-2-1
modules:
- name: keyguard
buildsystem: simple
Expand Down
19 changes: 18 additions & 1 deletion desktopApp/src/jvmMain/kotlin/com/artemchep/keyguard/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ import com.artemchep.keyguard.feature.navigation.NavigationRouterBackHandler
import com.artemchep.keyguard.feature.navigation.state.TranslatorScope
import com.artemchep.keyguard.nativecrypto.NativeCryptoDesktopSmoke
import com.artemchep.keyguard.nativecrypto.NativeCryptoException
import com.artemchep.keyguard.platform.CurrentPlatform
import com.artemchep.keyguard.platform.LeContext
import com.artemchep.keyguard.platform.LocalWindowId
import com.artemchep.keyguard.platform.Platform
import com.artemchep.keyguard.platform.WindowId
import com.artemchep.keyguard.platform.lifecycle.LaunchLifecycleProviderEffect
import com.artemchep.keyguard.platform.lifecycle.LeLifecycleState
Expand Down Expand Up @@ -236,6 +238,21 @@ private fun verifyPackagedDesktopTls(): String {
return "OkHttp/$providerName/JDK$jdkFeature"
}

/**
* `true` if the app is able to show a tray icon.
*
* On Linux the tray icon is a StatusNotifierItem published on the session
* bus, while [isTraySupported] reports the availability of the legacy XEmbed
* tray. A session that implements only the modern protocol, as well as the
* Flatpak sandbox, reports no XEmbed tray even though the tray icon itself
* works there, so we never ask AWT about it.
*/
private val isTrayAvailable: Boolean
get() = when (CurrentPlatform) {
is Platform.Desktop.Linux -> true
else -> isTraySupported
}

@OptIn(ExperimentalTime::class)
private fun runKeyguardApplication() {
ensurePlatformCryptoReady()
Expand Down Expand Up @@ -660,7 +677,7 @@ private fun runKeyguardApplication() {

// Show a tray icon and allow the app to be collapsed into
// the tray on supported platforms.
val getCloseToTrayState = if (isTraySupported) {
val getCloseToTrayState = if (isTrayAvailable) {
remember { getCloseToTray() }
.collectAsState(false)
} else {
Expand Down
Loading