From a98852e279454bf6a4a082a25a9c4701965d97d7 Mon Sep 17 00:00:00 2001 From: fufesou <13586388+fufesou@users.noreply.github.com> Date: Fri, 29 Aug 2025 01:06:05 +0800 Subject: [PATCH] fix: mouse event, is in current window (#12760) Signed-off-by: fufesou --- flutter/lib/models/input_model.dart | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/flutter/lib/models/input_model.dart b/flutter/lib/models/input_model.dart index b47abdaf8..68cd2f501 100644 --- a/flutter/lib/models/input_model.dart +++ b/flutter/lib/models/input_model.dart @@ -1313,8 +1313,12 @@ class InputModel { isMove = false; canvas = coords.canvas; rect = coords.remoteRect; - x -= coords.relativeOffset.dx / devicePixelRatio; - y -= coords.relativeOffset.dy / devicePixelRatio; + x -= isWindows + ? coords.relativeOffset.dx / devicePixelRatio + : coords.relativeOffset.dx; + y -= isWindows + ? coords.relativeOffset.dy / devicePixelRatio + : coords.relativeOffset.dy; } } } @@ -1339,15 +1343,21 @@ class InputModel { } bool _isInCurrentWindow(double x, double y) { - final w = _windowRect!.width / devicePixelRatio; - final h = _windowRect!.width / devicePixelRatio; + var w = _windowRect!.width; + var h = _windowRect!.height; + if (isWindows) { + w /= devicePixelRatio; + h /= devicePixelRatio; + } return x >= 0 && y >= 0 && x <= w && y <= h; } static RemoteWindowCoords? findRemoteCoords(double x, double y, List remoteWindowCoords, double devicePixelRatio) { - x *= devicePixelRatio; - y *= devicePixelRatio; + if (isWindows) { + x *= devicePixelRatio; + y *= devicePixelRatio; + } for (final c in remoteWindowCoords) { if (x >= c.relativeOffset.dx && y >= c.relativeOffset.dy &&