Documentation
¶
Overview ¶
Package nativeui is the interface of the desktop app's native windows: the types internal/desktop programs against, and the registration through which internal/webview provides them. Only the desktop app's binary (cmd/remohop-quick) links internal/webview; in any other binary (the static remohop command line tool) nothing is registered, Probe reports ErrUnavailable and the app falls back to a browser window.
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrUnavailable means this system has no usable native web view: no WebView2 runtime on Windows, no WebKitGTK library on Linux, an unknown platform. Callers fall back to a browser window.
Functions ¶
func FitArea ¶
FitArea shrinks a window's size, and its minimum size, to fit a work area of areaW x areaH (the screen minus task bar, Dock or panels, in the same units). A window takes at most 92% of the area, so its edges stay clear of them; the minimum never exceeds the area. A zero area (unknown) leaves everything as it is. The overlay banner does not use it: it has its own fixed size.
Types ¶
type App ¶
type App interface {
// NewWindow opens a window showing o.URL.
NewWindow(o Options) (Window, error)
// Dispatch runs fn on the UI thread. It may be called from any
// goroutine, and returns at once.
Dispatch(fn func())
// SetTray shows (or with nil removes) the tray icon. It fails where
// the system has no tray (a Linux desktop without AppIndicator
// support): callers must then not hide their last window.
SetTray(t *Tray) error
// Quit ends Run.
Quit()
}
App is the running native application.
type Config ¶
type Config struct {
// AppID names the program to the windowing system: the Linux
// application name that .desktop files match (WM_CLASS) and the
// AppIndicator ID.
AppID string
// DataDir is where the web engine keeps its profile (cache, local
// storage). WebView2 needs one it can write; the others ignore it.
DataDir string
// IconPNG is the tray icon on Linux and macOS (macOS draws it as a
// template image: only its alpha channel counts).
IconPNG []byte
// TemplatePNG, if set, is the macOS tray icon instead of IconPNG.
TemplatePNG []byte
// OnReopen runs when the user asks for the program again while it
// runs without a visible window (macOS: a click on its Dock icon).
OnReopen func()
// OnQuitRequest, if set, runs when the system asks the program to
// quit (macOS: Quit in the menu or the Dock) instead of quitting; the
// program calls App.Quit when it is ready.
OnQuitRequest func()
}
Config configures Run.
type Info ¶
type Info struct {
// Engine is "WebView2", "WKWebView" or "WebKitGTK".
Engine string
// Version is the engine's version where the system says.
Version string
}
Info describes the native web view of this system.
type Notifier ¶
type Notifier interface {
Notify(title, text string)
}
Notifier is an App that can also show a notification from its tray icon (a balloon or toast on Windows), for when its window may not be seen: hidden in the tray, or behind other windows because the system does not let a background program come to the front.
type Options ¶
type Options struct {
Title string
URL string
Width int // logical pixels; 0 means 960
Height int // 0 means 680
// MinWidth and MinHeight bound resizing (0: no bound).
MinWidth, MinHeight int
// OnClose runs when the user asks to close the window. Returning false
// keeps it open (the caller may hide it instead); true closes it.
// Nil closes it.
OnClose func() bool
// Hidden creates the window without showing it.
Hidden bool
// Overlay makes a small undecorated window that stays above the
// others and out of the task bar, in the bottom-right corner of the
// work area (where notifications appear, clear of the app's own
// window and tab bar): the "this computer is being controlled" banner.
Overlay bool
}
Options configure a window.