You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
danalec
committed
linux/input: optionally emulate absolute mouse as relative motion
Some compositors implement assistive features that only track relative
pointer motion; Wayland's PointerMotionAbsolute moves the cursor but such
features do not follow it (e.g. the COSMIC screen magnifier focal point,
pop-os/cosmic-comp#2760). Add an absolute_mouse_as_relative option
(disabled by default) that converts absolute client coordinates into
relative deltas.
The first absolute event still anchors the cursor absolutely. Subsequent
events are turned into relative deltas driven by dead reckoning. The KMS
capture path publishes the real cursor-plane position every frame; the
estimate snaps to it while the client is idle, and a coordinate saturated
at the client's own surface edge targets the matching host edge so
movement cannot stall mid-screen. On backends without cursor feedback
the conversion still works from dead reckoning alone.
Copy file name to clipboardExpand all lines: src/input.cpp
+171-1Lines changed: 171 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,14 @@ constexpr int WHEEL_DELTA = 120; ///< Standard Windows wheel delta used to norm
42
42
43
43
usingnamespacestd::literals;
44
44
45
+
namespaceplatf {
46
+
kms_cursor_feedback_t&
47
+
kms_cursor_feedback() {
48
+
statickms_cursor_feedback_t fb;
49
+
return fb;
50
+
}
51
+
}
52
+
45
53
namespaceinput {
46
54
47
55
constexprautoMAX_GAMEPADS = std::min((std::size_t) platf::MAX_GAMEPADS, sizeof(std::int16_t) * 8); ///< Maximum gamepads representable by the active gamepad mask.
@@ -271,6 +279,20 @@ namespace input {
271
279
272
280
input::touch_port_t touch_port; ///< Touch coordinate bounds for the current stream.
273
281
282
+
/// State of the absolute->relative mouse conversion (absolute_mouse_as_relative).
283
+
structabs_mouse_t {
284
+
bool initialized = false; ///< Whether the absolute baseline is set.
285
+
float frac_x = 0; ///< Accumulated fractional X delta.
286
+
float frac_y = 0; ///< Accumulated fractional Y delta.
287
+
float host_x = 0; ///< Dead-reckoning estimate of the host cursor X, touch-port pixels.
288
+
float host_y = 0; ///< Dead-reckoning estimate of the host cursor Y, touch-port pixels.
289
+
std::uint64_t seq_last = 0; ///< Cursor-feedback sequence seen by the previous event.
290
+
float last_raw_x = 0; ///< Previous raw client X (idle detection).
291
+
float last_raw_y = 0; ///< Previous raw client Y (idle detection).
292
+
std::chrono::steady_clock::time_point last_client_move {}; ///< Last time the client coordinates changed.
0 commit comments