Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PointerFrameState.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
7#include <PhosphorPointer/phosphorpointer_export.h>
8
9#include <QPointF>
10#include <QRectF>
11#include <QVector2D>
12#include <QVector4D>
13
14#include <array>
15
17
26struct PHOSPHORPOINTER_EXPORT PointerFrameState
27{
29 QVector2D velocity;
30
38 double filteredSpeed = 0.0;
39
42 QPointF pressPos;
44 int pressButton = 0;
45
47 QPointF releasePos;
50
52 int buttons = 0;
53
56
58 double scale = 1.0;
59
61 QRectF cursorRect;
62
64 bool hasSprite = false;
65
72 std::array<QVector4D, PointerShaderContract::kMaxTrailPoints> trail{};
73 int trailCount = 0;
74
75 [[nodiscard]] bool trailIsEmpty() const
76 {
77 return trailCount <= 0;
78 }
79 [[nodiscard]] int trailSize() const
80 {
81 return trailCount;
82 }
83
85 [[nodiscard]] const QVector4D& newestTrail() const
86 {
87 return trail[0];
88 }
89 [[nodiscard]] const QVector4D& trailAt(int index) const
90 {
91 return trail[static_cast<size_t>(index)];
92 }
93};
94
95} // namespace PhosphorPointerShaders
constexpr double kNeverSeconds
The "none this session" sentinel for the seconds-since lanes of uPointerPress.z, uPointerRelease....
Definition PointerShaderContract.h:214
Definition PointerFrameState.h:16
Plain-data snapshot of everything the pointer contract's tail carries for one frame.
Definition PointerFrameState.h:27
QRectF cursorRect
Cursor sprite rect in canvas px, hotspot applied. Null when unknown.
Definition PointerFrameState.h:61
double filteredSpeed
Pointer speed with the per-sample jitter filtered out, in device px/s: an exponential filter walked o...
Definition PointerFrameState.h:38
int trailSize() const
Definition PointerFrameState.h:79
double scale
Logical-to-device scale of the canvas.
Definition PointerFrameState.h:58
double releaseSecondsSince
Definition PointerFrameState.h:48
int buttons
Pressed-button bitmask (1 left, 2 right, 4 middle).
Definition PointerFrameState.h:52
bool hasSprite
Whether uCursorSprite is bound this frame.
Definition PointerFrameState.h:64
int pressButton
Definition PointerFrameState.h:44
std::array< QVector4D, PointerShaderContract::kMaxTrailPoints > trail
Trail samples, newest first: .xy canvas px, .z age seconds, .w speed at the sample (device px/s).
Definition PointerFrameState.h:72
double idleSeconds
Seconds since the last motion (kNeverSeconds when none).
Definition PointerFrameState.h:55
int releaseButton
Definition PointerFrameState.h:49
int trailCount
Definition PointerFrameState.h:73
const QVector4D & trailAt(int index) const
Definition PointerFrameState.h:89
QVector2D velocity
Pointer velocity in device px/s.
Definition PointerFrameState.h:29
const QVector4D & newestTrail() const
The newest sample, which is the pointer itself.
Definition PointerFrameState.h:85
QPointF pressPos
Last press: position, seconds since (kNeverSeconds when none), button code (1 left,...
Definition PointerFrameState.h:42
QPointF releasePos
Last release, same shape.
Definition PointerFrameState.h:47
double pressSecondsSince
Definition PointerFrameState.h:43
bool trailIsEmpty() const
Definition PointerFrameState.h:75