Skip to content

Split TrayApp into a separate composenativetray-app module (#418)#419

Open
kdroidFilter wants to merge 3 commits into
masterfrom
feat/split-trayapp-module
Open

Split TrayApp into a separate composenativetray-app module (#418)#419
kdroidFilter wants to merge 3 commits into
masterfrom
feat/split-trayapp-module

Conversation

@kdroidFilter

Copy link
Copy Markdown
Collaborator

Fixes #418.

Splits the single composenativetray artifact so apps that only need a basic system tray icon no longer pull in the decorated-window-tao windowing backend. Public API and behaviour are unchanged.

What changed

  • New :tray-app module (dev.nucleusframework:composenativetray-app) holds TrayApp and its TrayAppState / TrayWindowDismissMode / animation helper. It owns the nucleus.decorated-window-tao dependency.
  • Core composenativetray keeps the Tray / menu DSL and native tray implementation unchanged, and drops its direct decorated-window-tao dependency (nucleus.application stays — it backs the NucleusApplicationScope.Tray receiver).
  • TrayScreenGeometry is now windowing-agnostic: it exposes injectable scale / work-area providers (with graceful fallbacks) instead of calling Tao directly. tray-app installs the Tao-backed providers at composition, so behaviour with TrayApp is identical.
  • NativeTray and TrayScreenGeometry are now public (shared engine used by both modules). No change to the Tray / TrayApp public API.
  • Bump Nucleus 2.0.32.0.5.
  • README updated: documents the two artifacts and corrects snippets to the current nucleusApplication / SingleInstanceRestoreEffect API.

Consumer impact

  • Basic tray users: no change — same composenativetray coordinate, now lighter.
  • TrayApp users: add one dependency — implementation("dev.nucleusframework:composenativetray-app:<version>").

Verification

  • composenativetray, :tray-app and :demo all compile; ktlint + detekt + core test pass.
  • ./gradlew :dependencies confirms decorated-window-tao is absent from the core runtime classpath and present only in :tray-app; nucleus.application does not pull it transitively.
  • Generated POMs: composenativetray-app → core + nucleus.application + decorated-window-tao.
  • Ran TrayAppDemo end-to-end on macOS: tray created via the cross-module NativeTray, popup positioned from the injected Tao geometry (real screen bounds), shown/dismissed, clean exit.
  • Existing release workflow (publishAndReleaseToMavenCentral) publishes both modules with no change, since the unqualified task runs in the root and every subproject that registers it.

Move TrayApp and its state/dismiss-mode/animation helpers into a new
:tray-app module, published as composenativetray-app, so apps that only
need a basic tray icon no longer pull in the decorated-window-tao
windowing backend.

- Core (composenativetray) keeps the Tray/menu API and native tray impl
  unchanged, and drops its direct decorated-window-tao dependency.
- TrayScreenGeometry is now windowing-agnostic (injectable scale/work-area
  providers with fallbacks); tray-app installs the Tao-backed geometry.
- NativeTray and TrayScreenGeometry are now public (shared engine used by
  both modules); the public Tray / TrayApp API is unchanged.
- Bump Nucleus to 2.0.5.
- README: document the two artifacts and correct the snippets to the
  current nucleusApplication / SingleInstanceRestoreEffect API.
… screen fallback

Addresses the code-review findings on the module split.

- Move TrayScreenGeometry + all popup positioning (getTrayWindowPosition /
  getTrayWindowPositionForInstance, corner detection, persistence) into
  :tray-app, where the Tao backend is always present. The core artifact no
  longer fabricates a 1920x1080 screen when no windowing backend is available:
  the native tray managers just record the raw tray-icon click, and tray-app
  resolves the corner + window position against real Tao geometry. macOS native
  status-item queries are reached through typed MacTrayInitializer wrappers so
  the JNI bridge stays internal.
- Move TrayApp/TrayAppState/TrayWindowDismissMode and friends to package
  dev.nucleusframework.composenativetray.trayapp so no package is split across
  the two published JARs (unblocks JPMS module-path consumers).
- tray-app: declare nucleus.application as api (it is TrayApp's receiver type).
- Align the tray-app log timestamp format with the core formatter.
- README: document the trayapp package and that getTrayWindowPosition lives in
  composenativetray-app; getTrayPosition stays in core.

Consequence: getTrayPosition() on Linux, when used without composenativetray-app,
returns the desktop-environment default corner instead of a click-derived one.
getTrayPosition() and the TrayPosition enum now live in composenativetray-app
(package ...trayapp), next to the popup positioning they feed, so the core
artifact exposes no tray-corner / positioning API at all. The native
tray-region queries are reached through typed wrappers
(WindowsTrayInitializer.notificationIconsRegion, MacTrayInitializer.statusItemRegion)
so the JNI bridges stay internal to core.

Core's TrayPosition.kt is reduced to the raw click tracker (TrayClickTracker +
TrayClickPoint) and renamed TrayClickTracker.kt. Demos and README updated for
the new package. This also removes the Linux core-only degradation: getTrayPosition
now always has Tao geometry available in tray-app.
Comment thread build.gradle.kts
@@ -50,7 +50,7 @@ kotlin {
implementation(libs.nucleus.core.runtime)
implementation(libs.nucleus.darkmode.detector)
api(libs.nucleus.application)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it be replaced with the core-runtime instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Separate TrayApp from the core Compose Tray

2 participants