2.5 KiB
2.5 KiB
Backend Documentation
The backend is written in Go and uses the forge.lthn.ai/core/gui/pkg/display package. It uses Wails v3 to bridge Go and the web frontend.
Core Types
Service
The Service struct is the main entry point for the display logic.
-
Initialization:
New() (*Service, error): Creates a new instance of the service.Register(wailsApp *application.App) func(*core.Core) (any, error): Captures the Wails app and registers the service with Core.OnStartup(ctx context.Context) error: Loads config and registers IPC handlers.
-
Window Management:
OpenWindow(spec window.Window) error: Opens a new window from a declarative spec.CreateWindow(spec window.Window) (*window.WindowInfo, error): Opens a window and returns its info.GetWindowInfo(name string) (*window.WindowInfo, error): Queries a single window.ListWindowInfos() []window.WindowInfo: Queries all tracked windows.SetWindowPosition(name string, x, y int) errorSetWindowSize(name string, width, height int) errorSetWindowBounds(name string, x, y, width, height int) errorMaximizeWindow(name string) errorMinimizeWindow(name string) errorRestoreWindow(name string) errorFocusWindow(name string) errorSetWindowFullscreen(name string, fullscreen bool) errorSetWindowAlwaysOnTop(name string, alwaysOnTop bool) errorSetWindowVisibility(name string, visible bool) errorSetWindowTitle(name, title string) errorSetWindowBackgroundColour(name string, r, g, b, a uint8) errorGetFocusedWindow() stringResetWindowState() errorGetSavedWindowStates() map[string]window.WindowState
Example:
svc.OpenWindow(window.Window{
Name: "editor",
Title: "Editor",
URL: "/#/editor",
Width: 1200,
Height: 800,
})
Subsystems
Menu (menu.go)
The buildMenu() method constructs the application's main menu, adding standard roles like File, Edit, Window, and Help. It also dispatches the app-specific developer actions used by the frontend.
System Tray (tray.go)
The setupTray() method initializes the system tray icon and its context menu. It supports:
- Showing/Hiding all windows.
- Displaying environment info.
- Quitting the application.
- Attaching tray actions that are broadcast as IPC events.
Actions (messages.go)
Defines structured messages for Inter-Process Communication (IPC) and internal event handling, including window.ActionWindowOpened, window.ActionWindowClosed, and display.ActionIDECommand.