x11window

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 11 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 x11window implements the Pure-Go X11 window contract.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWindowNotFound reports that no X11 client matched the target.
	ErrWindowNotFound = windowbackend.ErrWindowNotFound
	// ErrInvalidWindow reports a zero, stale, or invalid XID.
	ErrInvalidWindow = windowbackend.ErrInvalidWindow
	// ErrOperation reports a failed X11 window operation.
	ErrOperation = windowbackend.ErrOperation
)
View Source
var ErrWindowManagerUnavailable = fmt.Errorf(
	"%w: EWMH window manager unavailable",
	windowbackend.ErrUnsupported,
)

ErrWindowManagerUnavailable reports that a state/control request has no consistent EWMH manager or is not advertised by that manager.

Functions

This section is empty.

Types

type Backend

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

Backend resolves public targets and validates every operation before it is delegated to X11.

func New

func New(system System) *Backend

New constructs a Pure-Go X11 window backend.

func NewNative

func NewNative(config Config) *Backend

NewNative constructs a backend that opens and closes an X11 connection for each public operation.

func (*Backend) Activate

func (backend *Backend) Activate(handle windowbackend.Handle) error

Activate requests EWMH activation for a valid window.

func (*Backend) Active

func (backend *Backend) Active() (windowbackend.Handle, error)

Active returns the current valid active or focused X11 window.

func (*Backend) Bounds

func (backend *Backend) Bounds(handle windowbackend.Handle, client bool) (windowbackend.Rect, error)

Bounds returns outer or client geometry in root coordinates.

func (*Backend) Close

func (backend *Backend) Close(handle windowbackend.Handle) error

Close requests a graceful EWMH close.

func (*Backend) PID

func (backend *Backend) PID(handle windowbackend.Handle) (int, error)

PID returns the owning process ID from _NET_WM_PID.

func (*Backend) Resolve

func (backend *Backend) Resolve(target int, isHandle bool) (windowbackend.Handle, error)

Resolve maps a positive process ID or explicit XID to a valid window.

func (*Backend) Select

func (backend *Backend) Select(target int, isHandle bool) error

Select stores a resolved compatibility handle.

func (*Backend) Selected

func (backend *Backend) Selected() windowbackend.Handle

Selected returns the compatibility handle stored by Select.

func (*Backend) SetState

func (backend *Backend) SetState(handle windowbackend.Handle, state windowbackend.State, enabled bool) error

SetState changes minimized or maximized state through the window manager.

func (*Backend) SetTopMost

func (backend *Backend) SetTopMost(handle windowbackend.Handle, enabled bool) error

SetTopMost changes the EWMH ABOVE state.

func (*Backend) State

func (backend *Backend) State(handle windowbackend.Handle, state windowbackend.State) (bool, error)

State queries minimized or maximized state from _NET_WM_STATE.

func (*Backend) Title

func (backend *Backend) Title(handle windowbackend.Handle) (string, error)

Title returns a non-empty EWMH or ICCCM title.

func (*Backend) TopMost

func (backend *Backend) TopMost(handle windowbackend.Handle) (bool, error)

TopMost reports the EWMH ABOVE state.

type Config

type Config struct {
	ResolveDisplay func() (string, error)
}

Config controls X11 connection selection.

type System

type System interface {
	ActiveWindow() (windowbackend.Handle, error)
	WindowExists(windowbackend.Handle) (bool, error)
	FindWindowByPID(uint32) (windowbackend.Handle, error)
	WindowProcessID(windowbackend.Handle) (uint32, error)
	WindowText(windowbackend.Handle) (string, error)
	WindowRect(windowbackend.Handle) (windowbackend.Rect, error)
	ClientRect(windowbackend.Handle) (windowbackend.Rect, error)
	ActivateWindow(windowbackend.Handle) error
	SetWindowState(windowbackend.Handle, windowbackend.State, bool) error
	WindowState(windowbackend.Handle, windowbackend.State) (bool, error)
	IsTopMost(windowbackend.Handle) (bool, error)
	SetTopMost(windowbackend.Handle, bool) error
	CloseWindow(windowbackend.Handle) error
}

System abstracts X11 discovery, property queries, and EWMH requests.

Jump to

Keyboard shortcuts

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