import GObject, { register, property, signal } from "astal/gobject"; import { ConnectionInstantiationError, NotImplementedError } from "./errors"; import { OutputAdapter, OutputConfig, VSOutputAdapter, VSOutputEvent, VSWorkspaceAdapter, VSWorkspaceEvent, } from "./types"; /** * Mid-level abstract compositor connection providing raw data about the compositor to the rest of VoidShell. * Wraps the low-level compositor-specific IPC APIs with a common interface that other services can build on top of. * * This should generally only be utilized directly by the high-level compositor-related services (workspaces, * contexts, etc.). Other services should generally interact with the compositor via these high-level services. */ @register({ GTypeName: "AbstractCompositorConnection", }) export class CompositorConnection extends GObject.Object { constructor() { if (CompositorConnection._instance !== undefined) { throw new ConnectionInstantiationError( "Cannot create a CompositorConnection where one already exists", ); } super(); if (Object.getPrototypeOf(this) === CompositorConnection.prototype) { throw new ConnectionInstantiationError( "Cannnot instantiate abstract CompositorConnection", ); } CompositorConnection._instance = this; } static _instance: CompositorConnection | undefined; static get instance() { if (this._instance === undefined) { throw new Error( "Must instantiate a CompositorConnection before attempting to retrieve instance", ); } return this._instance; } /** * Focus a workspace by ID * @param workspaceId The workspace to focus */ async focusWorkspace(workspaceId: string): Promise { throw new NotImplementedError(); } /** * Move a workspace to a different output * @param workspaceId The workspace to move * @param outputName The output to move the workspace to */ async moveWorkspace(workspaceId: string, outputName: string): Promise { throw new NotImplementedError(); } /** * Focus an output * @param outputName The output to focus */ async focusOutput(outputName: string): Promise { throw new NotImplementedError(); } /** * Move the focused container to the given workspace * @param workspaceId The workspace to move the container to */ async moveContainer(workspaceId: string): Promise { throw new NotImplementedError(); } /** * Configure an output * @param outputName The name of the output to configure * @param config The configuration object for the output */ async configureOutput( outputName: string, config: OutputConfig, ): Promise { throw new NotImplementedError(); } /** * Gets a list of all connected outputs * @returns a list of VSOutputAdapter objects representing the connected outputs */ async getOutputs(): Promise { throw new NotImplementedError(); } /** * Gets a list of all workspaces * @returns a list of VSWorkspaceAdapter objects representing the workspaces presently known to the compositor */ async getWorkspaces(): Promise { throw new NotImplementedError(); } /** * Disable an output * @param outputName The name of the output to disable */ async disableOutput(outputName: string): Promise { throw new NotImplementedError(); } /** * Set an output property without fully reconfiguring the output */ async setOutputProperty( property: Prop, value: Exclude, ) { throw new NotImplementedError(); } /** * Emitted when a workspace's data changes */ @signal(VSWorkspaceEvent) declare workspaceChange: (event: VSWorkspaceEvent) => void; /** * Emitted when an output's data changes * For example, it is enabled or disabled, or its mode changes */ @signal(VSOutputEvent) declare outputChange: (event: VSOutputEvent) => void; /** * Emitted when the binding mode changes */ @signal(String) declare modeChange: (event: string) => void; }