Help us shape the future of Go! Take the 2026 Go Developer Survey

windowapp

package
v0.0.0-...-ea410ed Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package windowapp adapts an *app.App to the window.Handler contract: it exposes the app's double-buffered framebuffer to a native presenter and routes native mouse/scroll/key events into the ui.Scene. It is deliberately decoupled from the window package (it satisfies the interface structurally), so both build on every platform and the routing logic is unit-testable without any Cocoa dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler adapts an app to the presenter's data-source/input-sink interface.

pending* records a text-selectable hit (a feed card, a sidebar row, or a non-interactive reading surface) whose action is DEFERRED from the press to the release: a press begins a text selection instead of acting, and MouseUp decides — a drag that produced a selection suppresses the action and keeps the selection for a copy; a plain click (no drag) runs the recorded action.

func New

func New(a *app.App) *Handler

New wraps a to be driven by a native window. It installs the platform browser opener as the app's sign-in URL opener (through the openURLIn seam, so tests substituting it are honoured), letting the app start a browser sign-in without importing this package.

func (*Handler) A11yElements

func (h *Handler) A11yElements() []window.A11yElement

A11yElements describes what the app is showing, satisfying window.Accessible so a back-end with an accessibility API can expose it.

It is the ui package's tree flattened into the window package's neutral shape. The translation exists precisely so window stays a generic surface that never imports ui: the presenter learns the roles and labels without learning what a feed or a subscription is.

The rects pass through unchanged. ui.A11yNode already carries device-pixel, top-left coordinates — the same space the framebuffer and MouseDown use — so there is nothing to convert here, and the back-end owns the trip to whatever its platform wants.

func (*Handler) ContextMenuActive

func (h *Handler) ContextMenuActive() bool

ContextMenuActive reports whether a context menu is popped up, so the window routes input to it rather than the scene. Satisfies window.ContextMenuHost.

func (*Handler) ContextMenuEvent

func (h *Handler) ContextMenuEvent(ev toolkit.Event)

ContextMenuEvent forwards one input event to the open context menu.

func (*Handler) Frame

func (h *Handler) Frame() ([]byte, int, int, bool)

Frame returns the current framebuffer, its device dimensions, and whether it changed since the last call.

func (*Handler) Key

func (h *Handler) Key(name string, r rune)

Key handles editing keys and printable runes for whichever view/field is focused (topbar search in the feed, or the settings text fields).

func (*Handler) MouseDown

func (h *Handler) MouseDown(x, y int)

MouseDown routes a click across the feed, detail and settings views: open an item, follow a link, switch a filter or profile, or drive the settings editor.

func (*Handler) MouseMove

func (h *Handler) MouseMove(x, y int)

MouseMove forwards pointer motion to the scene. Back-ends deliver a left-button drag as MouseMove, so while a press is held inside the embedded web-preview browser the motion is routed there first as a drag (letting a grabbed scrollbar thumb — horizontal or vertical — track the pointer); otherwise it falls through to the scene, which applies it only while a sidebar/preview-divider drag is in progress.

func (*Handler) MouseUp

func (h *Handler) MouseUp(x, y int)

MouseUp ends any in-progress sidebar-divider drag and releases a pressed web-preview toolbar button (clearing its click-feedback face).

func (*Handler) NativeControls

func (h *Handler) NativeControls() []toolkit.NativeControl

NativeControls describes the interactive controls the app wants backed by real OS controls this frame, satisfying application.NativeControlProvider so a back-end that can embed native controls lays them over the framebuffer. The descriptors are the toolkit's own, already in the framebuffer's device-pixel, top-left space the platform expects — the same reason A11yElements passes its rects through unchanged — so there is nothing to convert here. It is the Scene that decides what should be native; this only forwards its list.

func (*Handler) NeedsPresent

func (h *Handler) NeedsPresent() bool

NeedsPresent reports whether the present loop should repaint now: a queued scene write is waiting, or the scene is still animating. A gated loop uses it to skip the blit on an idle, unchanged window; see internal/window's ticker.

func (*Handler) PresentImmediate

func (h *Handler) PresentImmediate() bool

PresentImmediate reports that queued content must be blitted without throttle delay; the gated present loop uses it to override its spinner throttle.

func (*Handler) PresentThrottle

func (h *Handler) PresentThrottle() bool

PresentThrottle reports that the only motion is the loading spinner, which the gated present loop may redraw below its tick rate; see internal/window.

func (*Handler) Resize

func (h *Handler) Resize(w, height int, scale float64)

Resize maps a logical size to device pixels via the backing scale.

func (*Handler) Scroll

func (h *Handler) Scroll(dy int)

Scroll scrolls the feed by a device-pixel wheel delta, unless the pointer is over the embedded web-preview browser — then the wheel scrolls the page.

func (*Handler) SecondaryClick

func (h *Handler) SecondaryClick(x, y int)

SecondaryClick opens a context menu when the secondary press landed on a sidebar subscription (a real source, not the All filter) or a virtual folder. The menu is the toolkit's own ContextMenu widget — this only builds its items and their actions, which reuse the same scene/app operations the rest of the UI uses, and hands it to the scene to present. A press anywhere else is ignored.

func (*Handler) SetSystemClipboard

func (h *Handler) SetSystemClipboard(c window.SystemClipboard)

SetSystemClipboard installs the native back-end's OS pasteboard as the toolkit-wide clipboard, so every text widget's copy/cut/paste and the app's copy actions go through it. It satisfies the optional window.ClipboardController capability. window.SystemClipboard has the same method set as toolkit.Clipboard, so it installs directly.

func (*Handler) Shortcut

func (h *Handler) Shortcut(r rune, ctrl, meta bool)

Shortcut handles a command-style modifier chord (Ctrl/Cmd + a base key) forwarded by the native back-end. In the feed view with the embedded web preview active, a chord whose base rune matches the configured zoom-in / zoom-out key zooms the browser through its MVVM commands; every other chord is ignored so ordinary shortcuts fall through untouched. This satisfies the optional window.ShortcutSink capability (asserted below).

func (*Handler) SystemAppearance

func (h *Handler) SystemAppearance(a window.SystemAppearance)

SystemAppearance applies host look-and-feel harvested by the native back-end (dark/light, accent, system font) to the app. This satisfies the optional window.AppearanceSink capability; the compile-time assertion below keeps the signature in step with the contract.

Jump to

Keyboard shortcuts

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