Skip to content

Commit 88eab48

Browse files
committed
Add windowsTitle parameter to TrayApp for configurable popup window titles
- Added a `windowsTitle` parameter to `TrayApp` and its related methods for setting custom popup window titles. - Updated `DialogWindow` to utilize the provided title, improving accessibility and debugging support. - Documented the new parameter in the README with examples.
1 parent 3b19c21 commit 88eab48

2 files changed

Lines changed: 50 additions & 17 deletions

File tree

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,25 @@ application {
676676

677677
Note: The fade-in/out animation in TrayApp controls the content alpha (visual fade) and is independent from window transparency. Transparency support is available on Linux, Windows, and macOS.
678678

679-
## 🧩 New: Tray Window Dismiss Modes
679+
#### Window Title
680+
You can set the popup window title using the `windowsTitle` parameter. The window remains undecorated, but the title may still be used by some window managers or for accessibility/debugging.
681+
682+
- Default: `windowsTitle = ""` (empty)
683+
- Example:
684+
```kotlin
685+
@OptIn(ExperimentalTrayAppApi::class)
686+
application {
687+
TrayApp(
688+
icon = Icons.Default.Dashboard,
689+
tooltip = "My Tray App",
690+
windowsTitle = "My Tray Popup"
691+
) {
692+
// content
693+
}
694+
}
695+
```
696+
697+
## 🧩 New: Tray Window Dismiss Modes
680698

681699
By default, the `TrayApp` popup window closes automatically when it loses focus or when the user clicks outside of it.
682700
With the new `TrayWindowDismissMode` API, you can choose between:

src/commonMain/kotlin/com/kdroid/composetray/tray/api/TrayApp.kt

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ fun ApplicationScope.TrayApp(
7474
fadeDurationMs: Int = 200,
7575
animationSpec: AnimationSpec<Float> = tween(durationMillis = fadeDurationMs, easing = EaseInOut),
7676
transparent: Boolean = true,
77+
windowsTitle: String = "",
7778
menu: (TrayMenuBuilder.() -> Unit)? = null,
7879
content: @Composable () -> Unit,
7980
) {
@@ -97,6 +98,7 @@ fun ApplicationScope.TrayApp(
9798
fadeDurationMs = fadeDurationMs,
9899
animationSpec = animationSpec,
99100
transparent = transparent,
101+
windowsTitle = windowsTitle,
100102
menu = menu,
101103
content = content,
102104
)
@@ -114,6 +116,7 @@ fun ApplicationScope.TrayApp(
114116
fadeDurationMs: Int = 200,
115117
animationSpec: AnimationSpec<Float> = tween(durationMillis = fadeDurationMs, easing = EaseInOut),
116118
transparent: Boolean = true,
119+
windowsTitle: String = "",
117120
menu: (TrayMenuBuilder.() -> Unit)? = null,
118121
content: @Composable () -> Unit,
119122
) {
@@ -130,6 +133,7 @@ fun ApplicationScope.TrayApp(
130133
fadeDurationMs = fadeDurationMs,
131134
animationSpec = animationSpec,
132135
transparent = transparent,
136+
windowsTitle = windowsTitle,
133137
menu = menu,
134138
content = content,
135139
)
@@ -149,6 +153,7 @@ fun ApplicationScope.TrayApp(
149153
fadeDurationMs: Int = 200,
150154
animationSpec: AnimationSpec<Float> = tween(durationMillis = fadeDurationMs, easing = EaseInOut),
151155
transparent: Boolean = true,
156+
windowsTitle: String = "",
152157
menu: (TrayMenuBuilder.() -> Unit)? = null,
153158
content: @Composable () -> Unit,
154159
) {
@@ -163,6 +168,7 @@ fun ApplicationScope.TrayApp(
163168
fadeDurationMs = fadeDurationMs,
164169
animationSpec = animationSpec,
165170
transparent = transparent,
171+
windowsTitle = windowsTitle,
166172
menu = menu,
167173
content = content,
168174
)
@@ -178,6 +184,7 @@ fun ApplicationScope.TrayApp(
178184
fadeDurationMs = fadeDurationMs,
179185
animationSpec = animationSpec,
180186
transparent = transparent,
187+
windowsTitle = windowsTitle,
181188
menu = menu,
182189
content = content,
183190
)
@@ -196,6 +203,7 @@ fun ApplicationScope.TrayApp(
196203
fadeDurationMs: Int = 200,
197204
animationSpec: AnimationSpec<Float> = tween(durationMillis = fadeDurationMs, easing = EaseInOut),
198205
transparent: Boolean = true,
206+
windowsTitle: String = "",
199207
menu: (TrayMenuBuilder.() -> Unit)? = null,
200208
content: @Composable () -> Unit,
201209
) {
@@ -209,6 +217,7 @@ fun ApplicationScope.TrayApp(
209217
fadeDurationMs = fadeDurationMs,
210218
animationSpec = animationSpec,
211219
transparent = transparent,
220+
windowsTitle = windowsTitle,
212221
menu = menu,
213222
content = content,
214223
)
@@ -228,23 +237,25 @@ fun ApplicationScope.TrayApp(
228237
fadeDurationMs: Int = 200,
229238
animationSpec: AnimationSpec<Float> = tween(durationMillis = fadeDurationMs, easing = EaseInOut),
230239
transparent: Boolean = true,
240+
windowsTitle: String = "",
231241
menu: (TrayMenuBuilder.() -> Unit)? = null,
232242
content: @Composable () -> Unit,
233243
) {
234244
if (getOperatingSystem() == WINDOWS) {
235245
TrayApp(
236-
icon = painterResource(windowsIcon),
237-
iconRenderProperties = iconRenderProperties,
238-
tooltip = tooltip,
239-
state = state,
240-
windowSize = windowSize,
241-
visibleOnStart = visibleOnStart,
242-
fadeDurationMs = fadeDurationMs,
243-
animationSpec = animationSpec,
244-
transparent = transparent,
245-
menu = menu,
246-
content = content,
247-
)
246+
icon = painterResource(windowsIcon),
247+
iconRenderProperties = iconRenderProperties,
248+
tooltip = tooltip,
249+
state = state,
250+
windowSize = windowSize,
251+
visibleOnStart = visibleOnStart,
252+
fadeDurationMs = fadeDurationMs,
253+
animationSpec = animationSpec,
254+
transparent = transparent,
255+
windowsTitle = windowsTitle,
256+
menu = menu,
257+
content = content,
258+
)
248259
} else {
249260
TrayApp(
250261
icon = macLinuxIcon,
@@ -257,6 +268,7 @@ fun ApplicationScope.TrayApp(
257268
fadeDurationMs = fadeDurationMs,
258269
animationSpec = animationSpec,
259270
transparent = transparent,
271+
windowsTitle = windowsTitle,
260272
menu = menu,
261273
content = content,
262274
)
@@ -277,17 +289,18 @@ fun ApplicationScope.TrayApp(
277289
fadeDurationMs: Int = 200,
278290
animationSpec: AnimationSpec<Float> = tween(durationMillis = fadeDurationMs, easing = EaseInOut),
279291
transparent: Boolean = true,
292+
windowsTitle: String = "",
280293
menu: (TrayMenuBuilder.() -> Unit)? = null,
281294
content: @Composable () -> Unit,
282295
) {
283296
when (getOperatingSystem()) {
284297
OperatingSystem.LINUX -> TrayAppImplLinux(
285298
iconContent, iconRenderProperties, tooltip, state, windowSize,
286-
visibleOnStart, fadeDurationMs, animationSpec, transparent, menu, content
299+
visibleOnStart, fadeDurationMs, animationSpec, transparent, windowsTitle, menu, content
287300
)
288301
else -> TrayAppImplOriginal(
289302
iconContent, iconRenderProperties, tooltip, state, windowSize,
290-
visibleOnStart, fadeDurationMs, animationSpec, transparent, menu, content
303+
visibleOnStart, fadeDurationMs, animationSpec, transparent, windowsTitle, menu, content
291304
)
292305
}
293306
}
@@ -305,6 +318,7 @@ private fun ApplicationScope.TrayAppImplOriginal(
305318
fadeDurationMs: Int,
306319
animationSpec: AnimationSpec<Float>,
307320
transparent: Boolean,
321+
windowsTitle: String,
308322
menu: (TrayMenuBuilder.() -> Unit)?,
309323
content: @Composable () -> Unit,
310324
) {
@@ -439,7 +453,7 @@ private fun ApplicationScope.TrayAppImplOriginal(
439453

440454
DialogWindow(
441455
onCloseRequest = { requestHideExplicit() },
442-
title = "",
456+
title = windowsTitle,
443457
undecorated = true,
444458
resizable = false,
445459
focusable = true,
@@ -519,6 +533,7 @@ private fun ApplicationScope.TrayAppImplLinux(
519533
fadeDurationMs: Int,
520534
animationSpec: AnimationSpec<Float>,
521535
transparent: Boolean,
536+
windowsTitle: String,
522537
menu: (TrayMenuBuilder.() -> Unit)?,
523538
content: @Composable () -> Unit,
524539
) {
@@ -628,7 +643,7 @@ private fun ApplicationScope.TrayAppImplLinux(
628643

629644
DialogWindow(
630645
onCloseRequest = { requestHideExplicit() },
631-
title = "",
646+
title = windowsTitle,
632647
undecorated = true,
633648
resizable = false,
634649
focusable = shouldShowWindow, // avoid focus-steal while hidden

0 commit comments

Comments
 (0)