|
@@ -3,13 +3,16 @@ import 'package:flutter/widgets.dart';
|
|
|
import 'package:xterm/src/core/mouse/button.dart';
|
|
import 'package:xterm/src/core/mouse/button.dart';
|
|
|
import 'package:xterm/src/core/mouse/button_state.dart';
|
|
import 'package:xterm/src/core/mouse/button_state.dart';
|
|
|
import 'package:xterm/src/terminal_view.dart';
|
|
import 'package:xterm/src/terminal_view.dart';
|
|
|
|
|
+import 'package:xterm/src/ui/controller.dart';
|
|
|
import 'package:xterm/src/ui/gesture/gesture_detector.dart';
|
|
import 'package:xterm/src/ui/gesture/gesture_detector.dart';
|
|
|
|
|
+import 'package:xterm/src/ui/pointer_input.dart';
|
|
|
import 'package:xterm/src/ui/render.dart';
|
|
import 'package:xterm/src/ui/render.dart';
|
|
|
|
|
|
|
|
class TerminalGestureHandler extends StatefulWidget {
|
|
class TerminalGestureHandler extends StatefulWidget {
|
|
|
const TerminalGestureHandler({
|
|
const TerminalGestureHandler({
|
|
|
super.key,
|
|
super.key,
|
|
|
required this.terminalView,
|
|
required this.terminalView,
|
|
|
|
|
+ required this.terminalController,
|
|
|
this.child,
|
|
this.child,
|
|
|
this.onTapUp,
|
|
this.onTapUp,
|
|
|
this.onSingleTapUp,
|
|
this.onSingleTapUp,
|
|
@@ -22,6 +25,8 @@ class TerminalGestureHandler extends StatefulWidget {
|
|
|
|
|
|
|
|
final TerminalViewState terminalView;
|
|
final TerminalViewState terminalView;
|
|
|
|
|
|
|
|
|
|
+ final TerminalController terminalController;
|
|
|
|
|
+
|
|
|
final Widget? child;
|
|
final Widget? child;
|
|
|
|
|
|
|
|
final GestureTapUpCallback? onTapUp;
|
|
final GestureTapUpCallback? onTapUp;
|
|
@@ -71,58 +76,73 @@ class _TerminalGestureHandlerState extends State<TerminalGestureHandler> {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ bool get _shouldSendTapEvent =>
|
|
|
|
|
+ widget.terminalController.shouldSendPointerInput(PointerInput.tap);
|
|
|
|
|
+
|
|
|
void onTapDown(TapDownDetails details) {
|
|
void onTapDown(TapDownDetails details) {
|
|
|
widget.onTapDown?.call(details);
|
|
widget.onTapDown?.call(details);
|
|
|
- renderTerminal.mouseEvent(
|
|
|
|
|
- TerminalMouseButton.left,
|
|
|
|
|
- TerminalMouseButtonState.down,
|
|
|
|
|
- details.localPosition,
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ if (_shouldSendTapEvent) {
|
|
|
|
|
+ renderTerminal.mouseEvent(
|
|
|
|
|
+ TerminalMouseButton.left,
|
|
|
|
|
+ TerminalMouseButtonState.down,
|
|
|
|
|
+ details.localPosition,
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void onSingleTapUp(TapUpDetails details) {
|
|
void onSingleTapUp(TapUpDetails details) {
|
|
|
widget.onSingleTapUp?.call(details);
|
|
widget.onSingleTapUp?.call(details);
|
|
|
- renderTerminal.mouseEvent(
|
|
|
|
|
- TerminalMouseButton.left,
|
|
|
|
|
- TerminalMouseButtonState.up,
|
|
|
|
|
- details.localPosition,
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ if (_shouldSendTapEvent) {
|
|
|
|
|
+ renderTerminal.mouseEvent(
|
|
|
|
|
+ TerminalMouseButton.left,
|
|
|
|
|
+ TerminalMouseButtonState.up,
|
|
|
|
|
+ details.localPosition,
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void onSecondaryTapDown(TapDownDetails details) {
|
|
void onSecondaryTapDown(TapDownDetails details) {
|
|
|
widget.onSecondaryTapDown?.call(details);
|
|
widget.onSecondaryTapDown?.call(details);
|
|
|
- renderTerminal.mouseEvent(
|
|
|
|
|
- TerminalMouseButton.right,
|
|
|
|
|
- TerminalMouseButtonState.down,
|
|
|
|
|
- details.localPosition,
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ if (_shouldSendTapEvent) {
|
|
|
|
|
+ renderTerminal.mouseEvent(
|
|
|
|
|
+ TerminalMouseButton.right,
|
|
|
|
|
+ TerminalMouseButtonState.down,
|
|
|
|
|
+ details.localPosition,
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void onSecondaryTapUp(TapUpDetails details) {
|
|
void onSecondaryTapUp(TapUpDetails details) {
|
|
|
widget.onSecondaryTapUp?.call(details);
|
|
widget.onSecondaryTapUp?.call(details);
|
|
|
- renderTerminal.mouseEvent(
|
|
|
|
|
- TerminalMouseButton.right,
|
|
|
|
|
- TerminalMouseButtonState.up,
|
|
|
|
|
- details.localPosition,
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ if (_shouldSendTapEvent) {
|
|
|
|
|
+ renderTerminal.mouseEvent(
|
|
|
|
|
+ TerminalMouseButton.right,
|
|
|
|
|
+ TerminalMouseButtonState.up,
|
|
|
|
|
+ details.localPosition,
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void onTertiaryTapDown(TapDownDetails details) {
|
|
void onTertiaryTapDown(TapDownDetails details) {
|
|
|
widget.onTertiaryTapDown?.call(details);
|
|
widget.onTertiaryTapDown?.call(details);
|
|
|
- renderTerminal.mouseEvent(
|
|
|
|
|
- TerminalMouseButton.middle,
|
|
|
|
|
- TerminalMouseButtonState.down,
|
|
|
|
|
- details.localPosition,
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ if (_shouldSendTapEvent) {
|
|
|
|
|
+ renderTerminal.mouseEvent(
|
|
|
|
|
+ TerminalMouseButton.middle,
|
|
|
|
|
+ TerminalMouseButtonState.down,
|
|
|
|
|
+ details.localPosition,
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void onTertiaryTapUp(TapUpDetails details) {
|
|
void onTertiaryTapUp(TapUpDetails details) {
|
|
|
widget.onTertiaryTapUp?.call(details);
|
|
widget.onTertiaryTapUp?.call(details);
|
|
|
- renderTerminal.mouseEvent(
|
|
|
|
|
- TerminalMouseButton.middle,
|
|
|
|
|
- TerminalMouseButtonState.up,
|
|
|
|
|
- details.localPosition,
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ if (_shouldSendTapEvent) {
|
|
|
|
|
+ renderTerminal.mouseEvent(
|
|
|
|
|
+ TerminalMouseButton.middle,
|
|
|
|
|
+ TerminalMouseButtonState.up,
|
|
|
|
|
+ details.localPosition,
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void onDoubleTapDown(TapDownDetails details) {
|
|
void onDoubleTapDown(TapDownDetails details) {
|