Documentation
¶
Overview ¶
Package window is a pure-Go (CGO-free, no Xlib/XCB) X11 windowing backend for the go-widgets toolkit. It opens a real window on an X11 server, blits the toolkit's RGBA framebuffer into it via the core protocol's PutImage, and routes X input events into toolkit.Event, so a go-widgets widget tree runs on a Linux desktop exactly as it does in the browser/wasm host.
The X11 protocol itself is implemented from scratch in the internal/x11 package over a raw byte stream, mirroring the sovereign transport+codec approach of github.com/go-freedesktop/dbus.
Open dials the server named by $DISPLAY; it is implemented on Linux and returns ErrUnsupported elsewhere, so cross-builds stay green. The windowing logic (framebuffer, present, event translation, run loop) is platform-independent and driven through the transport-agnostic internal/x11 connection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupported = errors.New("window: a native windowing backend is only supported on Linux")
ErrUnsupported is returned by Open on platforms with no windowing backend (non-Linux).
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
// Run binds root, performs the initial layout+present, then dispatches
// server/compositor events into the widget tree until the window closes.
Run(root toolkit.Widget) error
// Close releases the window and its connection.
Close() error
// Size returns the current client size in pixels.
Size() (int, int)
// String identifies the window for debugging.
String() string
}
Backend is an open, backend-specific window bound to a go-widgets scene. Both the X11 (*Window) and the Wayland backend satisfy it, so Open can return whichever the environment selects and a go-widgets application is backend-agnostic: it just calls Run, Size, String and Close.
func Open ¶
Open connects to the running display server and returns a window ready for Run. It auto-selects the backend: Wayland when $WAYLAND_DISPLAY is set (the modern default on contemporary Linux desktops), otherwise the X11 backend driven by $DISPLAY. Both are sovereign, pure-Go, CGO-free implementations of their wire protocols.
type Config ¶
type Config struct {
// Title is the WM_NAME shown in the title bar.
Title string
// Instance and Class populate WM_CLASS (window-manager grouping). When
// empty they default to Title (Instance) and Title (Class).
Instance string
Class string
// Width and Height are the initial client size in pixels.
Width int
Height int
// Display overrides $DISPLAY (e.g. ":0"). Empty uses the environment.
Display string
// Theme overrides the toolkit theme used to paint the background and
// widgets. Nil uses toolkit.DefaultDark.
Theme *toolkit.Theme
}
Config parametrises a window.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is an open X11 window bound to a go-widgets scene. It owns the backing RGBA framebuffer, presents it to the server and drives the toolkit widget tree from X input events.
func (*Window) Run ¶
Run binds root to the window, performs the initial layout+draw+present, then dispatches server events into the toolkit until the window is closed (WM_DELETE_WINDOW) or the connection ends. It is the real-window analogue of the wasm compositor host loop.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
windowdemo
command
Command windowdemo opens a real X11 window (on Linux) showing a few go-widgets widgets, driven by the pure-Go github.com/go-widgets/window backend.
|
Command windowdemo opens a real X11 window (on Linux) showing a few go-widgets widgets, driven by the pure-Go github.com/go-widgets/window backend. |
|
internal
|
|
|
wayland
Package wayland is a from-scratch, pure-Go (CGO-free, zero non-stdlib dependency) implementation of the Wayland wire protocol, spoken directly over a UNIX-domain stream socket.
|
Package wayland is a from-scratch, pure-Go (CGO-free, zero non-stdlib dependency) implementation of the Wayland wire protocol, spoken directly over a UNIX-domain stream socket. |
|
x11
Package x11 is a from-scratch, pure-Go (CGO-free, zero non-stdlib dependency) implementation of the X Window System core protocol, version 11.0, spoken directly over a byte stream (a unix-domain socket in practice).
|
Package x11 is a from-scratch, pure-Go (CGO-free, zero non-stdlib dependency) implementation of the X Window System core protocol, version 11.0, spoken directly over a byte stream (a unix-domain socket in practice). |