Merge pull request #3360 from fufesou/refact/better_mouse_pos

better mouse position
This commit is contained in:
RustDesk 2023-02-25 08:50:25 +08:00 committed by GitHub
commit 365273e3a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -459,17 +459,22 @@ class InputModel {
} }
evt['type'] = type; evt['type'] = type;
if (isDesktop) { if (isDesktop) {
y = y - stateGlobal.tabBarHeight; y = y - stateGlobal.tabBarHeight - stateGlobal.windowBorderWidth.value;
x -= stateGlobal.windowBorderWidth.value;
} }
final canvasModel = parent.target!.canvasModel; final canvasModel = parent.target!.canvasModel;
final nearThr = 3;
var nearRight = (canvasModel.size.width - x) < nearThr;
var nearBottom = (canvasModel.size.height - y) < nearThr;
final ffiModel = parent.target!.ffiModel; final ffiModel = parent.target!.ffiModel;
if (isMove) { if (isMove) {
canvasModel.moveDesktopMouse(x, y); canvasModel.moveDesktopMouse(x, y);
} }
final d = ffiModel.display; final d = ffiModel.display;
final imageWidth = d.width * canvasModel.scale;
final imageHeight = d.height * canvasModel.scale;
if (canvasModel.scrollStyle == ScrollStyle.scrollbar) { if (canvasModel.scrollStyle == ScrollStyle.scrollbar) {
final imageWidth = d.width * canvasModel.scale;
final imageHeight = d.height * canvasModel.scale;
x += imageWidth * canvasModel.scrollX; x += imageWidth * canvasModel.scrollX;
y += imageHeight * canvasModel.scrollY; y += imageHeight * canvasModel.scrollY;
@ -487,6 +492,15 @@ class InputModel {
x /= canvasModel.scale; x /= canvasModel.scale;
y /= canvasModel.scale; y /= canvasModel.scale;
if (canvasModel.scale > 0 && canvasModel.scale < 1) {
final step = 1.0 / canvasModel.scale - 1;
if (nearRight) {
x += step;
}
if (nearBottom) {
y += step;
}
}
x += d.x; x += d.x;
y += d.y; y += d.y;