mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-29 08:46:32 +00:00
Prevent the inner terminal scrollable from accepting user scrolling in the alternate buffer, so xterm's existing outer handler receives trackpad gestures after main-screen history. Keep wheel encoding and drag reporting unchanged. Cover trackpad forwarding, subsequent drag coordinates, arrow fallback, and return to local scrollback.
37 lines
1.1 KiB
Dart
37 lines
1.1 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
import 'package:xterm/xterm.dart';
|
|
|
|
class TerminalScrollController extends ScrollController {
|
|
TerminalScrollController(this.terminal);
|
|
|
|
final Terminal Function() terminal;
|
|
|
|
@override
|
|
ScrollPosition createScrollPosition(ScrollPhysics physics,
|
|
ScrollContext context, ScrollPosition? oldPosition) {
|
|
return super.createScrollPosition(
|
|
_TerminalScrollPhysics(terminal, parent: physics),
|
|
context,
|
|
oldPosition,
|
|
);
|
|
}
|
|
}
|
|
|
|
class _TerminalScrollPhysics extends ScrollPhysics {
|
|
const _TerminalScrollPhysics(this.terminal, {super.parent});
|
|
|
|
final Terminal Function() terminal;
|
|
|
|
@override
|
|
_TerminalScrollPhysics applyTo(ScrollPhysics? ancestor) =>
|
|
_TerminalScrollPhysics(terminal, parent: buildParent(ancestor));
|
|
|
|
@override
|
|
bool shouldAcceptUserOffset(ScrollMetrics position) {
|
|
// A retained main-screen offset can make this inner scrollable win the
|
|
// trackpad gesture, starving xterm's outer alternate-screen scroll handler.
|
|
if (terminal().isUsingAltBuffer) return false;
|
|
return super.shouldAcceptUserOffset(position);
|
|
}
|
|
}
|