From ccb60ace8fde3fde2d4bd9bde93b90e3994a8674 Mon Sep 17 00:00:00 2001 From: csf Date: Tue, 13 Sep 2022 16:28:22 +0800 Subject: [PATCH] fix mouse out of bounds --- flutter/lib/models/model.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index c37ae1046..c6f38534a 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -1240,8 +1240,8 @@ class FFI { return; } evt['type'] = type; - var x = evt['x']; - var y = max(0.0, (evt['y'] as double) - tabBarHeight); + double x = evt['x']; + double y = max(0.0, (evt['y'] as double) - tabBarHeight); if (isMove) { canvasModel.moveDesktopMouse(x, y); } @@ -1264,9 +1264,6 @@ class FFI { y -= canvasModel.y; } - if (!isMove && (x < 0 || x > d.width || y < 0 || y > d.height)) { - return; - } x /= canvasModel.scale; y /= canvasModel.scale; x += d.x; @@ -1275,6 +1272,9 @@ class FFI { x = 0; y = 0; } + // fix mouse out of bounds + x = min(max(0.0, x), d.width.toDouble()); + y = min(max(0.0, y), d.height.toDouble()); evt['x'] = '${x.round()}'; evt['y'] = '${y.round()}'; var buttons = '';