platform

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: BSD-3-Clause Imports: 6 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 platform defines the interface between the engine and an operating system backend, together with the types shared by all backends.

Flutter: the embedder API (engine/src/flutter/shell/platform/embedder).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accessibility

type Accessibility interface {
	// Start follows the screen reader in the background until ctx ends or Close.
	// A desktop without an accessibility service is not an error: the bridge stays off.
	Start(ctx context.Context, host AccessibilityHost)
	// UpdateSemantics gives the bridge the changes to the semantics tree of a view.
	UpdateSemantics(view ui.ViewID, update *ui.SemanticsUpdate)
	// SetWindow tells the title of the window of the view, which names the frame of its
	// tree, and whether it has the keyboard focus.
	SetWindow(view ui.ViewID, title string, active bool)
	// RemoveView forgets the tree of a view that was closed.
	RemoveView(view ui.ViewID)
	// Close stops the bridge. It may be called from any goroutine, and twice.
	Close()
}

Accessibility is the bridge to the assistive technologies of the desktop (SPEC §8.10). The engine starts it, gives it the semantics trees of the views, and it asks for the semantics tree only while a screen reader is on. All methods but Close are for the UI thread; the host is called on the UI thread too.

Flutter: no counterpart (the embedder's accessibility bridge)

type AccessibilityHost

type AccessibilityHost interface {
	// ScreenReaderChanged tells that a screen reader started or stopped: the framework
	// then makes the semantics tree, or stops making it
	// (PlatformDispatcher.SetSemanticsEnabled).
	ScreenReaderChanged(enabled bool)
	// PerformAction carries out the request of an assistive technology to perform an
	// action on a node (PlatformDispatcher.DispatchSemanticsActionEvent).
	PerformAction(event ui.SemanticsActionEvent)
}

AccessibilityHost is what the engine gives the bridge. Both methods are called on the UI thread.

Flutter: no counterpart

type ActivationTokenProvider

type ActivationTokenProvider interface {
	// RequestActivationToken asks for a token for the window of the view. done is
	// called on the UI thread with the token, or with an empty token when the
	// desktop gave none. The platform has the app id of the window and the last
	// input event of the seat.
	RequestActivationToken(view ui.ViewID, done func(token string))
}

ActivationTokenProvider is implemented by a Platform that can ask the desktop for an activation token: a proof of a user action that lets another app, one that this app launches, take the focus (Wayland's xdg_activation_v1). The services that launch apps (opening a URI, notifications) pass the token on through XDG_ACTIVATION_TOKEN.

Flutter: no counterpart

type Clipboard

type Clipboard interface {
	// SetText makes text the content of the clipboard; the app owns it until
	// another application takes it. done, when it is not nil, is called with the
	// error, if any.
	SetText(ctx context.Context, text string, done func(err error))
	// GetText reads the text of the clipboard. The text is empty and ok false when
	// the clipboard has no text. ctx ends a read that is taking too long.
	GetText(ctx context.Context, done func(text string, ok bool, err error))
	// SetContent makes the content the content of the selection of the kind: the
	// system clipboard or the primary selection. done is as for SetText.
	SetContent(ctx context.Context, kind ui.ClipboardKind, content ui.ClipboardContent, done func(err error))
	// GetContent reads the selection of the kind in the format (one of the
	// ui.ClipboardFormat constants). The content is empty when the selection has
	// no such format. ctx ends a read that is taking too long.
	GetContent(ctx context.Context, kind ui.ClipboardKind, format string, done func(content ui.ClipboardContent, err error))
}

Clipboard is the system clipboard of the desktop. Its methods are for the UI thread. Reading the clipboard of another application takes time (the other application has to write the data), so the results come back through a function that the platform calls later on the UI thread; it is never called before the method has returned.

SetContent and GetContent reach the primary selection and the formats beyond text; the platform that has no primary selection fails them for it with ClipboardPrimaryUnavailable.

Flutter: services/clipboard.dart Clipboard

type ContextMenuController

type ContextMenuController interface {
	// SetBrowserContextMenuEnabled says whether the browser's context menu is shown when the
	// user asks for it (a right click); it is enabled until the app disables it.
	SetBrowserContextMenuEnabled(enabled bool)
}

ContextMenuController is implemented by a Window that has a context menu of its own to show or to hide: the browser's, on the web (SPEC §23.4).

Flutter: no counterpart

type Decorations

type Decorations int

Decorations is how the title bar and the borders of a window are made. The zero value, DecorationsUnspecified, means DecorationsAuto.

Flutter: no counterpart

const (
	// DecorationsUnspecified is the zero value and means DecorationsAuto.
	//
	// Flutter: no counterpart
	DecorationsUnspecified Decorations = iota
	// DecorationsAuto uses the first of these that works: the compositor's own
	// (server-side), libdecor, and the title bar of the framework (SPEC §8.2).
	//
	// Flutter: no counterpart
	DecorationsAuto
	// DecorationsApp skips the first two: the app places a WindowDecoration or its
	// own title bar.
	//
	// Flutter: no counterpart
	DecorationsApp
	// DecorationsLibdecor uses libdecor even where the compositor has its own title
	// bars; without libdecor it is DecorationsAuto. It is a test aid
	// (GLUTTER_DECORATIONS=libdecor): the apps ask for DecorationsAuto or
	// DecorationsApp.
	//
	// Flutter: no counterpart
	DecorationsLibdecor
)

The values of Decorations.

type Display

type Display struct {
	// ID identifies the display.
	ID int
	// Name is the name the compositor or X server gives the display.
	Name string
	// Bounds is the display's position and size in logical pixels.
	Bounds ui.Rect
	// DevicePixelRatio is the number of physical pixels per logical pixel.
	DevicePixelRatio float64
	// RefreshRate is the refresh rate in frames per second.
	RefreshRate float64
	// Primary is whether this is the primary display.
	Primary bool
}

Display describes one connected display.

Flutter: ui/window.dart Display

type ExitController

type ExitController interface {
	// CanExit says whether the app may end Run when it asks to exit.
	CanExit() bool
}

ExitController is implemented by a Platform whose app cannot end itself: a web page cannot close itself, so the engine does nothing when the app asks to exit (SPEC §23.3).

Flutter: no counterpart

type FontAntialiasing

type FontAntialiasing int

FontAntialiasing is how the system wants text smoothed. The zero value, FontAntialiasingUnspecified, means the platform does not say.

Flutter: no counterpart

const (
	// FontAntialiasingUnspecified is the zero value.
	//
	// Flutter: no counterpart
	FontAntialiasingUnspecified FontAntialiasing = iota
	// FontAntialiasingNone draws glyphs without smoothing.
	//
	// Flutter: no counterpart
	FontAntialiasingNone
	// FontAntialiasingGrayscale smooths glyphs with gray levels.
	//
	// Flutter: no counterpart
	FontAntialiasingGrayscale
	// FontAntialiasingRGBA smooths glyphs per color channel (sub-pixel).
	//
	// Flutter: no counterpart
	FontAntialiasingRGBA
)

The values of FontAntialiasing.

type FontHinting

type FontHinting int

FontHinting is how strongly the system wants glyph outlines fitted to the pixel grid. The zero value, FontHintingUnspecified, means the platform does not say.

Flutter: no counterpart

const (
	// FontHintingUnspecified is the zero value.
	//
	// Flutter: no counterpart
	FontHintingUnspecified FontHinting = iota
	// FontHintingNone does no hinting.
	//
	// Flutter: no counterpart
	FontHintingNone
	// FontHintingSlight hints vertically only.
	//
	// Flutter: no counterpart
	FontHintingSlight
	// FontHintingMedium hints moderately.
	//
	// Flutter: no counterpart
	FontHintingMedium
	// FontHintingFull hints fully.
	//
	// Flutter: no counterpart
	FontHintingFull
)

The values of FontHinting.

type Handler

type Handler interface {
	// OnPointer delivers a batch of pointer reports, in order.
	OnPointer(data []ui.PointerData)
	// OnKey delivers one key event.
	OnKey(data ui.KeyData)
	// OnTextInput delivers a text-input event from the IME.
	OnTextInput(event ui.TextInputEvent)
	// OnFrame asks for a frame of the view. The duration is the frame time
	// since an arbitrary fixed point in the past.
	OnFrame(view ui.ViewID, frameTime time.Duration)
	// OnMetrics reports a new size or scale of the view.
	OnMetrics(view ui.ViewID, metrics ViewMetrics)
	// OnLifecycle reports a change of the application lifecycle state.
	OnLifecycle(state ui.AppLifecycleState)
	// OnDrop delivers a drag-and-drop event over a view (event.ViewID) and returns
	// the action the app accepts at that place, DropActionNone for none. The drop
	// carries the data, which the platform has read by then.
	OnDrop(event ui.DropEvent) ui.DropActions
	// OnDragEnd reports how a drag that the app started with Window.StartDrag ended.
	OnDragEnd(result ui.DragResult)
	// OnDisplaysChanged reports that the displays changed: one was connected or
	// disconnected, or one changed its size, scale or refresh rate. Platform.Displays
	// has the new list.
	OnDisplaysChanged()
	// OnSettings reports changed system settings.
	OnSettings(settings Settings)
	// OnViewFocus reports that the keyboard focus moved to a view (true) or left it
	// (false). When it moves from one view to another, the old view is told first.
	OnViewFocus(view ui.ViewID, focused bool)
	// OnContentLost reports that what the window shows is no longer the last frame
	// that was presented (an X11 window was exposed, and the server kept nothing of
	// it), so that the next frame must be presented whole, whatever changed in it.
	OnContentLost(view ui.ViewID)
	// OnCloseRequest reports that the user asked to close the view. Returning
	// true closes the window; false keeps it open.
	OnCloseRequest(view ui.ViewID) bool
}

Handler receives everything the platform reports. The engine implements it. Its methods are called on the UI thread, inside Platform.Run.

Flutter: no counterpart (the embedder's callbacks into the engine)

type MouseCursor

type MouseCursor int

MouseCursor is a cursor shown over a window: one of Flutter's system mouse cursors. The zero value, MouseCursorUnspecified, means the platform's default arrow, like MouseCursorBasic.

Flutter: services/mouse_cursor.dart SystemMouseCursors

const (
	// MouseCursorUnspecified is the zero value: the default arrow.
	//
	// Flutter: no counterpart
	MouseCursorUnspecified MouseCursor = iota
	// MouseCursorNone hides the cursor.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.none
	MouseCursorNone
	// MouseCursorBasic is the arrow.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.basic
	MouseCursorBasic
	// MouseCursorClick is the pointing hand, for something that can be clicked.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.click
	MouseCursorClick
	// MouseCursorForbidden says the action is not allowed.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.forbidden
	MouseCursorForbidden
	// MouseCursorWait says the app is busy and cannot be used.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.wait
	MouseCursorWait
	// MouseCursorProgress says the app is busy but can still be used.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.progress
	MouseCursorProgress
	// MouseCursorContextMenu says a context menu is available.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.contextMenu
	MouseCursorContextMenu
	// MouseCursorHelp says help is available.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.help
	MouseCursorHelp
	// MouseCursorText is the I-beam, for text that can be selected.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.text
	MouseCursorText
	// MouseCursorVerticalText is the I-beam for vertical text.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.verticalText
	MouseCursorVerticalText
	// MouseCursorCell is the cross of a spreadsheet cell.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.cell
	MouseCursorCell
	// MouseCursorPrecise is the crosshair.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.precise
	MouseCursorPrecise
	// MouseCursorMove says an item can be moved.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.move
	MouseCursorMove
	// MouseCursorGrab is the open hand, for something that can be grabbed.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.grab
	MouseCursorGrab
	// MouseCursorGrabbing is the closed hand, for something being dragged.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.grabbing
	MouseCursorGrabbing
	// MouseCursorNoDrop says the item cannot be dropped here.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.noDrop
	MouseCursorNoDrop
	// MouseCursorAlias says a shortcut will be made.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.alias
	MouseCursorAlias
	// MouseCursorCopy says the item will be copied.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.copy
	MouseCursorCopy
	// MouseCursorDisappearing says the item will disappear.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.disappearing
	MouseCursorDisappearing
	// MouseCursorAllScroll says the content scrolls in every direction.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.allScroll
	MouseCursorAllScroll
	// MouseCursorResizeLeftRight resizes horizontally.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeLeftRight
	MouseCursorResizeLeftRight
	// MouseCursorResizeUpDown resizes vertically.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeUpDown
	MouseCursorResizeUpDown
	// MouseCursorResizeUpLeftDownRight resizes along the diagonal from the top
	// left to the bottom right.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeUpLeftDownRight
	MouseCursorResizeUpLeftDownRight
	// MouseCursorResizeUpRightDownLeft resizes along the diagonal from the top
	// right to the bottom left.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeUpRightDownLeft
	MouseCursorResizeUpRightDownLeft
	// MouseCursorResizeUp moves the top edge.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeUp
	MouseCursorResizeUp
	// MouseCursorResizeDown moves the bottom edge.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeDown
	MouseCursorResizeDown
	// MouseCursorResizeLeft moves the left edge.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeLeft
	MouseCursorResizeLeft
	// MouseCursorResizeRight moves the right edge.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeRight
	MouseCursorResizeRight
	// MouseCursorResizeUpLeft moves the top left corner.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeUpLeft
	MouseCursorResizeUpLeft
	// MouseCursorResizeUpRight moves the top right corner.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeUpRight
	MouseCursorResizeUpRight
	// MouseCursorResizeDownLeft moves the bottom left corner.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeDownLeft
	MouseCursorResizeDownLeft
	// MouseCursorResizeDownRight moves the bottom right corner.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeDownRight
	MouseCursorResizeDownRight
	// MouseCursorResizeColumn resizes a column.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeColumn
	MouseCursorResizeColumn
	// MouseCursorResizeRow resizes a row.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.resizeRow
	MouseCursorResizeRow
	// MouseCursorZoomIn says the content will zoom in.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.zoomIn
	MouseCursorZoomIn
	// MouseCursorZoomOut says the content will zoom out.
	//
	// Flutter: services/mouse_cursor.dart SystemMouseCursors.zoomOut
	MouseCursorZoomOut
)

The values of MouseCursor follow the declaration order of Flutter's SystemMouseCursors.

func MouseCursorFromKind

func MouseCursorFromKind(kind string) (MouseCursor, bool)

MouseCursorFromKind returns the cursor of a Flutter system mouse cursor kind ("click", "resizeUpDown"), and false for a kind it does not know.

Flutter: services/mouse_cursor.dart SystemMouseCursor.kind

func (MouseCursor) String

func (c MouseCursor) String() string

String returns the name of the cursor, such as "MouseCursorText".

Flutter: services/mouse_cursor.dart SystemMouseCursors

func (MouseCursor) Valid

func (c MouseCursor) Valid() bool

Valid reports whether the cursor is one of the values above.

Flutter: no counterpart

type NopHandler

type NopHandler struct{}

NopHandler is a Handler that ignores every event and agrees to every close request. It is for tests and for the development examples that only need a window.

Flutter: no counterpart

func (NopHandler) OnCloseRequest

func (NopHandler) OnCloseRequest(ui.ViewID) bool

OnCloseRequest agrees to close the view.

Flutter: no counterpart

func (NopHandler) OnContentLost

func (NopHandler) OnContentLost(ui.ViewID)

OnContentLost ignores the loss.

Flutter: no counterpart

func (NopHandler) OnDisplaysChanged

func (NopHandler) OnDisplaysChanged()

OnDisplaysChanged ignores the change.

Flutter: no counterpart

func (NopHandler) OnDragEnd

func (NopHandler) OnDragEnd(ui.DragResult)

OnDragEnd ignores the end of a drag.

Flutter: no counterpart

func (NopHandler) OnDrop

OnDrop ignores the drop event and accepts nothing.

Flutter: no counterpart

func (NopHandler) OnFrame

func (NopHandler) OnFrame(ui.ViewID, time.Duration)

OnFrame ignores the frame request.

Flutter: no counterpart

func (NopHandler) OnKey

func (NopHandler) OnKey(ui.KeyData)

OnKey ignores the key event.

Flutter: no counterpart

func (NopHandler) OnLifecycle

func (NopHandler) OnLifecycle(ui.AppLifecycleState)

OnLifecycle ignores the lifecycle change.

Flutter: no counterpart

func (NopHandler) OnMetrics

func (NopHandler) OnMetrics(ui.ViewID, ViewMetrics)

OnMetrics ignores the new metrics.

Flutter: no counterpart

func (NopHandler) OnPointer

func (NopHandler) OnPointer([]ui.PointerData)

OnPointer ignores the pointer data.

Flutter: no counterpart

func (NopHandler) OnSettings

func (NopHandler) OnSettings(Settings)

OnSettings ignores the new settings.

Flutter: no counterpart

func (NopHandler) OnTextInput

func (NopHandler) OnTextInput(ui.TextInputEvent)

OnTextInput ignores the text-input event.

Flutter: no counterpart

func (NopHandler) OnViewFocus

func (NopHandler) OnViewFocus(ui.ViewID, bool)

OnViewFocus ignores the focus change.

Flutter: no counterpart

type Platform

type Platform interface {
	// Run owns the UI thread's event loop. It delivers events to h and returns
	// nil when ctx is cancelled or the platform has nothing left to show. A
	// second call while Run is active fails with PlatformAlreadyRunning.
	Run(ctx context.Context, h Handler) error
	// Post runs fn on the UI thread. It is safe to call from any goroutine and
	// wakes the loop. Functions posted by one goroutine run in the order that
	// goroutine posted them.
	Post(fn func())
	// NewWindow creates a top-level window; the engine turns it into a view.
	NewWindow(cfg WindowConfig) (Window, error)
	// Displays lists the connected displays.
	Displays() []Display
	// Clipboard returns the system clipboard.
	Clipboard() Clipboard
	// Settings returns the current system settings. Changes arrive through
	// Handler.OnSettings.
	Settings() Settings
	// Services returns the optional desktop capabilities of this platform, or
	// nil when it has none.
	Services() Services
}

Platform is the contract between the engine and an operating system backend. Only the engine talks to it, and only on the UI thread, except for Post.

Flutter: no counterpart (the embedder API)

type PortalHandleProvider

type PortalHandleProvider interface {
	// PortalHandle calls done on the UI thread with the handle of the window, or with
	// an empty string when the window has none (a compositor without
	// zxdg_exporter_v2).
	PortalHandle(done func(handle string))
}

PortalHandleProvider is implemented by a Window that can say how the portals of xdg-desktop-portal name it as the parent of a dialog (SPEC §8.9): "wayland:<handle>" from zxdg_exporter_v2, or "x11:<window id in hex>".

Flutter: no counterpart

type ScreenshotPoster

type ScreenshotPoster interface {
	// PostScreenshot sends the PNG to where the host collects it. It returns at once;
	// done is called later, on the UI thread, with the error if the PNG did not arrive.
	PostScreenshot(png []byte, done func(err error))
}

ScreenshotPoster is implemented by a Platform that cannot write files, so that the self-capture of the engine (GLUTTER_SCREENSHOT) hands the PNG over to it instead: the web posts it to the server that serves the page (SPEC §23.8).

Flutter: no counterpart

type Services

type Services interface {
	// Accessibility returns the bridge to the assistive technologies, or nil.
	Accessibility() Accessibility
}

Services groups the optional capabilities of a platform that the engine uses. Each accessor returns nil when the capability is absent. (The desktop services of package desktop, such as the tray and the notifications, are made by the app.)

Flutter: no counterpart

type Settings

type Settings struct {
	// PlatformBrightness is the system color scheme.
	PlatformBrightness ui.Brightness
	// AccentColor is the system accent color. It is meaningful only when
	// HasAccentColor is true.
	AccentColor ui.Color
	// HasAccentColor is whether the system has an accent color.
	HasAccentColor bool
	// TextScaleFactor is the system text scale; 0 means 1.
	TextScaleFactor float64
	// DisableAnimations is whether the user asked for reduced motion.
	DisableAnimations bool
	// HighContrast is whether the user asked for high contrast.
	HighContrast bool
	// Locales lists the user's locales, most preferred first.
	Locales []ui.Locale
	// CursorSize is the size of the mouse cursor in pixels; 0 means the
	// platform default.
	CursorSize int
	// CursorTheme is the name of the XCursor theme; empty means the
	// platform default.
	CursorTheme string
	// FontAntialiasing is how the system wants text smoothed.
	FontAntialiasing FontAntialiasing
	// FontHinting is how strongly the system wants glyph outlines fitted to
	// the pixel grid.
	FontHinting FontHinting
}

Settings is the system-wide configuration the app follows.

Flutter: ui/platform_dispatcher.dart PlatformConfiguration

type SurfaceRenewer

type SurfaceRenewer interface {
	// RenewSurface replaces the native surface.
	RenewSurface()
}

SurfaceRenewer is implemented by a Window whose native surface can be replaced by a new one: the web's canvas keeps the first kind of context it was asked for, so a renderer that follows a failed one needs a canvas that has had none (SPEC §9.6). The window keeps its size, its input and its place; the new surface is blank until the next frame.

Flutter: no counterpart

type SyncInputHandler

type SyncInputHandler interface {
	// OnKeySync handles the key event now and reports whether the framework handled it.
	OnKeySync(data ui.KeyData) bool
	// OnPointerSync handles the pointer data now. The OnRespond functions of the data
	// have been called, for the data that is answered, when it returns.
	OnPointerSync(data []ui.PointerData)
	// OnTextInputSync handles the text-input event now. A platform whose text field holds the
	// text (the web's) needs the framework's answer, the new state of the field, before the next
	// event of the field is read, so that it does not take its own echo for a change.
	OnTextInputSync(event ui.TextInputEvent)
}

SyncInputHandler is implemented by a Handler that can handle input at once and say what the framework made of it, for a platform whose events need the answer before the event handler returns: the web calls preventDefault on a key that the framework handled and on a wheel that a scrollable took (SPEC §23.3). The input that arrived earlier and is still waiting for its frame is handled first, so the order stays as it arrived.

Flutter: no counterpart (the synchronous invokeOnKeyData and invokeOnPointerDataPacket of the web engine)

type ViewMetrics

type ViewMetrics struct {
	// PhysicalSize is the size of the view in physical pixels.
	PhysicalSize ui.Size
	// DevicePixelRatio is the number of physical pixels per logical pixel.
	DevicePixelRatio float64
	// ViewPadding is the area the system covers, in physical pixels.
	ViewPadding ui.ViewPadding
	// ViewInsets is the area covered by system UI the app can draw below.
	ViewInsets ui.ViewPadding
	// SystemGestureInsets is the area where the system handles gestures.
	SystemGestureInsets ui.ViewPadding
	// Display is the display the view is on. None means the engine chooses
	// (the primary display).
	Display foundation.Opt[int]
	// Window says who draws the title bar and what state the window is in. A
	// backend that does not know leaves the zero value.
	Window ui.WindowInfo
}

ViewMetrics describes the size, scale and system areas of a view. Only the size and the scale are required; the engine fills in the rest from the display and the defaults.

Flutter: ui/window.dart ViewConfiguration

type Window

type Window interface {
	// ID returns the ID of the view this window shows.
	ID() ui.ViewID
	// NativeSurface returns the handle that a GPU backend renders into.
	NativeSurface() gpu.SurfaceHandle
	// SetTitle sets the window title.
	SetTitle(title string)
	// SetSize asks for a new window size, in logical pixels.
	SetSize(size ui.Size)
	// SetSizeConstraints sets the smallest and the largest size of the window in
	// logical pixels; zero means no limit. The compositor may ignore it.
	SetSizeConstraints(min, max ui.Size)
	// SetState asks for the window to be maximized, minimized, fullscreen or
	// back to normal.
	SetState(state WindowState)
	// SetCursor sets the mouse cursor shown over the window.
	SetCursor(cursor MouseCursor)
	// SetTextInput tells the IME about the focused text field. A zero
	// ui.TextInputState with Enabled false disables text input.
	SetTextInput(state ui.TextInputState)
	// RequestFrame asks for Handler.OnFrame to be called for this window, at the
	// next moment the compositor wants a frame. At most one frame is in flight
	// per window: requests made while one is in flight are merged into one more
	// frame, after the compositor is done with the first. The handler must
	// present exactly one frame for each OnFrame, or no further frame follows.
	RequestFrame()
	// StartDrag starts a drag-and-drop operation from this window.
	StartDrag(request ui.DragRequest) error
	// PerformWindowAction does what the title bar of the app asks: move, resize,
	// the window menu, minimize, maximize, restore and close. Moves, resizes and
	// the menu need the input event that is going on. An action that the platform
	// cannot do is ignored.
	PerformWindowAction(action ui.WindowAction)
	// Close destroys the window. Destroy the GPU surface of the window first.
	Close()
	// SetIcon sets the icon of the window; the zero icon removes it. It fails with
	// the platform's error when the icon cannot be used. A platform that has no
	// window icons ignores it.
	SetIcon(icon ui.WindowIcon) error
	// SetContentType gives the compositor a hint about what the window shows. A
	// platform without such hints ignores it.
	SetContentType(contentType ui.ContentType)
	// KeepScreenOn stops the screen from going idle while the window is visible
	// (on is true), or lets it go idle again. It fails with IdleInhibitUnavailable
	// when the platform cannot.
	KeepScreenOn(on bool) error
}

Window is one top-level native window. All methods are for the UI thread.

Flutter: no counterpart (the embedder's view API)

type WindowConfig

type WindowConfig struct {
	// Kind is the kind of window.
	Kind WindowKind
	// Parent is the view of the parent window of a dialog.
	Parent ui.ViewID
	// HasParent is whether Parent is set.
	HasParent bool
	// Modal is whether a dialog blocks its parent.
	Modal bool
	// Title is the window title.
	Title string
	// AppID is the application ID: the Wayland app_id or the X11 WM_CLASS. It
	// must match the app's .desktop file.
	AppID string
	// Size is the initial size in logical pixels. A zero size lets the backend
	// choose.
	Size ui.Size
	// MinSize is the smallest size in logical pixels; zero means no minimum.
	MinSize ui.Size
	// MaxSize is the largest size in logical pixels; zero means no maximum.
	MaxSize ui.Size
	// Resizable is whether the user can resize the window. None means the
	// default, true; use IsResizable to read it.
	Resizable foundation.Opt[bool]
	// Decorated is whether the window has a title bar and borders. None means
	// the default, true; use IsDecorated to read it.
	Decorated foundation.Opt[bool]
	// State is the initial window state.
	State WindowState
	// Decorations is how the title bar is made; it does not matter when Decorated
	// is false.
	Decorations Decorations
	// Icon is the icon of the window; the zero value is none.
	Icon ui.WindowIcon
	// ContentType is the hint about what the window shows.
	ContentType ui.ContentType
}

WindowConfig describes a window to create.

Flutter: widgets/_window.dart WindowController

func DefaultWindowConfig

func DefaultWindowConfig() WindowConfig

DefaultWindowConfig returns a WindowConfig with the defaults: a regular, resizable, decorated window of a size the backend chooses. It is the zero value.

Flutter: no counterpart

func (WindowConfig) IsDecorated

func (c WindowConfig) IsDecorated() bool

IsDecorated is whether the window has a title bar and borders; the default is true.

Flutter: no counterpart

func (WindowConfig) IsResizable

func (c WindowConfig) IsResizable() bool

IsResizable is whether the user can resize the window; the default is true.

Flutter: no counterpart

type WindowKind

type WindowKind int

WindowKind is the kind of a window. The zero value, WindowKindUnspecified, means WindowKindRegular.

Flutter: widgets/_window.dart WindowArchetype

const (
	// WindowKindUnspecified is the zero value and means WindowKindRegular.
	//
	// Flutter: no counterpart
	WindowKindUnspecified WindowKind = iota
	// WindowKindRegular is an ordinary top-level window.
	//
	// Flutter: widgets/_window.dart WindowArchetype.regular
	WindowKindRegular
	// WindowKindDialog is a dialog, optionally modal, of a parent window.
	//
	// Flutter: widgets/_window.dart WindowArchetype.dialog
	WindowKindDialog
	// WindowKindBorderless is a window without decorations, such as a
	// tooltip-style window.
	//
	// Flutter: no counterpart
	WindowKindBorderless
)

The values of WindowKind.

type WindowState

type WindowState int

WindowState is the state of a window. The zero value, WindowStateUnspecified, means WindowStateNormal.

Flutter: no counterpart

const (
	// WindowStateUnspecified is the zero value and means WindowStateNormal.
	//
	// Flutter: no counterpart
	WindowStateUnspecified WindowState = iota
	// WindowStateNormal is a window that is neither maximized, minimized nor
	// fullscreen.
	//
	// Flutter: no counterpart
	WindowStateNormal
	// WindowStateMaximized is a maximized window.
	//
	// Flutter: no counterpart
	WindowStateMaximized
	// WindowStateMinimized is a minimized (iconified) window.
	//
	// Flutter: no counterpart
	WindowStateMinimized
	// WindowStateFullscreen is a fullscreen window.
	//
	// Flutter: no counterpart
	WindowStateFullscreen
)

The values of WindowState.

Directories

Path Synopsis
Package fake is a scripted platform for tests: it replays queued events and records what the engine asks of it.
Package fake is a scripted platform for tests: it replays queued events and records what the engine asks of it.
Package linux holds what the Linux backends share: the event loop, the key tables, system settings and the choice between Wayland and X11.
Package linux holds what the Linux backends share: the event loop, the key tables, system settings and the choice between Wayland and X11.
dl
Package dl is the one safe way to load C libraries and call into them without cgo: it wraps purego's Dlopen, Dlsym and callbacks, tags every failure, and offers the libc helpers (malloc, free, C strings) and the struct-layout test helper that the backends share.
Package dl is the one safe way to load C libraries and call into them without cgo: it wraps purego's Dlopen, Dlsym and callbacks, tags every failure, and offers the libc helpers (malloc, free, C strings) and the struct-layout test helper that the backends share.
fontconfig
Package fontconfig binds libfontconfig (through purego, SPEC §8.1) to match a font family, weight, slant and language to the font files of the system, in the fallback order the user's fontconfig settings give.
Package fontconfig binds libfontconfig (through purego, SPEC §8.1) to match a font family, weight, slant and language to the font files of the system, in the fallback order the user's fontconfig settings give.
ime
Package ime connects a window system backend to an input method framework over D-Bus (IBus or Fcitx5): the same way for X11, and for Wayland on a compositor without text-input-v3 (SPEC §8.3, §8.6).
Package ime connects a window system backend to an input method framework over D-Bus (IBus or Fcitx5): the same way for X11, and for Wayland on a compositor without text-input-v3 (SPEC §8.3, §8.6).
ime/imetest
Package imetest has test doubles for the input method of the Linux backends: an input method that records its calls, and a poster that lets the test run what the bridge hands to the UI thread.
Package imetest has test doubles for the input method of the Linux backends: an input method that records its calls, and a poster that lets the test run what the bridge hands to the UI thread.
input
Package input turns what the Linux windowing systems report about pointers and touch screens into ui.PointerData, the same way for Wayland and X11.
Package input turns what the Linux windowing systems report about pointers and touch screens into ui.PointerData, the same way for Wayland and X11.
wayland
Package wayland is the Wayland backend.
Package wayland is the Wayland backend.
wayland/decor
Package decor binds libdecor, the library that draws native title bars for Wayland compositors without server-side decorations (GNOME).
Package decor binds libdecor, the library that draws native title bars for Wayland compositors without server-side decorations (GNOME).
wayland/fakecomp
Package fakecomp is a tiny fake Wayland compositor for tests: it speaks the wire protocol over a socket pair, answers the requests that the tests send, and logs them.
Package fakecomp is a tiny fake Wayland compositor for tests: it speaks the wire protocol over a socket pair, answers the requests that the tests send, and logs them.
wayland/wl
Package wl is the Wayland client: the runtime over libwayland-client, which is bound with purego, and the Go bindings of every protocol in ../protocols, generated by `glutter-gen wayland` into the *_gen.go files.
Package wl is the Wayland client: the runtime over libwayland-client, which is bound with purego, and the Go bindings of every protocol in ../protocols, generated by `glutter-gen wayland` into the *_gen.go files.
x11
Package x11 is the X11 backend.
Package x11 is the X11 backend.
xkb
Package xkb binds libxkbcommon (through purego, SPEC §8.1) and turns key presses into Flutter key data: the physical key, the logical key and the text, for any keyboard layout, with dead keys and compose sequences.
Package xkb binds libxkbcommon (through purego, SPEC §8.1) and turns key presses into Flutter key data: the physical key, the logical key and the text, for any keyboard layout, with dead keys and compose sequences.
web
Package web is the platform backend of the web (GOOS=js GOARCH=wasm, SPEC §23): one window that is a canvas in a host element of the page, frames from requestAnimationFrame, and the lifecycle and the settings of the browser.
Package web is the platform backend of the web (GOOS=js GOARCH=wasm, SPEC §23): one window that is a canvas in a host element of the page, frames from requestAnimationFrame, and the lifecycle and the settings of the browser.
desktoptest command
Command desktoptest is the program of the browser tests of the web desktop services (step 21.6, SPEC §17, §23.7).
Command desktoptest is the program of the browser tests of the web desktop services (step 21.6, SPEC §17, §23.7).
inputtest command
Command inputtest is the program of the browser tests of the web input (step 21.2, SPEC §17, §23.4).
Command inputtest is the program of the browser tests of the web input (step 21.2, SPEC §17, §23.4).
synthetic
Package synthetic dispatches synthetic DOM events at the canvas of a Glutter app, the way the browser would deliver real ones: the debug-only script of the web platform (GLUTTER_DEV_EVENTS, for proof screenshots) and the browser tests use it.
Package synthetic dispatches synthetic DOM events at the canvas of a Glutter app, the way the browser would deliver real ones: the debug-only script of the web platform (GLUTTER_DEV_EVENTS, for proof screenshots) and the browser tests use it.
texttest command
Command texttest is the program of the browser tests of the web text input and clipboard (step 21.3, SPEC §17, §23.5).
Command texttest is the program of the browser tests of the web text input and clipboard (step 21.3, SPEC §17, §23.5).

Jump to

Keyboard shortcuts

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