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;
}
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 = '';