Documentation
¶
Overview ¶
Package host has the platform services of giode.App that don't need its window, for apps that host Giode themselves - in a GLFW window, as an embedded view (see docs/low-level.md): keeping the screen on, the single-instance lock, and the clipboard bridge between Gio's input router and the host's clipboard. App uses them too. The package doesn't import gioui.org/app.
Index ¶
Constants ¶
const WaitArg = "--giode-wait-pid="
WaitArg is the argument an app restarted with other rights (see giode's App.RestartElevated) gets before its own, naming the old process to wait for: elevation (UAC, pkexec, an administrator prompt) doesn't pass the environment on.
Variables ¶
var ErrNotSupported = errors.New("giode: not supported on this platform")
ErrNotSupported is returned by features the current platform lacks. giode.ErrNotSupported is the same error.
Functions ¶
func KeepAwake ¶
KeepAwake keeps the computer from sleeping while idle until release is called: a systemd-logind inhibitor lock, listed with reason.
func KeepScreenOn ¶
KeepScreenOn keeps the screen from dimming and locking while on is set: the freedesktop screen saver inhibition.
func ServeClipboard ¶
ServeClipboard connects Gio's input router to the host's clipboard (GLFW's, the OS's): text components copy (editors, SelectionArea, kit.WriteClipboard) goes to write, and their paste requests are answered with read's text. Call it every frame, after router.Frame. giode.App's window does this itself.
func TakeWaitArg ¶
func TakeWaitArg() int
TakeWaitArg removes WaitArg from os.Args and returns its pid, or 0.
func WaitForUpdate ¶
func WaitForUpdate()
WaitForUpdate waits, in an app restarted by an update (see the update package), for the old process to exit, so the new one takes over its files and lock. LockInstance calls it; an app without the lock calls it early in main.
Types ¶
type InstanceLock ¶
type InstanceLock struct {
// contains filtered or unexported fields
}
InstanceLock is the single-instance lock of an application id, held by the first instance to start. Get it with LockInstance.
func LockInstance ¶
func LockInstance(id string) *InstanceLock
LockInstance claims the single-instance lock for id (the app's id, "com.example.player"). When another live instance holds it, Running reports true: hand it this launch's arguments with Forward and exit. Otherwise this instance holds the lock: Serve receives later instances' arguments, and Release frees the lock on exit. An app restarted by an update first waits for the old process to exit.
func (*InstanceLock) Forward ¶
func (l *InstanceLock) Forward(args []string) error
Forward hands args to the instance holding the lock, which gets them through its Serve function.
func (*InstanceLock) Release ¶
func (l *InstanceLock) Release()
Release frees a lock this instance holds.
func (*InstanceLock) Running ¶
func (l *InstanceLock) Running() bool
Running reports whether another instance holds the lock.
func (*InstanceLock) Serve ¶
func (l *InstanceLock) Serve(fn func(args []string))
Serve calls fn, on its own goroutine, with the arguments of each later instance that forwards its launch. It does nothing when another instance holds the lock.