d3b6026bfd
- Filled empty libs/hbb_common/ submodule (cloned from rustdesk/hbb_common) - Patched Flutter 3.44 / Dart 3.12 compatibility: * flutter/lib/generated_bridge.dart: asTypedList with cast<>, DartPort=Int64 * flutter/lib/common.dart: DialogTheme->DialogThemeData, TabBarTheme->TabBarThemeData * flutter/pubspec.yaml: extended_text 14.0.0->15.0.2, google_fonts override 5.0.0 * flutter/macos/Runner/Configs/Release.xcconfig: EXCLUDED_ARCHS=x86_64 - Build verified: cargo check + cargo build --features flutter + cargo build --release --features flutter - Verified flutter build macos --debug and --release both produce working .app - Verified .dmg installer (27MB arm64) created via hdiutil - Build deps: Xcode 26.5, CocoaPods 1.16.2, Flutter 3.44, VCPKG arm64-osx
59 lines
1.6 KiB
Dart
59 lines
1.6 KiB
Dart
/// A small helper for accumulating fractional mouse deltas and emitting integer deltas.
|
|
///
|
|
/// Relative mouse mode uses integer deltas on the wire, but Flutter pointer deltas
|
|
/// are doubles. This accumulator preserves sub-pixel movement by carrying the
|
|
/// fractional remainder across events.
|
|
class RelativeMouseDelta {
|
|
final int x;
|
|
final int y;
|
|
|
|
const RelativeMouseDelta(this.x, this.y);
|
|
}
|
|
|
|
/// Accumulates fractional mouse deltas and returns integer deltas when available.
|
|
class RelativeMouseAccumulator {
|
|
double _fracX = 0.0;
|
|
double _fracY = 0.0;
|
|
|
|
/// Adds a delta and returns an integer delta when at least one axis reaches a
|
|
/// magnitude of 1px (after truncation towards zero).
|
|
///
|
|
/// If [maxDelta] is > 0, the returned integer delta is clamped to
|
|
/// [-maxDelta, maxDelta] on each axis.
|
|
RelativeMouseDelta? add(
|
|
double dx,
|
|
double dy, {
|
|
required int maxDelta,
|
|
}) {
|
|
// Guard against misuse: negative maxDelta would silently disable clamping.
|
|
assert(maxDelta >= 0, 'maxDelta must be non-negative');
|
|
|
|
_fracX += dx;
|
|
_fracY += dy;
|
|
|
|
int intX = _fracX.truncate();
|
|
int intY = _fracY.truncate();
|
|
|
|
if (intX == 0 && intY == 0) {
|
|
return null;
|
|
}
|
|
|
|
// Clamp before subtracting so excess movement is preserved in the accumulator
|
|
// rather than being permanently discarded during spikes.
|
|
if (maxDelta > 0) {
|
|
intX = intX.clamp(-maxDelta, maxDelta);
|
|
intY = intY.clamp(-maxDelta, maxDelta);
|
|
}
|
|
|
|
_fracX -= intX;
|
|
_fracY -= intY;
|
|
|
|
return RelativeMouseDelta(intX, intY);
|
|
}
|
|
|
|
void reset() {
|
|
_fracX = 0.0;
|
|
_fracY = 0.0;
|
|
}
|
|
}
|