Skip to content

Commit b1c502a

Browse files
authored
Merge pull request #416 from NucleusFramework/refactor/trayapp-stable-api
Promote TrayApp to a stable API; log instead of crashing on non-Tao backend
2 parents 30156e4 + 5592006 commit b1c502a

6 files changed

Lines changed: 11 additions & 43 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,6 @@ Add the following to your ProGuard rules file:
591591
## Quick Start (minimal)
592592

593593
```kotlin
594-
@OptIn(ExperimentalTrayAppApi::class)
595594
application {
596595
val trayAppState = rememberTrayAppState(
597596
initialWindowSize = DpSize(300.dp, 420.dp),

demo/src/jvmMain/kotlin/dev/nucleusframework/composenativetray/demo/TrayAppDemo.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import composenativetray.demo.generated.resources.Res
1919
import composenativetray.demo.generated.resources.icon
2020
import dev.nucleusframework.application.SingleInstanceRestoreEffect
2121
import dev.nucleusframework.application.nucleusApplication
22-
import dev.nucleusframework.composenativetray.tray.api.ExperimentalTrayAppApi
2322
import dev.nucleusframework.composenativetray.tray.api.TrayApp
2423
import dev.nucleusframework.composenativetray.tray.api.TrayWindowDismissMode
2524
import dev.nucleusframework.composenativetray.tray.api.rememberTrayAppState
@@ -30,7 +29,6 @@ import dev.nucleusframework.window.material.MaterialTitleBar
3029
import kotlinx.coroutines.launch
3130
import org.jetbrains.compose.resources.painterResource
3231

33-
@OptIn(ExperimentalTrayAppApi::class)
3432
fun main() {
3533
allowComposeNativeTrayLogging = true
3634
nucleusApplication(dockIconFollowsWindows = true) {

src/jvmMain/kotlin/dev/nucleusframework/composenativetray/tray/api/ExperimentalTrayAppApi.kt

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/jvmMain/kotlin/dev/nucleusframework/composenativetray/tray/api/TrayApp.kt

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@file:OptIn(
2-
ExperimentalTrayAppApi::class,
32
ExperimentalTransitionApi::class,
43
InternalAnimationApi::class,
54
)
@@ -51,6 +50,7 @@ import dev.nucleusframework.composenativetray.utils.MenuContentHash
5150
import dev.nucleusframework.composenativetray.utils.PersistentAnimatedVisibility
5251
import dev.nucleusframework.composenativetray.utils.TrayScreenGeometry
5352
import dev.nucleusframework.composenativetray.utils.debugln
53+
import dev.nucleusframework.composenativetray.utils.errorln
5454
import dev.nucleusframework.composenativetray.utils.getTrayWindowPosition
5555
import dev.nucleusframework.composenativetray.utils.getTrayWindowPositionForInstance
5656
import dev.nucleusframework.composenativetray.utils.isMenuBarInDarkMode
@@ -123,7 +123,6 @@ private val defaultVerticalOffset =
123123

124124
// --------------------- Public API (overloads) ---------------------
125125

126-
@ExperimentalTrayAppApi
127126
@Composable
128127
fun NucleusApplicationScope.TrayApp(
129128
icon: ImageVector,
@@ -179,7 +178,6 @@ fun NucleusApplicationScope.TrayApp(
179178
)
180179
}
181180

182-
@ExperimentalTrayAppApi
183181
@Composable
184182
fun NucleusApplicationScope.TrayApp(
185183
icon: Painter,
@@ -227,7 +225,6 @@ fun NucleusApplicationScope.TrayApp(
227225
}
228226

229227
/** Painter on Windows, ImageVector on macOS/Linux */
230-
@ExperimentalTrayAppApi
231228
@Composable
232229
fun NucleusApplicationScope.TrayApp(
233230
windowsIcon: Painter,
@@ -297,7 +294,6 @@ fun NucleusApplicationScope.TrayApp(
297294
}
298295
}
299296

300-
@ExperimentalTrayAppApi
301297
@Composable
302298
fun NucleusApplicationScope.TrayApp(
303299
icon: DrawableResource,
@@ -341,7 +337,6 @@ fun NucleusApplicationScope.TrayApp(
341337
)
342338
}
343339

344-
@ExperimentalTrayAppApi
345340
@Composable
346341
fun NucleusApplicationScope.TrayApp(
347342
windowsIcon: DrawableResource,
@@ -414,17 +409,16 @@ fun NucleusApplicationScope.TrayApp(
414409
// --------------------- Core implementation (Tao backend only) ---------------------
415410

416411
/**
417-
* Tray icon + anchored popup. Runs exclusively on the Nucleus Tao backend
418-
* call it inside `nucleusApplication(backend = NucleusBackend.Tao)` (or
419-
* `Auto` with `decorated-window-tao` on the classpath).
412+
* Tray icon + anchored popup. Runs exclusively on the Nucleus Tao backend,
413+
* which the `Auto` backend selects automatically once the
414+
* `decorated-window-tao` module is on the classpath.
420415
*
421416
* On Windows + macOS the popup body is hosted in a standalone per-pixel
422417
* transparent, non-activating native panel — no backing window exists anywhere
423418
* (nothing in the taskbar/Dock, Alt-Tab or the Start task view). On Linux the
424419
* popup is a regular undecorated Tao window (opaque): no cross-WM transparency
425420
* equivalent exists.
426421
*/
427-
@ExperimentalTrayAppApi
428422
@Composable
429423
fun NucleusApplicationScope.TrayApp(
430424
iconContent: @Composable () -> Unit,
@@ -446,10 +440,13 @@ fun NucleusApplicationScope.TrayApp(
446440
menu: (TrayMenuBuilder.() -> Unit)? = null,
447441
content: @Composable () -> Unit,
448442
) {
449-
require(backend == NucleusBackend.Tao) {
450-
"TrayApp requires the Tao window backend. Launch with " +
451-
"nucleusApplication(backend = NucleusBackend.Tao) and ship the " +
452-
"nucleus.decorated-window-tao module."
443+
if (backend != NucleusBackend.Tao) {
444+
errorln {
445+
"TrayApp requires the Tao window backend. Launch with " +
446+
"nucleusApplication() and ship the " +
447+
"nucleus.decorated-window-tao module."
448+
}
449+
return
453450
}
454451

455452
// Linux gates on runtime availability: the panel is a raw X11 window,

src/jvmMain/kotlin/dev/nucleusframework/composenativetray/tray/api/TrayAppState.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import kotlinx.coroutines.flow.asStateFlow
1212
* State holder for TrayApp that provides programmatic control over the tray window
1313
* and observability of its state changes, including window dismiss behavior.
1414
*/
15-
@ExperimentalTrayAppApi
1615
class TrayAppState(
1716
initialWindowSize: DpSize = DpSize(300.dp, 200.dp),
1817
initiallyVisible: Boolean = false,
@@ -87,7 +86,6 @@ class TrayAppState(
8786
}
8887

8988
/** Creates and remembers a TrayAppState instance */
90-
@ExperimentalTrayAppApi
9189
@Composable
9290
fun rememberTrayAppState(
9391
initialWindowSize: DpSize = DpSize(300.dp, 200.dp),

src/jvmMain/kotlin/dev/nucleusframework/composenativetray/tray/api/TrayWindowDismissMode.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dev.nucleusframework.composenativetray.tray.api
33
/**
44
* Defines how the tray window should be dismissed (hidden)
55
*/
6-
@ExperimentalTrayAppApi
76
enum class TrayWindowDismissMode {
87
/**
98
* The window automatically hides when it loses focus or when clicking outside.

0 commit comments

Comments
 (0)