diff --git a/flutter_hbb/lib/model.dart b/flutter_hbb/lib/model.dart index ebf4b1755..4949ddcf6 100644 --- a/flutter_hbb/lib/model.dart +++ b/flutter_hbb/lib/model.dart @@ -252,6 +252,13 @@ class CursorModel with ChangeNotifier { return Rect.fromLTWH(x0, y0, size.width / scale, size.height / scale); } + double adjustForKeyboard() { + var keyboardHeight = MediaQueryData.fromWindow(ui.window).viewInsets.bottom; + if (keyboardHeight < 100) return 0; + var h = _y - getVisibleRect().top; + return h > 200 ? h - 200 : 0; + } + void updatePan(double dx, double dy) { final scale = FFI.canvasModel.scale; dx /= scale; diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index 0d9b2814d..137181686 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -221,10 +221,11 @@ class ImagePaint extends StatelessWidget { Widget build(BuildContext context) { final m = Provider.of(context); final c = Provider.of(context); + final adjust = FFI.cursorModel.adjustForKeyboard(); var s = c.scale; return CustomPaint( - painter: - new ImagePainter(image: m.image, x: c.x / s, y: c.y / s, scale: s), + painter: new ImagePainter( + image: m.image, x: c.x / s, y: (c.y - adjust) / s, scale: s), ); } } @@ -234,12 +235,13 @@ class CursorPaint extends StatelessWidget { Widget build(BuildContext context) { final m = Provider.of(context); final c = Provider.of(context); + final adjust = FFI.cursorModel.adjustForKeyboard(); var s = c.scale; return CustomPaint( painter: new ImagePainter( image: m.image, x: m.x * s - m.hotx + c.x, - y: m.y * s - m.hoty + c.y, + y: m.y * s - m.hoty + c.y - adjust, scale: 1), ); }