fix mouse out of bounds

This commit is contained in:
csf 2022-09-13 16:28:22 +08:00
parent 406be63ffd
commit ccb60ace8f

View File

@ -1240,8 +1240,8 @@ class FFI {
return; return;
} }
evt['type'] = type; evt['type'] = type;
var x = evt['x']; double x = evt['x'];
var y = max(0.0, (evt['y'] as double) - tabBarHeight); double y = max(0.0, (evt['y'] as double) - tabBarHeight);
if (isMove) { if (isMove) {
canvasModel.moveDesktopMouse(x, y); canvasModel.moveDesktopMouse(x, y);
} }
@ -1264,9 +1264,6 @@ class FFI {
y -= canvasModel.y; y -= canvasModel.y;
} }
if (!isMove && (x < 0 || x > d.width || y < 0 || y > d.height)) {
return;
}
x /= canvasModel.scale; x /= canvasModel.scale;
y /= canvasModel.scale; y /= canvasModel.scale;
x += d.x; x += d.x;
@ -1275,6 +1272,9 @@ class FFI {
x = 0; x = 0;
y = 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['x'] = '${x.round()}';
evt['y'] = '${y.round()}'; evt['y'] = '${y.round()}';
var buttons = ''; var buttons = '';