window

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package window decides when and where the cockpit's native window and its omnibox panel show; a Host draws them.

Index

Constants

View Source
const HomeRoute = "view=home"

HomeRoute is the cockpit's home. An empty route would keep a shown window where it is.

View Source
const MalformedLinkRoute = "link=malformed"

MalformedLinkRoute is the route a link that cannot be read opens: the default view, which the cockpit tells about the link.

View Source
const PanelRoute = "panel=omnibox"

PanelRoute is the cockpit route the panel loads.

Variables

This section is empty.

Functions

func InsetTitleBar

func InsetTitleBar(u string) string

InsetTitleBar marks a cockpit URL for a window whose title bar the page draws, around the window controls.

func IsLink(s string) bool

IsLink says s names the deep link scheme, readable or not.

func LinkRoute

func LinkRoute(link string) (route string, ok bool)

LinkRoute is the cockpit route of a deep link, <scheme>://open/#<route>; ok is false for anything else. The route is kept as written, still escaped.

func Navigation(current, next string) (load bool, hash string)

Navigation is how a host moves a webview from current to next: load the page when anything before the fragment differs (another daemon port or token), or only set its hash; an empty hash on the same page keeps the place.

Types

type Config

type Config struct {
	Host       Host
	Daemon     Events
	CockpitURL func(route string) (string, error)
	Hotkey     string
	Log        func(format string, args ...any)
	// After is time.After unless a test supplies its own.
	After func(time.Duration) <-chan time.Time
}

Config is what a Controller needs.

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller keeps one main window and one panel.

func New

func New(cfg Config) *Controller

New returns a controller of cfg.Host.

func (c *Controller) OpenLink(link string)

OpenLink shows a deep link's route in the main window; a link it cannot read shows the default view, which says so.

func (*Controller) Run

func (c *Controller) Run(ctx context.Context) error

Run binds the host's handlers, then follows the window requests the daemon relays until ctx ends, subscribing again whenever the daemon goes away; it returns once the stream it follows has closed.

func (*Controller) Show

func (c *Controller) Show(route string) error

Show shows the main window at route ("" keeps where it was) and hides the panel; a panel route shows the panel instead, since the panel's page in the main window would hand every other route back to it.

func (*Controller) TogglePanel

func (c *Controller) TogglePanel()

TogglePanel shows the panel, or hides it when it shows.

type Events

type Events interface {
	Events(ctx context.Context, client string, since api.Since) (<-chan api.Change, error)
}

Events is the daemon's events stream.

type Handlers

type Handlers struct {
	// Hotkey is an accelerator such as "ctrl+option+space"; "" binds none.
	Hotkey   string
	OnHotkey func()
	// OnReopen runs when the Dock icon is clicked or the bundle is opened
	// again while running.
	OnReopen func()
	// OnPanelHidden runs when the host hid the panel on its own, as on
	// focus loss.
	OnPanelHidden func()
	// OnOpenURL runs for each deep link the system hands the app.
	OnOpenURL func(link string)
}

Handlers are what a host calls back.

type Host

type Host interface {
	// ShowMain shows, focuses and brings the app forward, in the Dock and
	// ⌘Tab while shown.
	ShowMain(url string)
	// ShowPanel shows the panel without activating the app.
	ShowPanel(url string)
	HidePanel()
	// ShowDetached shows and focuses the secondary window id, opening it at
	// url when none is open; it closes for good and is not restored at
	// relaunch.
	ShowDetached(id, url string)
	// OpenExternal opens url, a web address, in the default browser.
	OpenExternal(url string)
	// Listen binds the hotkey, the reopen and opened links; an error leaves
	// the reopen and the links bound.
	Listen(h Handlers) error
}

Host shows the cockpit natively. Every method returns at once; the host runs AppKit work on the main thread.

Directories

Path Synopsis
Package wails hosts the cockpit in a Wails window and panel on macOS; it is the only package that imports Wails.
Package wails hosts the cockpit in a Wails window and panel on macOS; it is the only package that imports Wails.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL