From 222dbf12cddd048034dabc94ad2ef034d8cbe0e8 Mon Sep 17 00:00:00 2001 From: fufesou <13586388+fufesou@users.noreply.github.com> Date: Wed, 15 Jan 2025 18:24:50 +0800 Subject: [PATCH] fix: mobile, don't reset canvas on metrics changed (#10463) Signed-off-by: fufesou --- flutter/lib/models/model.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index 5a5dcf623eed..748fa1c4043d 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -1500,13 +1500,15 @@ class CanvasModel with ChangeNotifier { return max(bottom - MediaQueryData.fromView(ui.window).padding.top, 0); } + updateSize() => _size = getSize(); + updateViewStyle({refreshMousePos = true, notify = true}) async { final style = await bind.sessionGetViewStyle(sessionId: sessionId); if (style == null) { return; } - _size = getSize(); + updateSize(); final displayWidth = getDisplayWidth(); final displayHeight = getDisplayHeight(); final viewStyle = ViewStyle( @@ -1543,7 +1545,7 @@ class CanvasModel with ChangeNotifier { _resetCanvasOffset(int displayWidth, int displayHeight) { _x = (size.width - displayWidth * _scale) / 2; _y = (size.height - displayHeight * _scale) / 2; - if (isMobile && _lastViewStyle.style == kRemoteViewStyleOriginal) { + if (isMobile) { _moveToCenterCursor(); } } @@ -1736,7 +1738,8 @@ class CanvasModel with ChangeNotifier { _timerMobileFocusCanvasCursor?.cancel(); _timerMobileFocusCanvasCursor = Timer(Duration(milliseconds: 100), () async { - await updateViewStyle(refreshMousePos: false, notify: false); + updateSize(); + _resetCanvasOffset(getDisplayWidth(), getDisplayHeight()); notifyListeners(); }); }