| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- //
- // Copyright 2026 Aarav Ravindra Kharade
- //
- import CSystem
- import CWayland
- /// ArkCompositor
- /// The core Wayland Server embedded directly into arkrt.
- /// Any UI app (like setup_app or ui_daemon) can connect to this Wayland server
- /// to render graphics using standard Wayland protocols.
- @_silgen_name("ark_compositor_init")
- func c_ark_compositor_init() -> Bool
- @_silgen_name("ark_compositor_dispatch")
- func c_ark_compositor_dispatch()
- @_silgen_name("ark_compositor_shutdown")
- func c_ark_compositor_shutdown()
- @_silgen_name("ark_compositor_set_render_buffer")
- func c_ark_compositor_set_render_buffer(_ buffer: UnsafeMutablePointer<UInt8>, _ width: Int32, _ height: Int32, _ bpp: Int32)
- public class ArkCompositor {
- public static let shared = ArkCompositor()
-
- public private(set) var isRunning = false
-
- private init() {}
-
- /// Starts the Wayland server in the arkrt core.
- public func start() {
- if isRunning { return }
- if c_ark_compositor_init() {
- isRunning = true
- print("ArkCompositor: Core Wayland Server Started.")
- } else {
- print("ArkCompositor: FATAL - Failed to start Wayland Server.")
- }
- }
-
- /// Hook this into the main runloop of arkrt to process Wayland events
- public func dispatch() {
- if isRunning {
- c_ark_compositor_dispatch()
- }
- }
-
- /// Connects the Wayland compositor to the actual physical screen buffer (e.g. from DRM/KMS or Splash rendering)
- public func setRenderBuffer(buffer: UnsafeMutablePointer<UInt8>, width: Int, height: Int, bpp: Int) {
- c_ark_compositor_set_render_buffer(buffer, Int32(width), Int32(height), Int32(bpp))
- }
-
- public func shutdown() {
- if isRunning {
- c_ark_compositor_shutdown()
- isRunning = false
- print("ArkCompositor: Core Wayland Server Shut Down.")
- }
- }
- }
|