Documentation
¶
Overview ¶
Package linux implements the Linux backend (GTK 3 + WebKitGTK) in pure Go: the libraries are loaded at run time with purego, no cgo.
Index ¶
- func LinkContentRules()
- func LinkContextMenus()
- func LinkDMABUFProbe()
- func LinkMenuIcons()
- func LinkNotificationImages()
- func LinkNowPlaying()
- func TestAccessStatesAndRelations(handle uintptr, label string) (states []string, relations map[string][]string, ok bool)
- func TestAccessibilityEnabled(handle uintptr, label string) (enabled, focusable, ok bool)
- func TestAccessibilityPerform(handle uintptr, label, action, value string) bool
- func TestActivateAccelerator(handle uintptr, acc string) bool
- func TestActivateMenuItem(handle uintptr, path ...string) error
- func TestActivateTray() bool
- func TestBackgroundThrottlingOff(handle uintptr, webView bool) (off bool, features int)
- func TestCancelDataDrag(handle uintptr)
- func TestChoosePageMenuItem(label string) bool
- func TestChoosePopupItem(label string) bool
- func TestClickPage(handle uintptr, x, y float64) bool
- func TestClickSurface(handle uintptr, x, y float64) bool
- func TestCloseMenuBar(handle uintptr)
- func TestComposeOver(handle uintptr, text string, caret int, commit bool, from, length int) bool
- func TestDataDragReady(handle uintptr) bool
- func TestDataDragResources() int
- func TestDefaultURLHandler(scheme string) string
- func TestDismissPageMenu()
- func TestDismissPopups() int
- func TestDragSurface(handle uintptr, points [][2]float64) bool
- func TestDropFiles(handle uintptr, x, y float64, paths []string) (over, dropped bool)
- func TestFrameClockInterval(handle uintptr) (interval int64, mhz int32)
- func TestGLDamage(handle uintptr) (damage []image.Rectangle, area image.Point, scale int, ok bool)
- func TestHasRecentItem(path string) bool
- func TestHoldKey(name string, press bool) bool
- func TestInputPending() bool
- func TestMenuBarState(handle uintptr) (shown, open bool)
- func TestMenuItemEnabled(handle uintptr, path ...string) (bool, error)
- func TestMenuItemIcon(handle uintptr, path ...string) (width, height int, checked bool, err error)
- func TestMockCaptureDevices(handle uintptr) bool
- func TestMovePointer(x, y int) bool
- func TestMoveSurfacePointer(handle uintptr, x, y float64) bool
- func TestPageGestures(handle uintptr, webView int) (swipe, pinch, ok bool)
- func TestPageMenu() ([]string, bool)
- func TestPinchPage(handle uintptr, webView int, x, y float64, scales []float64) bool
- func TestPinchSurface(handle uintptr, x, y, scale float64) bool
- func TestPopupItemEnabled(label string) (enabled, ok bool)
- func TestPopups() [][]string
- func TestPressButton(press bool) bool
- func TestPressKeys(names ...string) bool
- func TestPressTitleButton(handle uintptr, name string) bool
- func TestProbeGL() (renderer, failure string, freed func() bool)
- func TestResizeCursor(handle uintptr) string
- func TestRestoreKeyboard(k TestKeyboard)
- func TestRightClickPage(handle uintptr, x, y float64) bool
- func TestRightClickSurface(handle uintptr, x, y float64) bool
- func TestSetDroppedFiles(handle uintptr, paths []string)
- func TestSideButton(handle uintptr, back bool) bool
- func TestStartSerializedDrag(handle uintptr, d transfer.Data, ops transfer.Operation, ...) bool
- func TestSurfaceGL(handle uintptr) (how string, pix []byte, width, height int)
- func TestSurfaceOnScreen(handle uintptr) []byte
- func TestSurrounding(handle uintptr) (text string, caret int, ok bool)
- func TestTitleButtonSizes(handle uintptr) [][2]int
- func TestTitleButtons(handle uintptr) []string
- func TestTrayActivates() bool
- func TestTrayIcon() string
- func TestUsePortalShortcuts(on bool) bool
- func TestWheelSurface(handle uintptr, x, y float64) bool
- func TestWindowTitle(handle uintptr) string
- type Backend
- func (b *Backend) App() platform.AppController
- func (b *Backend) Applications() ([]platform.Application, error)
- func (b *Backend) Clipboard() platform.Clipboard
- func (b *Backend) Dialogs() platform.Dialogs
- func (b *Backend) Init(h platform.AppHandler, opts platform.AppOptions) error
- func (b *Backend) IsMainThread() bool
- func (b *Backend) Name() string
- func (b *Backend) Network() platform.Network
- func (*Backend) NewFileWatch(notify func(platform.FileWatchNotice)) (platform.FileWatch, error)
- func (b *Backend) NewTray(h platform.TrayHandler) (platform.Tray, error)
- func (b *Backend) NewWindow(o *platform.WindowOptions, h platform.WindowHandler) (platform.Window, error)
- func (b *Backend) NotificationsSupported() bool
- func (b *Backend) NowPlaying() platform.NowPlaying
- func (b *Backend) PopupMenu(m *platform.Menu, pw platform.Window, pos *platform.Point)
- func (b *Backend) Power() platform.Power
- func (b *Backend) Quit()
- func (b *Backend) RegisterHotkey(id int, acc string) error
- func (b *Backend) RemoveAllNotifications()
- func (b *Backend) RemoveNotification(id string)
- func (*Backend) ReplaceFile(target, replacement string) error
- func (b *Backend) Run() error
- func (b *Backend) Screen() platform.Screen
- func (b *Backend) Secrets() platform.Secrets
- func (b *Backend) SetApplicationMenu(m *platform.Menu)
- func (b *Backend) SetStyleSheet(css string) error
- func (b *Backend) Shell() platform.Shell
- func (b *Backend) ShowNotification(n *platform.Notification, done func(error))
- func (b *Backend) Signal()
- func (b *Backend) Step()
- func (b *Backend) Theme() platform.Theme
- func (b *Backend) UnregisterHotkey(id int)
- func (b *Backend) UpdateMenuItem(it *platform.MenuItem)
- func (b *Backend) Wake()
- func (b *Backend) WebViewAvailable() bool
- func (b *Backend) WindowButtons() (start, end []string)
- type Decorations
- type TestAccessNode
- type TestKeyboard
- type TitleBarStyle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LinkContentRules ¶
func LinkContentRules()
LinkContentRules links the code of content rules, when the app first compiles rules.
func LinkContextMenus ¶
func LinkContextMenus()
LinkContextMenus links the code of pages' context menus, when the app first listens to them (Page.OnContextMenu).
func LinkDMABUFProbe ¶
func LinkDMABUFProbe()
LinkDMABUFProbe links the code that looks at the host, when the app asks for "auto".
func LinkMenuIcons ¶
func LinkMenuIcons()
LinkMenuIcons links the code of the icons of menu items, when the app first gives an item one.
func LinkNotificationImages ¶
func LinkNotificationImages()
LinkNotificationImages links the code of notifications' images, when the app first makes a notification with one.
func LinkNowPlaying ¶
func LinkNowPlaying()
LinkNowPlaying links the code of NowPlaying, when the app first shows what it plays.
func TestAccessStatesAndRelations ¶
func TestAccessStatesAndRelations(handle uintptr, label string) (states []string, relations map[string][]string, ok bool)
TestAccessStatesAndRelations reads the element labeled label of a window showing native UI as assistive technology does: the names of its ATK states, and the labels of the elements each of its relations points to, by the relation's name. ok is false without such an element.
func TestAccessibilityEnabled ¶
TestAccessibilityEnabled reports whether the element labeled label is enabled and focusable for assistive technology, as ATK's enabled and focusable states say, and ok false without one.
func TestAccessibilityPerform ¶
TestAccessibilityPerform acts on the element labeled label as assistive technology does: "press", "increment", "decrement", "focus", or "value" to set its text to value. It reports whether the element can.
func TestActivateAccelerator ¶
TestActivateAccelerator presses a window's shortcut, as its keys do, and reports whether a menu item took it.
func TestActivateMenuItem ¶
TestActivateMenuItem activates an item of a window's menu bar, found by the labels along its path. plugins/automation's menu request chooses items with it too.
func TestActivateTray ¶
func TestActivateTray() bool
TestActivateTray activates the tray icon made last, as a panel does when its icon is double-clicked. It reports false when the icon answers no activation: no click has anywhere to go.
func TestBackgroundThrottlingOff ¶
TestBackgroundThrottlingOff reports whether the page of a window, or of its first web view, has every background throttling feature WebKitGTK has turned off, and how many it has.
func TestCancelDataDrag ¶
func TestCancelDataDrag(handle uintptr)
func TestChoosePageMenuItem ¶
TestChoosePageMenuItem chooses the item labeled label (without its mnemonic) of the context menu shown over a page, which closes it, and reports whether it has one.
func TestChoosePopupItem ¶
TestChoosePopupItem chooses the item labeled label of a context menu being shown, and closes the menu, and reports whether it has one.
func TestClickPage ¶
TestClickPage clicks (x, y), in DIPs, in the page of a window's web view, through XTEST, as a user clicks it.
func TestClickSurface ¶
TestClickSurface clicks (x, y), in DIPs, in a window showing native UI, through the XTEST extension like a mouse would. It reports false for a window showing a web page, and without an X server.
func TestCloseMenuBar ¶
func TestCloseMenuBar(handle uintptr)
TestCloseMenuBar closes the menus of a window's menu bar, as Escape does.
func TestComposeOver ¶
TestComposeOver does what an input method that edits typed text does: it deletes length runes from offset from of the text around the caret unless from is -1, then composes text with the caret at caret, or commits it.
func TestDataDragReady ¶
func TestDataDragResources ¶
func TestDataDragResources() int
func TestDefaultURLHandler ¶
TestDefaultURLHandler returns the id of the application GLib opens URLs of scheme with, as xdg-open and GTK apps do.
func TestDismissPageMenu ¶
func TestDismissPageMenu()
TestDismissPageMenu closes the context menu shown over a page, if one is.
func TestDismissPopups ¶
func TestDismissPopups() int
TestDismissPopups closes the context menus being shown, as if the user pressed Escape, and reports how many there were.
func TestDragSurface ¶
TestDragSurface presses the primary button at the first of points, in DIPs, in a window showing native UI, moves the pointer through the others, and releases it at the last, through XTEST.
func TestDropFiles ¶
TestDropFiles drags files to (x, y) of a window showing native UI and drops them there, as GTK tells it, and reports whether the content took them over there and when dropped.
func TestFrameClockInterval ¶
TestFrameClockInterval returns the refresh interval, in microseconds, in the timings of the last frame of the frame clock of a window showing native UI, which the clock waits after it for the next (paceFrameClock), and the refresh rate of the monitor showing the window in millihertz.
func TestGLDamage ¶
TestGLDamage returns what the paints of a window of native UI drawing with OpenGL told a Wayland compositor they changed since the last call, beside GTK's own damage (damageGLPaint), in the window's coordinates; where its GtkGLArea is in them; and the window's scale. The first call starts recording. It returns ok false but on Wayland, for a GtkGLArea.
func TestHasRecentItem ¶
TestHasRecentItem reports whether the shared recent files list holds the file at path, as App.AddRecentDocument put it there.
func TestHoldKey ¶
TestHoldKey presses the key of X keysym name and holds it, or releases it, through the XTEST extension: held, the X server's auto-repeat presses it again until it is released. It reports false without an X server, or without that key in the keyboard's layout.
func TestInputPending ¶
func TestInputPending() bool
TestInputPending reports whether the app has events it has yet to handle: once it reports false after a hook faked input through XTEST, the app handled that input, as a window's content does on the main thread when GDK hands it an event. GDK leaves out a last motion, which it holds until the window's next frame to merge it with the next ones.
func TestMenuBarState ¶
TestMenuBarState reports whether a window shows its menu bar, and whether the bar's first menu is open.
func TestMenuItemEnabled ¶
TestMenuItemEnabled reports whether an item of a window's menu bar, found as TestActivateMenuItem finds it, is sensitive once the bar's menu holding it opens.
func TestMenuItemIcon ¶
TestMenuItemIcon reports the size, in points, of the icon an item of a window's menu bar shows, 0 by 0 for none, and whether the item is checked.
func TestMockCaptureDevices ¶
TestMockCaptureDevices turns on a window's MediaStream and WebKit's mock camera and microphone, which getUserMedia() captures without devices, for the pages it loads from then on.
func TestMovePointer ¶
TestMovePointer moves the pointer to a point of the screen through the XTEST extension like a mouse would. It reports false without an X server.
func TestMoveSurfacePointer ¶
TestMoveSurfacePointer sends real XTEST motion to the surface, including during GTK's native drag tracker. It is unavailable outside X11.
func TestPageGestures ¶
TestPageGestures reports whether a swipe navigates and a pinch magnifies the page of a window, or with webView 0 or more, of its web view of that index: the web view's enable-back-forward-navigation-gestures setting, and whether its zoom gesture takes events. ok is false without that page or on WebKitGTK older than 2.38, whose zoom gesture can't be reached.
func TestPageMenu ¶
TestPageMenu returns the labels of the items of the context menu shown over a page, without their mnemonics' underscores, "-" for separators, and false when none is shown.
func TestPinchPage ¶
TestPinchPage pinches a touchpad at (x, y), in DIPs, over the page of a window, or with webView 0 or more, of its web view of that index, from 1 through scales, as TestPinchSurface does over native UI.
func TestPinchSurface ¶
TestPinchSurface pinches a touchpad at (x, y), in DIPs, in a window showing native UI, from 1 to scale: the begin, update and end events of GDK's pinch, which only Wayland makes, go through GTK as its own do.
func TestPopupItemEnabled ¶
TestPopupItemEnabled reports whether the item labeled label of a context menu being shown is sensitive, and whether there is one.
func TestPopups ¶
func TestPopups() [][]string
TestPopups returns the labels of the items of the context menus being shown, "-" for separators.
func TestPressButton ¶
TestPressButton presses or releases the first mouse button the same way.
func TestPressKeys ¶
TestPressKeys presses keys, X keysym names such as "Control_L", together and releases them, through the XTEST extension like a keyboard would. It reports false without an X server.
func TestPressTitleButton ¶
TestPressTitleButton clicks one of them.
func TestProbeGL ¶
TestProbeGL probes OpenGL as the first window of native UI does, and returns what it found and a function that reports whether GDK freed the probe's window; nil where GDK keeps it: GTK 3 on Wayland never drops a reference of its own.
func TestResizeCursor ¶
TestResizeCursor returns the name of the resize cursor a frameless window shows over an edge of its page, or "".
func TestRestoreKeyboard ¶
func TestRestoreKeyboard(k TestKeyboard)
TestRestoreKeyboard puts the keyboard back in state k, which held no key that it doesn't hold now, pressing the lock keys that differ.
func TestRightClickPage ¶
TestRightClickPage clicks (x, y) in a window's page with the secondary button, as TestClickPage does with the primary.
func TestRightClickSurface ¶
TestRightClickSurface clicks (x, y) with the secondary button, as TestClickSurface does with the primary.
func TestSetDroppedFiles ¶
TestSetDroppedFiles makes paths the files of the next drop on a window's page, as if they had been dragged there.
func TestSideButton ¶
TestSideButton clicks a mouse's back or forward button (buttons 8 and 9) in a window showing native UI, through XTEST.
func TestStartSerializedDrag ¶
func TestStartSerializedDrag(handle uintptr, d transfer.Data, ops transfer.Operation, done func(transfer.Result)) bool
TestStartSerializedDrag simulates another application: the source uses GTK's production providers with no token in MyGo's local registry.
func TestSurfaceGL ¶
TestSurfaceGL tells how the native UI of a window draws: "opengl" when its renderer draws in the GtkGLArea, "memory" when the GtkGLArea shows frames drawn on the CPU, "cairo" when a drawing area, or a GtkGLArea without a context, paints them with cairo, and "" before the first frame. For a GtkGLArea it returns its framebuffer's pixels too, premultiplied BGRA rows from the top, and their size.
func TestSurfaceOnScreen ¶
TestSurfaceOnScreen returns, as a PNG, what the display shows of the surface of a window: GTK repaints only what frames drawn in memory changed, and keeps the rest.
func TestSurrounding ¶
TestSurrounding returns the text around the caret that input methods get from a window showing native UI, and the caret's offset in runes. GTK's own input method reads it back: others, as fcitx5's, keep it to themselves, so the window's input switches to GTK's.
func TestTitleButtonSizes ¶
TestTitleButtonSizes returns the sizes GTK gave the title buttons over the page of a window with a hidden title bar, in DIPs, inside their CSS margins.
func TestTitleButtons ¶
TestTitleButtons returns the names of the title buttons over the page of a window with a hidden title bar.
func TestTrayActivates ¶
func TestTrayActivates() bool
TestTrayActivates tells whether the AppIndicator library can report activation at all; call it after making a tray.
func TestTrayIcon ¶
func TestTrayIcon() string
TestTrayIcon returns the icon the tray icon made last gives the panel (app_indicator_get_icon), "" for none.
func TestUsePortalShortcuts ¶
TestUsePortalShortcuts makes global shortcuts bind through the XDG desktop portal, as on Wayland, and reports whether the desktop offers it.
func TestWheelSurface ¶
TestWheelSurface turns a mouse's wheel a notch down at (x, y), in DIPs, in a window showing native UI, through XTEST (button 5), over whatever shows there: the content, or a web view's page.
func TestWindowTitle ¶
TestWindowTitle returns the title GTK gives a window.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend is the Linux (GTK 3 + WebKitGTK) implementation of platform.Backend.
func New ¶
func New() *Backend
New creates the Linux backend. Libraries are loaded by Init so that programs still start (and report a clear error) on machines without GTK.
func (*Backend) App ¶
func (b *Backend) App() platform.AppController
func (*Backend) Applications ¶
func (b *Backend) Applications() ([]platform.Application, error)
Applications lists the applications of the desktop entries that menus show (g_app_info_should_show: not NoDisplay or Hidden, and meant for this desktop), with their names in the user's language, their desktop file IDs and the paths of their entries. GIO is thread-safe.
func (*Backend) Init ¶
func (b *Backend) Init(h platform.AppHandler, opts platform.AppOptions) error
func (*Backend) IsMainThread ¶
IsMainThread reports whether the caller runs on the thread the process started with, whose thread id is the process id. Package mygo locks the main goroutine to it, so this holds before Init too.
func (*Backend) NewFileWatch ¶
func (*Backend) NewWindow ¶
func (b *Backend) NewWindow(o *platform.WindowOptions, h platform.WindowHandler) (platform.Window, error)
func (*Backend) NotificationsSupported ¶
func (*Backend) NowPlaying ¶
func (b *Backend) NowPlaying() platform.NowPlaying
func (*Backend) RemoveAllNotifications ¶
func (b *Backend) RemoveAllNotifications()
func (*Backend) RemoveNotification ¶
func (*Backend) ReplaceFile ¶
ReplaceFile renames replacement over target, after giving it the target's permissions and, where the user may, its owner and group, as GIO's g_file_replace does.
func (*Backend) SetApplicationMenu ¶
func (*Backend) SetStyleSheet ¶
SetStyleSheet loads css into a new provider and puts it in place of the one before, which stays when css does not parse: GTK resets a provider before it parses, and keeps the rules before an error.
func (*Backend) ShowNotification ¶
func (b *Backend) ShowNotification(n *platform.Notification, done func(error))
func (*Backend) UnregisterHotkey ¶
func (*Backend) UpdateMenuItem ¶
func (*Backend) WebViewAvailable ¶
WebViewAvailable reports whether a window showing a web page can have one: WebKitGTK, JavaScriptCore and libsoup, which it needs. Windows showing native UI need GTK alone, so an app whose windows all do runs without them. Loading the libraries is as much as can be known before a page loads.
func (*Backend) WindowButtons ¶
WindowButtons returns the buttons of the desktop's layout, none where the compositor decorates windows itself (platform.WindowButtonsBackend).
type Decorations ¶
type Decorations struct {
// CSD tells that GTK decorates the window itself (useCSD).
CSD bool
// Room is the room its decorations take around the window's content,
// left, top, right and bottom: the shadow and the border, where GTK
// resizes the window. Content is the size of the page or the native
// UI, below a menu bar.
Room [4]int
Content [2]int
// OnX11 tells the display.
OnX11 bool
}
Decorations are what TestDecorations reports.
func TestDecorations ¶
func TestDecorations(handle uintptr) Decorations
TestDecorations reports how GTK decorates a window.
type TestAccessNode ¶
type TestAccessNode struct {
Role, Label, Value, Description string
// Busy, Active, Selectable, Selected, Multiselectable, Focused and
// SupportsAutocompletion are its ATK states of those names,
// Attributes its object attributes, and Selection whether it
// implements AtkSelection.
Busy, Active, Selectable, Selected, Multiselectable, Focused bool
SupportsAutocompletion, Selection bool
Attributes map[string]string
// contains filtered or unexported fields
}
TestAccessNode is an element of native UI as assistive technology reads it through ATK: the name of its role, its name, its value, and its description.
func TestAccessibility ¶
func TestAccessibility(handle uintptr) ([]TestAccessNode, bool)
TestAccessibility reads the elements of a window showing native UI as assistive technology does, in order, and reports false when it cannot.
type TestKeyboard ¶
type TestKeyboard struct {
Locks uint32 // the bits of testLockKeys on
Held string // the keys TestHoldKey holds, sorted
}
TestKeyboard is what the X server keeps of a keyboard from one test to the next, as all of a package's tests share it.
func TestKeyboardState ¶
func TestKeyboardState() (TestKeyboard, bool)
TestKeyboardState returns the keyboard's state, and false without an X server.
func (TestKeyboard) String ¶
func (k TestKeyboard) String() string
type TitleBarStyle ¶
type TitleBarStyle struct {
// Button is the size a title button asks for, in DIPs, inside its CSS
// margins: its border box.
Button [2]int
// Background is the header bar's background color.
Background [4]float64
}
TitleBarStyle is how GTK styles a header bar and its title buttons.
func TestTitleBarStyle ¶
func TestTitleBarStyle() TitleBarStyle
TestTitleBarStyle makes a header bar holding a title button, as GTK's own title bars do, and returns how the style providers style them.
Source Files
¶
- app.go
- apps.go
- auth.go
- clipboard.go
- content_rules.go
- context_menu.go
- cookies.go
- deeplink.go
- dialog.go
- dmabuf.go
- download.go
- ffi.go
- flyout.go
- glprobe.go
- hotkey.go
- hotkey_portal.go
- icon.go
- keyrepeat.go
- layer.go
- locale.go
- login.go
- menu.go
- menuicon.go
- network.go
- notify_image.go
- nowplaying.go
- panel.go
- portal.go
- power.go
- replace.go
- scheme.go
- secrets.go
- session.go
- session_state.go
- style.go
- surface.go
- surface_access.go
- surface_drop.go
- surface_input.go
- system.go
- testhooks.go
- testhooks_gl.go
- testhooks_surface.go
- titlebar.go
- touch.go
- watch.go
- webview.go
- window.go