Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorPointerShaders::PointerFrameState Struct Reference

Plain-data snapshot of everything the pointer contract's tail carries for one frame. More...

#include <PhosphorPointer/PointerFrameState.h>

Public Member Functions

bool trailIsEmpty () const
int trailSize () const
const QVector4D & newestTrail () const
 The newest sample, which is the pointer itself.
const QVector4D & trailAt (int index) const

Public Attributes

QVector2D velocity
 Pointer velocity in device px/s.
double filteredSpeed = 0.0
 Pointer speed with the per-sample jitter filtered out, in device px/s: an exponential filter walked over the current stroke's samples, oldest to newest (see PointerHistory::filteredSpeed).
QPointF pressPos
 Last press: position, seconds since (kNeverSeconds when none), button code (1 left, 2 right, 3 middle, 0 none).
double pressSecondsSince = PointerShaderContract::kNeverSeconds
int pressButton = 0
QPointF releasePos
 Last release, same shape.
double releaseSecondsSince = PointerShaderContract::kNeverSeconds
int releaseButton = 0
int buttons = 0
 Pressed-button bitmask (1 left, 2 right, 4 middle).
double idleSeconds = PointerShaderContract::kNeverSeconds
 Seconds since the last motion (kNeverSeconds when none).
double scale = 1.0
 Logical-to-device scale of the canvas.
QRectF cursorRect
 Cursor sprite rect in canvas px, hotspot applied. Null when unknown.
bool hasSprite = false
 Whether uCursorSprite is bound this frame.
std::array< QVector4D, PointerShaderContract::kMaxTrailPoints > trail {}
 Trail samples, newest first: .xy canvas px, .z age seconds, .w speed at the sample (device px/s).
int trailCount = 0

Detailed Description

Plain-data snapshot of everything the pointer contract's tail carries for one frame.

PointerHistory::frameState produces it, and both hosts (the compositor pushing loose uniforms and the preview driving the UBO through PointerUniformExtension::apply) consume the same type. Positions are in canvas px (device px, top-down, origin at the output's top-left).

It lives in its own header so a sampler consumer that only needs the frame shape does not pull the UBO extension's mutex and atomics along.

Member Function Documentation

◆ newestTrail()

const QVector4D & PhosphorPointerShaders::PointerFrameState::newestTrail ( ) const
inlinenodiscard

The newest sample, which is the pointer itself.

Only meaningful when !trailIsEmpty(); on an empty trail it is the zero vector.

◆ trailAt()

const QVector4D & PhosphorPointerShaders::PointerFrameState::trailAt ( int index) const
inlinenodiscard

◆ trailIsEmpty()

bool PhosphorPointerShaders::PointerFrameState::trailIsEmpty ( ) const
inlinenodiscard

◆ trailSize()

int PhosphorPointerShaders::PointerFrameState::trailSize ( ) const
inlinenodiscard

Member Data Documentation

◆ buttons

int PhosphorPointerShaders::PointerFrameState::buttons = 0

Pressed-button bitmask (1 left, 2 right, 4 middle).

◆ cursorRect

QRectF PhosphorPointerShaders::PointerFrameState::cursorRect

Cursor sprite rect in canvas px, hotspot applied. Null when unknown.

◆ filteredSpeed

double PhosphorPointerShaders::PointerFrameState::filteredSpeed = 0.0

Pointer speed with the per-sample jitter filtered out, in device px/s: an exponential filter walked over the current stroke's samples, oldest to newest (see PointerHistory::filteredSpeed).

Pushed as uPointerVelocity.w, which is what pointerFilteredSpeed() in the shared shader library reads, so the speed a pack gates on is computed once per frame by the sampler that owns the ring rather than by every fragment.

◆ hasSprite

bool PhosphorPointerShaders::PointerFrameState::hasSprite = false

Whether uCursorSprite is bound this frame.

◆ idleSeconds

double PhosphorPointerShaders::PointerFrameState::idleSeconds = PointerShaderContract::kNeverSeconds

Seconds since the last motion (kNeverSeconds when none).

◆ pressButton

int PhosphorPointerShaders::PointerFrameState::pressButton = 0

◆ pressPos

QPointF PhosphorPointerShaders::PointerFrameState::pressPos

Last press: position, seconds since (kNeverSeconds when none), button code (1 left, 2 right, 3 middle, 0 none).

◆ pressSecondsSince

double PhosphorPointerShaders::PointerFrameState::pressSecondsSince = PointerShaderContract::kNeverSeconds

◆ releaseButton

int PhosphorPointerShaders::PointerFrameState::releaseButton = 0

◆ releasePos

QPointF PhosphorPointerShaders::PointerFrameState::releasePos

Last release, same shape.

◆ releaseSecondsSince

double PhosphorPointerShaders::PointerFrameState::releaseSecondsSince = PointerShaderContract::kNeverSeconds

◆ scale

double PhosphorPointerShaders::PointerFrameState::scale = 1.0

Logical-to-device scale of the canvas.

◆ trail

std::array<QVector4D, PointerShaderContract::kMaxTrailPoints> PhosphorPointerShaders::PointerFrameState::trail {}

Trail samples, newest first: .xy canvas px, .z age seconds, .w speed at the sample (device px/s).

Only the first trailCount entries are meaningful and the rest are zero. Fixed storage rather than a list because a frame state is built once per painted frame on the compositor path, and the ring never holds more than the contract's capacity anyway.

◆ trailCount

int PhosphorPointerShaders::PointerFrameState::trailCount = 0

◆ velocity

QVector2D PhosphorPointerShaders::PointerFrameState::velocity

Pointer velocity in device px/s.


The documentation for this struct was generated from the following file: