Documentation
¶
Overview ¶
Package input turns what the Linux windowing systems report about pointers and touch screens into ui.PointerData, the same way for Wayland and X11. It has no dependency on either: the backends feed it plain events (positions, buttons, scroll axes, gestures, fingers) and send on what it returns.
Flutter: no counterpart (the embedders do this on each platform)
Index ¶
- Constants
- type Axis
- type AxisSource
- type KeyTracker
- type PointerBatcher
- func (b *PointerBatcher) Axis(axis Axis, value float64)
- func (b *PointerBatcher) AxisDirection(axis Axis, inverted bool)
- func (b *PointerBatcher) AxisDiscrete(axis Axis, n int32)
- func (b *PointerBatcher) AxisSource(src AxisSource)
- func (b *PointerBatcher) AxisStop(axis Axis)
- func (b *PointerBatcher) AxisValue120(axis Axis, v int32)
- func (b *PointerBatcher) Button(code uint32, pressed bool)
- func (b *PointerBatcher) Enter(view ui.ViewID, x, y float64)
- func (b *PointerBatcher) Frame() []ui.PointerData
- func (b *PointerBatcher) Leave()
- func (b *PointerBatcher) Locked() bool
- func (b *PointerBatcher) Motion(x, y float64)
- func (b *PointerBatcher) PinchBegin()
- func (b *PointerBatcher) PinchEnd()
- func (b *PointerBatcher) PinchUpdate(dx, dy, scale, rotationDegrees float64)
- func (b *PointerBatcher) Relative(dx, dy float64)
- func (b *PointerBatcher) SetLocked(locked bool)
- func (b *PointerBatcher) SwipeBegin()
- func (b *PointerBatcher) SwipeEnd()
- func (b *PointerBatcher) SwipeUpdate(dx, dy float64)
- func (b *PointerBatcher) Take() []ui.PointerData
- type PointerIDs
- type StylusBatcher
- func (b *StylusBatcher) AddTool(id int, kind ui.PointerDeviceKind)
- func (b *StylusBatcher) Button(id int, code uint32, pressed bool)
- func (b *StylusBatcher) CancelView(view ui.ViewID)
- func (b *StylusBatcher) Distance(id int, raw uint32)
- func (b *StylusBatcher) Down(id int)
- func (b *StylusBatcher) Frame(id int)
- func (b *StylusBatcher) Motion(id int, x, y float64)
- func (b *StylusBatcher) Pressure(id int, raw uint32)
- func (b *StylusBatcher) ProximityIn(id int, view ui.ViewID)
- func (b *StylusBatcher) ProximityOut(id int)
- func (b *StylusBatcher) RemoveTool(id int)
- func (b *StylusBatcher) Rotation(id int, degrees float64)
- func (b *StylusBatcher) Take() []ui.PointerData
- func (b *StylusBatcher) Tilt(id int, x, y float64)
- func (b *StylusBatcher) Up(id int)
- type TouchBatcher
- func (t *TouchBatcher) Cancel()
- func (t *TouchBatcher) CancelView(view ui.ViewID)
- func (t *TouchBatcher) Down(view ui.ViewID, id int32, x, y float64)
- func (t *TouchBatcher) Motion(id int32, x, y float64)
- func (t *TouchBatcher) Orientation(id int32, degrees float64)
- func (t *TouchBatcher) Shape(id int32, major, minor float64)
- func (t *TouchBatcher) Take() []ui.PointerData
- func (t *TouchBatcher) Up(id int32)
Constants ¶
const ( // MouseDevice is the device id of the mouse. // // Flutter: no counterpart MouseDevice = 0 // TrackpadDevice is the device id of the pan/zoom gestures of a trackpad. // // Flutter: no counterpart TrackpadDevice = 1 // TouchDeviceBase is added to the id of a finger to make its device id. // // Flutter: no counterpart TouchDeviceBase = 1000 // StylusDeviceBase is added to the id of a tablet tool to make its device id. // // Flutter: no counterpart StylusDeviceBase = 2000 )
The device ids of the pointers (Flutter tells pointers apart by device).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AxisSource ¶
type AxisSource int
AxisSource is what produced scroll events.
Flutter: no counterpart
const ( // AxisSourceWheel is a physical wheel: a notch is a step. // // Flutter: no counterpart AxisSourceWheel AxisSource = iota // AxisSourceFinger is a finger on a touchpad. // // Flutter: no counterpart AxisSourceFinger // AxisSourceContinuous is a continuous coordinate space, in pixels. // // Flutter: no counterpart AxisSourceContinuous // AxisSourceWheelTilt is a wheel tilted sideways. // // Flutter: no counterpart AxisSourceWheelTilt )
The sources of scroll events, as Wayland's wl_pointer.axis_source has them.
type KeyTracker ¶
type KeyTracker struct {
// contains filtered or unexported fields
}
KeyTracker remembers the keys that are down, with the data of their key-down event, so that the key-up reuses the physical and logical key even when the modifiers changed in between, and so that the keys can be released when the window loses the keyboard focus (SPEC §8.5).
A KeyTracker is used on the UI thread only.
Flutter: no counterpart
func (*KeyTracker) Data ¶
func (t *KeyTracker) Data(code uint32) (ui.KeyData, bool)
Data returns the key-down data of a key that is down, and false for a key that is not.
Flutter: no counterpart
func (*KeyTracker) Down ¶
func (t *KeyTracker) Down(code uint32, data ui.KeyData) bool
Down records the key-down data of the key with the platform's key code, and reports false, recording nothing, when the key is already down.
Flutter: no counterpart
func (*KeyTracker) ReleaseAll ¶
func (t *KeyTracker) ReleaseAll(now time.Duration) []ui.KeyData
ReleaseAll forgets every key and returns their key-up events, synthesized, in the order the keys went down.
Flutter: no counterpart
type PointerBatcher ¶
type PointerBatcher struct {
// Scale is the number of physical pixels per logical pixel; the positions the
// batcher gets are logical.
Scale float64
// contains filtered or unexported fields
}
PointerBatcher turns the events of a pointer, which the compositor groups in frames (Wayland's wl_pointer.frame; X11 sends one event at a time), into ui.PointerData. Enter, leave, motion, buttons and gestures are converted when they arrive; the scroll axes are held until frame, because only then it is known what the event was (a wheel, or a touchpad). The data belongs to the window the pointer is in. It works in physical pixels.
A PointerBatcher is used on the UI thread only.
Flutter: no counterpart
func NewPointerBatcher ¶
func NewPointerBatcher(now func() time.Duration, ids *PointerIDs) *PointerBatcher
NewPointerBatcher makes a batcher whose events carry the times that now gives and the pointer identifiers that ids gives (nil: a counter of its own). The batchers of one platform share ids, so that two contacts never have the same identifier.
Flutter: no counterpart
func (*PointerBatcher) Axis ¶
func (b *PointerBatcher) Axis(axis Axis, value float64)
Axis adds scroll in logical pixels on an axis to this frame.
Flutter: no counterpart
func (*PointerBatcher) AxisDirection ¶
func (b *PointerBatcher) AxisDirection(axis Axis, inverted bool)
AxisDirection records whether the physical direction of an axis is the opposite of what its events say (natural scrolling).
Flutter: no counterpart
func (*PointerBatcher) AxisDiscrete ¶
func (b *PointerBatcher) AxisDiscrete(axis Axis, n int32)
AxisDiscrete adds whole wheel notches on an axis to this frame, for compositors that have no high-resolution steps.
Flutter: no counterpart
func (*PointerBatcher) AxisSource ¶
func (b *PointerBatcher) AxisSource(src AxisSource)
AxisSource says what the scroll events of this frame come from.
Flutter: no counterpart
func (*PointerBatcher) AxisStop ¶
func (b *PointerBatcher) AxisStop(axis Axis)
AxisStop says the scrolling on an axis has stopped: for a touchpad, the fingers lifted.
Flutter: no counterpart
func (*PointerBatcher) AxisValue120 ¶
func (b *PointerBatcher) AxisValue120(axis Axis, v int32)
AxisValue120 adds high-resolution wheel steps (120 is one notch) on an axis to this frame.
Flutter: no counterpart
func (*PointerBatcher) Button ¶
func (b *PointerBatcher) Button(code uint32, pressed bool)
Button reports a button press or release, by its Linux button code. The first button down is a down event, the last one up an up event; the buttons in between change the button state with a move, as Flutter's embedders do.
Flutter: no counterpart
func (*PointerBatcher) Enter ¶
func (b *PointerBatcher) Enter(view ui.ViewID, x, y float64)
Enter reports that the pointer entered the window view at the position, in logical pixels.
Flutter: no counterpart
func (*PointerBatcher) Frame ¶
func (b *PointerBatcher) Frame() []ui.PointerData
Frame ends a group of events: it turns the collected scroll events into data and returns everything since the last frame, in order.
Flutter: no counterpart
func (*PointerBatcher) Leave ¶
func (b *PointerBatcher) Leave()
Leave reports that the pointer left its window. Buttons that are still down are released first (synthesized), and the pointer is removed.
Flutter: no counterpart
func (*PointerBatcher) Locked ¶
func (b *PointerBatcher) Locked() bool
Locked says whether SetLocked made the pointer locked.
Flutter: no counterpart
func (*PointerBatcher) Motion ¶
func (b *PointerBatcher) Motion(x, y float64)
Motion reports the pointer at a new position, in logical pixels.
Flutter: no counterpart
func (*PointerBatcher) PinchBegin ¶
func (b *PointerBatcher) PinchBegin()
PinchBegin starts a touchpad pinch gesture; PinchUpdate and PinchEnd follow it.
Flutter: no counterpart
func (*PointerBatcher) PinchEnd ¶
func (b *PointerBatcher) PinchEnd()
PinchEnd ends the pinch gesture.
Flutter: no counterpart
func (*PointerBatcher) PinchUpdate ¶
func (b *PointerBatcher) PinchUpdate(dx, dy, scale, rotationDegrees float64)
PinchUpdate gives the movement of the gesture's focus point in logical pixels, the scale since the start and the rotation since the start in degrees.
Flutter: no counterpart
func (*PointerBatcher) Relative ¶
func (b *PointerBatcher) Relative(dx, dy float64)
Relative reports the motion of a locked pointer, in logical pixels: a hover (a move while a button is down) at the position the pointer had when the lock began, with the motion as its delta (SPEC §27.6). Without a lock, or outside the window, it does nothing.
Flutter: no counterpart
func (*PointerBatcher) SetLocked ¶
func (b *PointerBatcher) SetLocked(locked bool)
SetLocked says that the pointer is locked (true) or free again (false). While it is locked the position does not change: Motion is ignored (the compositor or the server may still report a warped pointer), and Relative reports the motion.
Flutter: no counterpart
func (*PointerBatcher) SwipeBegin ¶
func (b *PointerBatcher) SwipeBegin()
SwipeBegin starts a touchpad swipe, which is a pan without scale or rotation; SwipeUpdate and SwipeEnd follow it.
Flutter: no counterpart
func (*PointerBatcher) SwipeEnd ¶
func (b *PointerBatcher) SwipeEnd()
SwipeEnd ends the swipe gesture.
Flutter: no counterpart
func (*PointerBatcher) SwipeUpdate ¶
func (b *PointerBatcher) SwipeUpdate(dx, dy float64)
SwipeUpdate gives the movement of the swipe in logical pixels.
Flutter: no counterpart
func (*PointerBatcher) Take ¶
func (b *PointerBatcher) Take() []ui.PointerData
Take returns the data converted since the last call, without ending the frame.
Flutter: no counterpart
type PointerIDs ¶
type PointerIDs struct {
// contains filtered or unexported fields
}
PointerIDs hands out the pointer identifiers of a platform: the number that tells the gesture arena which contact an event belongs to. Every contact (a mouse press, a finger on the screen, a pen on the tablet, a touchpad gesture) gets a new one at its start, and the numbers are never given twice in a run, whatever the device, as in Flutter's engine, where the converter has one counter for all its pointers. The identifier 0 is what an event has before any contact of its pointer: the batchers of one platform share one PointerIDs.
Deviation: Flutter's embedder hands the engine raw pointer data and the engine's PointerDataPacketConverter gives the identifiers; here the platform makes the final data, so the batchers give them (SPEC §8.5, §12.10).
A PointerIDs is used on the UI thread only.
Flutter: lib/ui/window/pointer_data_packet_converter.h PointerDataPacketConverter::pointer_
func NewPointerIDs ¶
func NewPointerIDs() *PointerIDs
NewPointerIDs makes a counter whose first identifier is 1.
Flutter: no counterpart
type StylusBatcher ¶
type StylusBatcher struct {
// Scale is the number of physical pixels per logical pixel; the positions the
// batcher gets are logical.
Scale float64
// contains filtered or unexported fields
}
StylusBatcher turns the events of the tablet tools (zwp_tablet_tool_v2) into ui.PointerData. The events of a tool are collected until its frame event, then they become one change: Add when the tool comes near the surface, Hover while it moves there, Down, Move and Up while it touches, and Remove when it leaves. A tool that leaves while it touches is lifted first.
A StylusBatcher is used on the UI thread only.
Flutter: no counterpart
func NewStylusBatcher ¶
func NewStylusBatcher(now func() time.Duration, ids *PointerIDs) *StylusBatcher
NewStylusBatcher makes a batcher whose events carry the times that now gives and the pointer identifiers that ids gives (nil: a counter of its own). A tool gets a new identifier at each contact with the surface. The batchers of one platform share ids.
Flutter: no counterpart
func (*StylusBatcher) AddTool ¶
func (b *StylusBatcher) AddTool(id int, kind ui.PointerDeviceKind)
AddTool announces a tool. The kind is stylus for a pen, a brush, a pencil or an airbrush, inverted stylus for an eraser, touch for a finger and mouse for a mouse or a lens.
Flutter: no counterpart
func (*StylusBatcher) Button ¶
func (b *StylusBatcher) Button(id int, code uint32, pressed bool)
Button reports that a button of the tool (a Linux button code) was pressed or released.
Flutter: no counterpart
func (*StylusBatcher) CancelView ¶
func (b *StylusBatcher) CancelView(view ui.ViewID)
CancelView cancels the tools that touch a window that goes away and removes the ones that are near it.
Flutter: no counterpart
func (*StylusBatcher) Distance ¶
func (b *StylusBatcher) Distance(id int, raw uint32)
Distance reports the distance of the tool from the surface, from 0 to 65535.
Flutter: no counterpart
func (*StylusBatcher) Down ¶
func (b *StylusBatcher) Down(id int)
Down reports that the tool touches the surface.
Flutter: no counterpart
func (*StylusBatcher) Frame ¶
func (b *StylusBatcher) Frame(id int)
Frame ends the group of events of the tool and turns them into data.
Flutter: no counterpart
func (*StylusBatcher) Motion ¶
func (b *StylusBatcher) Motion(id int, x, y float64)
Motion reports the position of the tool, in logical pixels.
Flutter: no counterpart
func (*StylusBatcher) Pressure ¶
func (b *StylusBatcher) Pressure(id int, raw uint32)
Pressure reports the pressure of the tool, from 0 to 65535.
Flutter: no counterpart
func (*StylusBatcher) ProximityIn ¶
func (b *StylusBatcher) ProximityIn(id int, view ui.ViewID)
ProximityIn reports that the tool came near the window view.
Flutter: no counterpart
func (*StylusBatcher) ProximityOut ¶
func (b *StylusBatcher) ProximityOut(id int)
ProximityOut reports that the tool went away from the surface.
Flutter: no counterpart
func (*StylusBatcher) RemoveTool ¶
func (b *StylusBatcher) RemoveTool(id int)
RemoveTool forgets a tool that went away. A tool that is near a surface is lifted and removed first.
Flutter: no counterpart
func (*StylusBatcher) Rotation ¶
func (b *StylusBatcher) Rotation(id int, degrees float64)
Rotation reports the rotation of the tool around its axis, in degrees.
Flutter: no counterpart
func (*StylusBatcher) Take ¶
func (b *StylusBatcher) Take() []ui.PointerData
Take returns the data since the last call.
Flutter: no counterpart
func (*StylusBatcher) Tilt ¶
func (b *StylusBatcher) Tilt(id int, x, y float64)
Tilt reports the tilt of the tool along the x and y axes, in degrees from the normal of the surface.
Flutter: no counterpart
func (*StylusBatcher) Up ¶
func (b *StylusBatcher) Up(id int)
Up reports that the tool no longer touches the surface.
Flutter: no counterpart
type TouchBatcher ¶
type TouchBatcher struct {
// Scale is the number of physical pixels per logical pixel; the positions the
// batcher gets are logical.
Scale float64
// contains filtered or unexported fields
}
TouchBatcher turns the events of a touch screen into ui.PointerData. Each finger is a device of its own (Flutter tells pointers apart by device): it is added when it touches down and removed when it lifts.
A TouchBatcher is used on the UI thread only.
Flutter: no counterpart
func NewTouchBatcher ¶
func NewTouchBatcher(now func() time.Duration, ids *PointerIDs) *TouchBatcher
NewTouchBatcher makes a batcher whose events carry the times that now gives and the pointer identifiers that ids gives (nil: a counter of its own). A finger gets a new identifier at each down, whatever the id the compositor or the X server gives it (they reuse them), and its events carry it until it lifts. The batchers of one platform share ids.
Flutter: no counterpart
func (*TouchBatcher) Cancel ¶
func (t *TouchBatcher) Cancel()
Cancel cancels every finger, in the order of their ids.
Flutter: no counterpart
func (*TouchBatcher) CancelView ¶
func (t *TouchBatcher) CancelView(view ui.ViewID)
CancelView cancels the fingers on a window that goes away.
Flutter: no counterpart
func (*TouchBatcher) Down ¶
func (t *TouchBatcher) Down(view ui.ViewID, id int32, x, y float64)
Down reports a finger touching the window view at the position, in logical pixels. A finger that is already down with the id is cancelled first.
Flutter: no counterpart
func (*TouchBatcher) Motion ¶
func (t *TouchBatcher) Motion(id int32, x, y float64)
Motion reports a finger that moved.
Flutter: no counterpart
func (*TouchBatcher) Orientation ¶
func (t *TouchBatcher) Orientation(id int32, degrees float64)
Orientation sets the angle of the contact ellipse, in degrees from the vertical; it shows in the events that follow, in radians.
Flutter: no counterpart
func (*TouchBatcher) Shape ¶
func (t *TouchBatcher) Shape(id int32, major, minor float64)
Shape sets the size of the contact ellipse (its axes in logical pixels); it shows in the events that follow.
Flutter: no counterpart
func (*TouchBatcher) Take ¶
func (t *TouchBatcher) Take() []ui.PointerData
Take returns the data since the last call.
Flutter: no counterpart
func (*TouchBatcher) Up ¶
func (t *TouchBatcher) Up(id int32)
Up reports a finger that lifted.
Flutter: no counterpart