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
+157-1Lines changed: 157 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,18 @@ constexpr int WHEEL_DELTA = 120; ///< Standard Windows wheel delta used to norm
42
42
43
43
usingnamespacestd::literals;
44
44
45
+
// Definitions for the cursor-position feedback published by the capture
46
+
// pipeline (declarations in platform/common.h; stores in linux/kmsgrab.cpp).
47
+
namespaceplatf {
48
+
std::atomic<std::int32_t> kms_cursor_x { -1 };
49
+
std::atomic<std::int32_t> kms_cursor_y { -1 };
50
+
std::atomic<std::int32_t> kms_desktop_w { 0 };
51
+
std::atomic<std::int32_t> kms_desktop_h { 0 };
52
+
std::atomic<std::int32_t> kms_logical_w { 0 };
53
+
std::atomic<std::int32_t> kms_logical_h { 0 };
54
+
std::atomic<std::uint64_t> kms_cursor_seq { 0 };
55
+
}
56
+
45
57
namespaceinput {
46
58
47
59
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 +283,17 @@ namespace input {
271
283
272
284
input::touch_port_t touch_port; ///< Touch coordinate bounds for the current stream.
273
285
286
+
bool abs_mouse_initialized = false; ///< Whether the absolute mouse baseline is set.
287
+
float abs_mouse_frac_x = 0; ///< Accumulated fractional X delta.
288
+
float abs_mouse_frac_y = 0; ///< Accumulated fractional Y delta.
289
+
float host_cursor_x = 0; ///< Dead-reckoning estimate of the host cursor X, touch-port pixels.
290
+
float host_cursor_y = 0; ///< Dead-reckoning estimate of the host cursor Y, touch-port pixels.
291
+
std::uint64_t cursor_seq_last = 0; ///< Cursor-feedback sequence seen by the previous event.
292
+
float last_raw_x = 0; ///< Previous raw client X (idle detection).
293
+
float last_raw_y = 0; ///< Previous raw client Y (idle detection).
294
+
std::chrono::steady_clock::time_point last_client_move {}; ///< Last time the client target changed.
295
+
std::chrono::steady_clock::time_point abs_dbg_last {}; ///< Rate limit for debug logging.
0 commit comments