Files
swiftcontrol/macos/Runner/MainFlutterWindow.swift
Jonas Bark e4ad6135eb overlay: auto-show on startup when trainer connects + remove debug logs
Auto-show:
- Navigation initState now subscribes to core.connection.connectionStream
  when the persisted overlay_enabled flag is true. The first connected
  smart trainer with a FitnessBikeDefinition triggers
  TrainerOverlayService.show(...) with the persisted overlay fields.
- Subscription is one-shot (cancels itself after a successful show) and
  also checks already-connected devices on mount, so the overlay reopens
  whether the trainer was reconnected before or after Navigation mounted.

Debug-log cleanup:
- Removed the `bikecontrol_dart_alive.log` liveness probe, the
  `[main:entry]` / `[main:entry/stderr]` print + stderr.writeln, the
  `[overlay-main]` step-by-step logs in the sub-window dispatch, the
  `[main:wm-spy]` channel-handler wrapper, the `[overlay-run]` /
  `[overlay-sub]` action logs in desktop_overlay_window, the
  `[overlay-main]` action-receive / dispatch-fail logs in
  desktop_overlay_controller, the `[main]` Android handler-retry logs,
  and the noisy `[multi_window_native] CreateNewWindow` cerr in the
  Windows runner.
- Kept catch handlers as silent (or kDebugMode-guarded) where the
  original error path was still useful.

Also: MainFlutterWindow simplified back to NSWindow — the vendored
multi_window_native plugin now creates the overlay sub-window as an
NSPanel with .screenSaver level + .fullScreenAuxiliary itself, so
the main window no longer needs the canBecomeMain/canBecomeKey
NSPanel overrides or the .normal level pin.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 12:35:31 +02:00

31 lines
981 B
Swift

import Cocoa
import FlutterMacOS
import multi_window_native
import window_manager
class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
let flutterViewController = FlutterViewController()
let windowFrame = self.frame
self.contentViewController = flutterViewController
self.setFrame(windowFrame, display: true)
RegisterGeneratedPlugins(registry: flutterViewController)
MultiWindowNativePlugin.onEngineCreatedCallback = { engine in
// Re-register every plugin on each new sub-window engine so the
// overlay window has access to window_manager, etc.
//
// The vendored multi_window_native plugin
// (packages/multi_window_native) handles `.screenSaver` window
// level + `.fullScreenAuxiliary` collection behaviour itself at
// sub-window creation time, so no further window-level work is
// needed here.
RegisterGeneratedPlugins(registry: engine)
}
super.awakeFromNib()
}
}