diff --git a/flutter_hbb/lib/model.dart b/flutter_hbb/lib/model.dart index c65784b21..e61f1f283 100644 --- a/flutter_hbb/lib/model.dart +++ b/flutter_hbb/lib/model.dart @@ -408,9 +408,16 @@ class FFI { return getByName('remote_id'); } - static void tap() { - sendMouse('down', 'left'); - sendMouse('up', 'left'); + static void tap(bool right) { + sendMouse('down', right ? 'right' : 'left'); + sendMouse('up', right ? 'right' : 'left'); + } + + static void scroll(double y) { + var y2 = y.round(); + if (y2 == 0) return; + setByName('send_mouse', + json.encode(modify({'type': 'wheel', 'y': y2.toString()}))); } static void resetModifiers() { diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index f82cef032..b98029da6 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -94,9 +94,6 @@ class _RemotePageState extends State { @override Widget build(BuildContext context) { - final size = MediaQueryData.fromWindow(ui.window).size; - print('$size'); - print('${MediaQuery.of(context).size}'); EasyLoading.instance.loadingStyle = EasyLoadingStyle.light; return WillPopScope( onWillPop: () async { @@ -178,12 +175,16 @@ class _RemotePageState extends State { : null, body: GestureDetector( onTap: () { - FFI.tap(); + if (_drag || _scroll) return; + FFI.tap(_right); }, onScaleStart: (details) { _scale = 1; _xOffset = details.focalPoint.dx; _yOffset = details.focalPoint.dy; + if (_drag) { + FFI.sendMouse('down', 'left'); + } }, onScaleUpdate: (details) { var scale = details.scale; @@ -192,15 +193,23 @@ class _RemotePageState extends State { var y = details.focalPoint.dy; var dx = x - _xOffset; var dy = y - _yOffset; - FFI.cursorModel.updatePan(dx, dy); + if (_scroll) { + FFI.scroll(-dy); + } else { + FFI.cursorModel.updatePan(dx, dy); + } _xOffset = x; _yOffset = y; - } else { + } else if (!_drag && !_scroll) { FFI.canvasModel.updateScale(scale / _scale); _scale = scale; } }, - onScaleEnd: (_) {}, + onScaleEnd: (_) { + if (_drag) { + FFI.sendMouse('up', 'left'); + } + }, child: FlutterEasyLoading( child: Container( color: MyTheme.canvasColor,