Skip to content

Commit

Permalink
refact: mobile reset canvas (rustdesk#9766)
Browse files Browse the repository at this point in the history
Signed-off-by: fufesou <[email protected]>
  • Loading branch information
fufesou authored Oct 29, 2024
1 parent 3a75947 commit f0450db
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions flutter/lib/models/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1659,11 +1659,25 @@ class CanvasModel with ChangeNotifier {
notifyListeners();
}

clear([bool notify = false]) {
// For reset canvas to the last view style
reset() {
_scale = _lastViewStyle.scale;
_devicePixelRatio = ui.window.devicePixelRatio;
if (kIgnoreDpi && _lastViewStyle.style == kRemoteViewStyleOriginal) {
_scale = 1.0 / _devicePixelRatio;
}
final displayWidth = getDisplayWidth();
final displayHeight = getDisplayHeight();
_x = (size.width - displayWidth * _scale) / 2;
_y = (size.height - displayHeight * _scale) / 2;
bind.sessionSetViewStyle(sessionId: sessionId, value: _lastViewStyle.style);
notifyListeners();
}

clear() {
_x = 0;
_y = 0;
_scale = 1.0;
if (notify) notifyListeners();
}

updateScrollPercent() {
Expand Down Expand Up @@ -1988,7 +2002,7 @@ class CursorModel with ChangeNotifier {
_x = _displayOriginX;
_y = _displayOriginY;
parent.target?.inputModel.moveMouse(_x, _y);
parent.target?.canvasModel.clear(true);
parent.target?.canvasModel.reset();
notifyListeners();
}

Expand Down

0 comments on commit f0450db

Please sign in to comment.