Documentation
¶
Overview ¶
Package window maps the xdg-shell role onto a wl_surface: real toplevel windows with titles, the configure handshake, the compositor-confirmed state set, ping/pong liveness, and the close signal.
Index ¶
- Variables
- type Capabilities
- type Config
- type State
- type Window
- func (w *Window) Capabilities() Capabilities
- func (w *Window) Close()
- func (w *Window) Closed() bool
- func (w *Window) Decorate(mgr *xdeco.ZxdgDecorationManagerV1) error
- func (w *Window) DestroySurface()
- func (w *Window) EnsureUsable() error
- func (w *Window) Export(exp *wlr.ZxdgExporterV2) error
- func (w *Window) ExportHandle() string
- func (w *Window) ForeignParented() bool
- func (w *Window) Fullscreen(output *wl.Output) error
- func (w *Window) HandleSurfaceConfigure(ev xdg.SurfaceConfigureEvent)
- func (w *Window) HandleToplevelClose(ev xdg.ToplevelCloseEvent)
- func (w *Window) HandleToplevelConfigure(ev xdg.ToplevelConfigureEvent)
- func (w *Window) HandleToplevelWmCapabilities(ev xdg.ToplevelWmCapabilitiesEvent)
- func (w *Window) HostSurface() *wl.Surface
- func (w *Window) Maximize() error
- func (w *Window) Minimize() error
- func (w *Window) ModalHinted() bool
- func (w *Window) Move(seat *wl.Seat, serial uint32) error
- func (w *Window) Parent() *Window
- func (w *Window) Resize(seat *wl.Seat, serial uint32, edges uint32) error
- func (w *Window) ServerDecorated() bool
- func (w *Window) SetCloseRequest(veto func() bool)
- func (w *Window) SetForeignParent(imp *wlr.ZxdgImporterV2, handle string, lost func()) error
- func (w *Window) SetMaxSize(width, height uint32) error
- func (w *Window) SetMinSize(width, height uint32) error
- func (w *Window) SetMinimized() error
- func (w *Window) SetModal(mgr *wlr.WmDialogV1, modal bool) error
- func (w *Window) SetParent(parent *Window)
- func (w *Window) SetTitle(title string) error
- func (w *Window) Size() (int, int)
- func (w *Window) SizeLimits() (minW, minH, maxW, maxH int)
- func (w *Window) State() State
- func (w *Window) Title() string
- func (w *Window) TooltipSurface() *xdg.Surface
- func (w *Window) Unfullscreen() error
- func (w *Window) Unmaximize() error
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("window: closed")
ErrClosed reports that the window was closed; the objects must not be used again.
var ErrNoImporter = errors.New("window: the compositor has no zxdg_importer_v2")
ErrNoImporter reports a foreign parent asked of a compositor that cannot import an xdg-foreign handle (no zxdg_importer_v2).
var ErrNotConfigured = errors.New("window: not configured yet")
ErrNotConfigured reports a draw attempt before the first configure event. The compositor rejects buffers committed before it.
Functions ¶
This section is empty.
Types ¶
type Capabilities ¶
Capabilities is what the compositor's window management offers a toplevel. Known is false until the compositor said (wm_capabilities, toplevel v5); until then every capability counts as available, the protocol's rule.
type Config ¶
type Config struct {
// Title and AppID identify the window to the compositor.
Title, AppID string
// Width and Height in surface (logical) pixels. Zeros let the
// compositor pick.
Width, Height uint32
// MinWidth and MinHeight constrain how far the compositor may
// resize the window down; zero axes are unconstrained. The app
// clamps layout to the same limits (SizeLimits) in case a
// compositor configures outside them.
MinWidth, MinHeight uint32
// MaxWidth and MaxHeight constrain how far the compositor may
// resize the window up; zero axes are unconstrained.
MaxWidth, MaxHeight uint32
}
Config describes the window before the first commit.
type State ¶
type State struct {
Activated bool // keyboard focus
Maximized bool
Fullscreen bool
Resizing bool // an interactive resize (Resize grab) is streaming
Suspended bool // the compositor stopped the window (not visible)
// The tiled_* bits: the compositor snapped the window to an edge.
TiledLeft, TiledRight, TiledTop, TiledBottom bool
}
State is the compositor-confirmed toplevel state: the state array of the most recent configure event, never the set of requests the client sent. A request (Maximize and friends) is a hint the compositor may refuse, delay, or undo in a later configure; only what arrives in the state array is true, so UI chrome reads this, not the requests.
There is no minimized bit: the protocol reports no state for a minimized (unmapped) window, and State keeps reporting what was last confirmed before it.
type Window ¶
type Window struct {
WLSurface *wl.Surface
XdgSurface *xdg.Surface
Toplevel *xdg.Toplevel
OnCapabilities func(Capabilities)
// contains filtered or unexported fields
}
Window is one toplevel window and its configure handshake.
func New ¶
New assigns the xdg_toplevel role and sends the initial state. The caller must still commit the wl_surface; the compositor answers with the first configure round.
func (*Window) Capabilities ¶
func (w *Window) Capabilities() Capabilities
Capabilities reports the compositor's window-management offer.
func (*Window) Close ¶
func (w *Window) Close()
Close closes the window, from the client side or on the compositor's close request: it destroys the toplevel role, which unmaps the surface, and marks the window closed for the next loop check. The wl_surface stays with its owner. Idempotent.
func (*Window) Decorate ¶
func (w *Window) Decorate(mgr *xdeco.ZxdgDecorationManagerV1) error
Decorate requests server-side title bars and borders through the xdg-decoration manager. A nil manager (compositor without the global) is a silent no-op: the window simply stays undecorated.
func (*Window) DestroySurface ¶
func (w *Window) DestroySurface()
DestroySurface destroys the role objects, if the window still holds them, and then the wl_surface. Idempotent.
func (*Window) EnsureUsable ¶
EnsureUsable gates drawing: the window must have completed the first configure round and must not be closed.
func (*Window) Export ¶
func (w *Window) Export(exp *wlr.ZxdgExporterV2) error
Export publishes the toplevel through xdg-foreign so other clients, xdg-desktop-portal above all, can name it. The compositor answers with the handle asynchronously; ExportHandle reports it once it has arrived. A nil exporter (no xdg-foreign v2) is a no-op, and a second call keeps the first export.
func (*Window) ExportHandle ¶
ExportHandle returns the toplevel's xdg-foreign handle, or "" before the compositor sent it or without an export.
func (*Window) ForeignParented ¶ added in v0.2.15
ForeignParented reports whether the window holds a live import of a foreign parent.
func (*Window) Fullscreen ¶
Fullscreen asks the compositor to show the window fullscreen; a nil output lets the compositor pick (the usual choice). The confirmed fullscreen state arrives with the output-sized configure. See Maximize.
func (*Window) HandleSurfaceConfigure ¶
func (w *Window) HandleSurfaceConfigure(ev xdg.SurfaceConfigureEvent)
HandleSurfaceConfigure completes the configure round: it marks the window configured and acknowledges the serial. Without a wire surface (tests) only the state changes.
func (*Window) HandleToplevelClose ¶
func (w *Window) HandleToplevelClose(ev xdg.ToplevelCloseEvent)
HandleToplevelClose marks the window closed unless a close-request veto rejects it.
func (*Window) HandleToplevelConfigure ¶
func (w *Window) HandleToplevelConfigure(ev xdg.ToplevelConfigureEvent)
HandleToplevelConfigure records the new size. A zero axis leaves the size to the client, per the protocol: the window keeps its size, or returns to its unconstrained size when the configure ends a fullscreen, maximize, or tiling that dictated it. The state array is authoritative: it replaces the confirmed set wholesale, so a configure without a state the client asked for reports the request as refused (or withdrawn).
func (*Window) HandleToplevelWmCapabilities ¶
func (w *Window) HandleToplevelWmCapabilities(ev xdg.ToplevelWmCapabilitiesEvent)
HandleToplevelWmCapabilities records the compositor's offer.
func (*Window) HostSurface ¶
HostSurface returns the underlying wl_surface.
func (*Window) Maximize ¶
Maximize asks the compositor to maximize the window. Like every state request it is a hint: it becomes visible only through a configure carrying the maximized state, which the compositor is free to refuse - judge the outcome through State. A wireless window (tests) sends nothing.
func (*Window) Minimize ¶
Minimize asks the compositor to minimize the window; a hint compositors without a minimized concept ignore.
func (*Window) ModalHinted ¶
ModalHinted reports whether the xdg-dialog modality hint is set on this window (SetModal succeeded with modal true). The compositor's own presentation of the hint is not observable.
func (*Window) Move ¶
Move starts the compositor's xdg_toplevel.move grab: the pointer drags the window from the point of the press with the given serial. Like resize, the grab replaces the widget press.
func (*Window) Resize ¶
Resize hands the pointer grab to the compositor for an interactive resize: it streams configure events as the user drags, and this window repaints at every configured size. seat and serial come from the button press that started the gesture; edges is a combination of the xdg_toplevel.resize_edge bits. A none (zero) edges value or a missing seat is a no-op: there is nothing to resize with.
func (*Window) ServerDecorated ¶
ServerDecorated reports whether server-side decorations were requested: the compositor then owns the window's borders and resize handles, and the client keeps its own edge handles passive. The answer reflects the request; the compositor may still decide otherwise (mode events are not tracked).
func (*Window) SetCloseRequest ¶
SetCloseRequest installs a veto callback: returning false keeps the window open when the compositor asks it to close (an unsaved-changes prompt decides itself when to call Window.Close). Nil accepts every close request.
func (*Window) SetForeignParent ¶ added in v0.2.15
func (w *Window) SetForeignParent(imp *wlr.ZxdgImporterV2, handle string, lost func()) error
SetForeignParent parents this toplevel to another client's, named by the xdg-foreign handle that client exported it as: the compositor keeps this one above it, on its workspace. It replaces the previous parent, foreign or not, and an empty handle leaves none. lost runs once if the import ends, the parent having gone away or the handle naming no toplevel; the window then has no parent.
func (*Window) SetMaxSize ¶
SetMaxSize publishes the largest size the compositor may resize the window to; zero axes are unconstrained. See SetMinSize.
func (*Window) SetMinSize ¶
SetMinSize publishes the smallest size the compositor may resize the window to; zero axes are unconstrained. The limits are also tracked client-side (SizeLimits) so layout clamps to them when a compositor configures outside them anyway. A wireless window (tests) records the limits without sending anything.
func (*Window) SetMinimized ¶
SetMinimized asks the compositor to minimize the window. The protocol defines no minimized state event, so State keeps reporting whatever was confirmed before; treat the window as invisible from here on. See Maximize.
func (*Window) SetModal ¶
func (w *Window) SetModal(mgr *wlr.WmDialogV1, modal bool) error
SetModal hints, through the optional xdg-dialog-v1 protocol, that this parented toplevel is a modal dialog of its parent: the compositor then blocks input to the parent itself, where the toolkit's application-level block only covers this client's windows. The hint rides the surface's next commit, so it should be sent before the first one for the compositor to map the dialog modal from the start.
A nil manager (compositor without the global) or a wireless window (tests) is a silent no-op — modality degrades to the application-level block, which callers keep as the floor. The dialog object is created lazily on the first call and reused after; closing the window unsets and destroys it.
func (*Window) SetParent ¶
SetParent parents this toplevel to another - a dialog, a toolbox that stays above its owner; the compositor keeps it above the parent and may group them. A nil parent clears the association.
func (*Window) SetTitle ¶
SetTitle updates the compositor-visible title at runtime; the xdg_toplevel title is a hint surfaces show in their own chrome (taskbars, alt-tab) - CSD apps paint HeaderBar themselves.
func (*Window) Size ¶
Size returns the last configured size in surface (logical) pixels. An unconfigured window reports zeros.
func (*Window) SizeLimits ¶
SizeLimits returns the current min/max size in surface (logical) pixels; a zero axis is unconstrained.
func (*Window) State ¶
State returns the compositor-confirmed state: what the last configure's state array said, not what the client asked for.
func (*Window) TooltipSurface ¶
TooltipSurface returns the xdg_surface hover tooltips anchor to.
func (*Window) Unfullscreen ¶
Unfullscreen asks the compositor to leave fullscreen. See Maximize.
func (*Window) Unmaximize ¶
Unmaximize asks the compositor to restore the window. See Maximize.