Skip to content

Display API Reference

Complete API reference for the Display service (pkg/display).

Service Creation

func NewService(c *core.Core) (any, error)

Window Management

CreateWindow

func (s *Service) CreateWindow(opts CreateWindowOptions) (*WindowInfo, error)

Creates a new window with the specified options.

type CreateWindowOptions struct {
    Name   string
    Title  string
    URL    string
    X      int
    Y      int
    Width  int
    Height int
}

CloseWindow

func (s *Service) CloseWindow(name string) error

GetWindowInfo

func (s *Service) GetWindowInfo(name string) (*WindowInfo, error)

Returns:

type WindowInfo struct {
    Name       string
    Title      string
    X          int
    Y          int
    Width      int
    Height     int
    IsVisible  bool
    IsFocused  bool
    IsMaximized bool
    IsMinimized bool
}

ListWindowInfos

func (s *Service) ListWindowInfos() []*WindowInfo

Window Position & Size

func (s *Service) SetWindowPosition(name string, x, y int) error
func (s *Service) SetWindowSize(name string, width, height int) error
func (s *Service) SetWindowBounds(name string, x, y, width, height int) error

Window State

func (s *Service) MaximizeWindow(name string) error
func (s *Service) MinimizeWindow(name string) error
func (s *Service) RestoreWindow(name string) error
func (s *Service) FocusWindow(name string) error
func (s *Service) SetWindowFullscreen(name string, fullscreen bool) error
func (s *Service) SetWindowAlwaysOnTop(name string, onTop bool) error
func (s *Service) SetWindowVisibility(name string, visible bool) error

Window Title

func (s *Service) SetWindowTitle(name, title string) error
func (s *Service) GetWindowTitle(name string) (string, error)

Window Background

func (s *Service) SetWindowBackgroundColour(name string, r, g, b, a uint8) error

Focus

func (s *Service) GetFocusedWindow() string

Screen Management

GetScreens

func (s *Service) GetScreens() []*Screen

Returns:

type Screen struct {
    ID          string
    Name        string
    X           int
    Y           int
    Width       int
    Height      int
    ScaleFactor float64
    IsPrimary   bool
}

GetScreen

func (s *Service) GetScreen(id string) (*Screen, error)

GetPrimaryScreen

func (s *Service) GetPrimaryScreen() (*Screen, error)

GetScreenAtPoint

func (s *Service) GetScreenAtPoint(x, y int) (*Screen, error)

GetScreenForWindow

func (s *Service) GetScreenForWindow(name string) (*Screen, error)

GetWorkAreas

func (s *Service) GetWorkAreas() []*WorkArea

Returns usable screen space (excluding dock/taskbar).

Layout Management

SaveLayout / RestoreLayout

func (s *Service) SaveLayout(name string) error
func (s *Service) RestoreLayout(name string) error
func (s *Service) ListLayouts() []string
func (s *Service) DeleteLayout(name string) error
func (s *Service) GetLayout(name string) *Layout

TileWindows

func (s *Service) TileWindows(mode TileMode, windows []string) error

Tile modes:

const (
    TileModeLeft      TileMode = "left"
    TileModeRight     TileMode = "right"
    TileModeGrid      TileMode = "grid"
    TileModeQuadrants TileMode = "quadrants"
)

SnapWindow

func (s *Service) SnapWindow(name string, position SnapPosition) error

Snap positions:

const (
    SnapPositionLeft        SnapPosition = "left"
    SnapPositionRight       SnapPosition = "right"
    SnapPositionTop         SnapPosition = "top"
    SnapPositionBottom      SnapPosition = "bottom"
    SnapPositionTopLeft     SnapPosition = "top-left"
    SnapPositionTopRight    SnapPosition = "top-right"
    SnapPositionBottomLeft  SnapPosition = "bottom-left"
    SnapPositionBottomRight SnapPosition = "bottom-right"
)

StackWindows

func (s *Service) StackWindows(windows []string, offsetX, offsetY int) error

ApplyWorkflowLayout

func (s *Service) ApplyWorkflowLayout(workflow WorkflowType) error

Workflow types:

const (
    WorkflowCoding    WorkflowType = "coding"
    WorkflowDebugging WorkflowType = "debugging"
    WorkflowPresenting WorkflowType = "presenting"
)

Dialogs

File Dialogs

func (s *Service) OpenSingleFileDialog(opts OpenFileOptions) (string, error)
func (s *Service) OpenFileDialog(opts OpenFileOptions) ([]string, error)
func (s *Service) SaveFileDialog(opts SaveFileOptions) (string, error)
func (s *Service) OpenDirectoryDialog(opts OpenDirectoryOptions) (string, error)

Options:

type OpenFileOptions struct {
    Title            string
    DefaultDirectory string
    AllowMultiple    bool
    Filters          []FileFilter
}

type SaveFileOptions struct {
    Title            string
    DefaultDirectory string
    DefaultFilename  string
    Filters          []FileFilter
}

type FileFilter struct {
    DisplayName string
    Pattern     string  // e.g., "*.png;*.jpg"
}

ConfirmDialog

func (s *Service) ConfirmDialog(title, message string) (bool, error)

PromptDialog

func (s *Service) PromptDialog(title, message string) (string, bool, error)

System Tray

func (s *Service) SetTrayIcon(icon []byte) error
func (s *Service) SetTrayTooltip(tooltip string) error
func (s *Service) SetTrayLabel(label string) error
func (s *Service) SetTrayMenu(items []TrayMenuItem) error
func (s *Service) GetTrayInfo() map[string]any

Menu item:

type TrayMenuItem struct {
    Label       string
    ActionID    string
    IsSeparator bool
}

Clipboard

func (s *Service) ReadClipboard() (string, error)
func (s *Service) WriteClipboard(text string) error
func (s *Service) HasClipboard() bool
func (s *Service) ClearClipboard() error

Notifications

func (s *Service) ShowNotification(opts NotificationOptions) error
func (s *Service) ShowInfoNotification(title, message string) error
func (s *Service) ShowWarningNotification(title, message string) error
func (s *Service) ShowErrorNotification(title, message string) error
func (s *Service) RequestNotificationPermission() (bool, error)
func (s *Service) CheckNotificationPermission() (bool, error)

Options:

type NotificationOptions struct {
    ID       string
    Title    string
    Message  string
    Subtitle string
}

Theme

func (s *Service) GetTheme() *Theme
func (s *Service) GetSystemTheme() string

Returns:

type Theme struct {
    IsDark bool
}

Events

func (s *Service) GetEventManager() *EventManager

The EventManager handles WebSocket connections for real-time events.