linux

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 34 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 linux implements the Linux backend (GTK 3 + WebKitGTK) in pure Go: the libraries are loaded at run time with purego, no cgo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestAccessibilityPerform

func TestAccessibilityPerform(handle uintptr, label, action, value string) bool

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

func TestActivateAccelerator(handle uintptr, acc string) bool

TestActivateAccelerator presses a window's shortcut, as its keys do, and reports whether a menu item took it.

func TestActivateMenuItem

func TestActivateMenuItem(handle uintptr, path ...string) error

TestActivateMenuItem activates an item of a window's menu bar, found by the labels along its path.

func TestCancelDataDrag

func TestCancelDataDrag(handle uintptr)

func TestChoosePopupItem

func TestChoosePopupItem(label string) bool

TestChoosePopupItem chooses the item labeled label of a context menu being shown, and closes the menu, and reports whether it has one.

func TestClickSurface

func TestClickSurface(handle uintptr, x, y float64) bool

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

func TestComposeOver(handle uintptr, text string, caret int, commit bool, from, length int) bool

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 TestDataDragReady(handle uintptr) bool

func TestDataDragResources

func TestDataDragResources() int

func TestDefaultURLHandler

func TestDefaultURLHandler(scheme string) string

TestDefaultURLHandler returns the id of the application GLib opens URLs of scheme with, as xdg-open and GTK apps do.

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

func TestDragSurface(handle uintptr, points [][2]float64) bool

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

func TestDropFiles(handle uintptr, x, y float64, paths []string) (over, dropped bool)

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 TestHasRecentItem

func TestHasRecentItem(path string) bool

TestHasRecentItem reports whether the shared recent files list holds the file at path, as App.AddRecentDocument put it there.

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

func TestMenuBarState(handle uintptr) (shown, open bool)

TestMenuBarState reports whether a window shows its menu bar, and whether the bar's first menu is open.

func TestMovePointer

func TestMovePointer(x, y int) bool

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

func TestMoveSurfacePointer(handle uintptr, x, y float64) bool

TestMoveSurfacePointer sends real XTEST motion to the surface, including during GTK's native drag tracker. It is unavailable outside X11.

func TestPopups

func TestPopups() [][]string

TestPopups returns the labels of the items of the context menus being shown, "-" for separators.

func TestPressButton

func TestPressButton(press bool) bool

TestPressButton presses or releases the first mouse button the same way.

func TestPressKeys

func TestPressKeys(names ...string) bool

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

func TestPressTitleButton(handle uintptr, name string) bool

TestPressTitleButton clicks one of them.

func TestResizeCursor

func TestResizeCursor(handle uintptr) string

TestResizeCursor returns the name of the resize cursor a frameless window shows over an edge of its page, or "".

func TestRightClickSurface

func TestRightClickSurface(handle uintptr, x, y float64) bool

TestRightClickSurface clicks (x, y) with the secondary button, as TestClickSurface does with the primary.

func TestSetDroppedFiles

func TestSetDroppedFiles(handle uintptr, paths []string)

TestSetDroppedFiles makes paths the files of the next drop on a window's page, as if they had been dragged there.

func TestSideButton

func TestSideButton(handle uintptr, back bool) bool

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 Golet's local registry.

func TestSurfaceGL

func TestSurfaceGL(handle uintptr) (how string, pix []byte, width, height int)

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

func TestSurfaceOnScreen(handle uintptr) []byte

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

func TestSurrounding(handle uintptr) (text string, caret int, ok bool)

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 TestTitleButtons

func TestTitleButtons(handle uintptr) []string

TestTitleButtons returns the names of the title buttons over the page of a window with a hidden title bar.

func TestUsePortalShortcuts

func TestUsePortalShortcuts(on bool) bool

TestUsePortalShortcuts makes global shortcuts bind through the XDG desktop portal, as on Wayland, and reports whether the desktop offers it.

func TestWindowTitle

func TestWindowTitle(handle uintptr) string

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) Clipboard

func (b *Backend) Clipboard() platform.Clipboard

func (*Backend) Dialogs

func (b *Backend) Dialogs() platform.Dialogs

func (*Backend) Init

func (*Backend) IsMainThread

func (b *Backend) IsMainThread() bool

IsMainThread reports whether the caller runs on the thread the process started with, whose thread id is the process id. Package golet locks the main goroutine to it, so this holds before Init too.

func (*Backend) Name

func (b *Backend) Name() string

func (*Backend) Network

func (b *Backend) Network() platform.Network

func (*Backend) NewFileWatch

func (*Backend) NewFileWatch(notify func(platform.FileWatchNotice)) (platform.FileWatch, error)

func (*Backend) NewTray

func (b *Backend) NewTray(h platform.TrayHandler) (platform.Tray, error)

func (*Backend) NewWindow

func (*Backend) NotificationsSupported

func (b *Backend) NotificationsSupported() bool

func (*Backend) PopupMenu

func (b *Backend) PopupMenu(m *platform.Menu, pw platform.Window, pos *platform.Point)

PopupMenu shows a context menu and blocks until it is dismissed.

func (*Backend) Power

func (b *Backend) Power() platform.Power

func (*Backend) Quit

func (b *Backend) Quit()

func (*Backend) RegisterHotkey

func (b *Backend) RegisterHotkey(id int, acc string) error

func (*Backend) RemoveAllNotifications

func (b *Backend) RemoveAllNotifications()

func (*Backend) RemoveNotification

func (b *Backend) RemoveNotification(id string)

func (*Backend) ReplaceFile

func (*Backend) ReplaceFile(target, replacement string) error

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) Run

func (b *Backend) Run() error

func (*Backend) Screen

func (b *Backend) Screen() platform.Screen

func (*Backend) Secrets

func (b *Backend) Secrets() platform.Secrets

func (*Backend) SetApplicationMenu

func (b *Backend) SetApplicationMenu(m *platform.Menu)

func (*Backend) Shell

func (b *Backend) Shell() platform.Shell

func (*Backend) ShowNotification

func (b *Backend) ShowNotification(n *platform.Notification, done func(error))

func (*Backend) Signal

func (b *Backend) Signal()

func (*Backend) Step

func (b *Backend) Step()

func (*Backend) Theme

func (b *Backend) Theme() platform.Theme

func (*Backend) UnregisterHotkey

func (b *Backend) UnregisterHotkey(id int)

func (*Backend) UpdateMenuItem

func (b *Backend) UpdateMenuItem(it *platform.MenuItem)

func (*Backend) Wake

func (b *Backend) Wake()

func (*Backend) WebViewAvailable

func (b *Backend) WebViewAvailable() bool

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.

type TestAccessNode

type TestAccessNode struct {
	Role, Label, Value 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, and its value.

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.

Jump to

Keyboard shortcuts

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