mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-27 14:59:02 +08:00
fix: mobile, soft keyboard (#9860)
Switching the input method, don't affect the canvas. Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
a277b022ff
commit
d3efcd4223
@ -134,6 +134,13 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeMetrics() {
|
void didChangeMetrics() {
|
||||||
|
// If the soft keyboard is visible and the canvas has been changed(panned or scaled)
|
||||||
|
// Don't try reset the view style and focus the cursor.
|
||||||
|
if (gFFI.cursorModel.lastKeyboardIsVisible &&
|
||||||
|
gFFI.canvasModel.isMobileCanvasChanged) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final newBottom = MediaQueryData.fromView(ui.window).viewInsets.bottom;
|
final newBottom = MediaQueryData.fromView(ui.window).viewInsets.bottom;
|
||||||
_timerDidChangeMetrics?.cancel();
|
_timerDidChangeMetrics?.cancel();
|
||||||
_timerDidChangeMetrics = Timer(Duration(milliseconds: 100), () async {
|
_timerDidChangeMetrics = Timer(Duration(milliseconds: 100), () async {
|
||||||
@ -563,7 +570,7 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
|||||||
// `onChanged` may be called depending on the input method if this widget is wrapped in
|
// `onChanged` may be called depending on the input method if this widget is wrapped in
|
||||||
// `Focus(onKeyEvent: ..., child: ...)`
|
// `Focus(onKeyEvent: ..., child: ...)`
|
||||||
// For `Backspace` button in the soft keyboard:
|
// For `Backspace` button in the soft keyboard:
|
||||||
// en/fr input method:
|
// en/fr input method:
|
||||||
// 1. The button will not trigger `onKeyEvent` if the text field is not empty.
|
// 1. The button will not trigger `onKeyEvent` if the text field is not empty.
|
||||||
// 2. The button will trigger `onKeyEvent` if the text field is empty.
|
// 2. The button will trigger `onKeyEvent` if the text field is empty.
|
||||||
// ko/zh/ja input method: the button will trigger `onKeyEvent`
|
// ko/zh/ja input method: the button will trigger `onKeyEvent`
|
||||||
|
@ -1424,6 +1424,10 @@ class CanvasModel with ChangeNotifier {
|
|||||||
|
|
||||||
Timer? _timerMobileFocusCanvasCursor;
|
Timer? _timerMobileFocusCanvasCursor;
|
||||||
|
|
||||||
|
// `isMobileCanvasChanged` is used to avoid canvas reset when changing the input method
|
||||||
|
// after showing the soft keyboard.
|
||||||
|
bool isMobileCanvasChanged = false;
|
||||||
|
|
||||||
final ScrollController _horizontal = ScrollController();
|
final ScrollController _horizontal = ScrollController();
|
||||||
final ScrollController _vertical = ScrollController();
|
final ScrollController _vertical = ScrollController();
|
||||||
|
|
||||||
@ -1639,6 +1643,9 @@ class CanvasModel with ChangeNotifier {
|
|||||||
|
|
||||||
panX(double dx) {
|
panX(double dx) {
|
||||||
_x += dx;
|
_x += dx;
|
||||||
|
if (isMobile) {
|
||||||
|
isMobileCanvasChanged = true;
|
||||||
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1653,6 +1660,9 @@ class CanvasModel with ChangeNotifier {
|
|||||||
|
|
||||||
panY(double dy) {
|
panY(double dy) {
|
||||||
_y += dy;
|
_y += dy;
|
||||||
|
if (isMobile) {
|
||||||
|
isMobileCanvasChanged = true;
|
||||||
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1672,6 +1682,9 @@ class CanvasModel with ChangeNotifier {
|
|||||||
// (focalPoint.dy - _y_1 - adjust) / s1 + displayOriginY = (focalPoint.dy - _y_2 - adjust) / s2 + displayOriginY
|
// (focalPoint.dy - _y_1 - adjust) / s1 + displayOriginY = (focalPoint.dy - _y_2 - adjust) / s2 + displayOriginY
|
||||||
// _y_2 = focalPoint.dy - adjust - (focalPoint.dy - _y_1 - adjust) / s1 * s2
|
// _y_2 = focalPoint.dy - adjust - (focalPoint.dy - _y_1 - adjust) / s1 * s2
|
||||||
_y = focalPoint.dy - adjust - (focalPoint.dy - _y - adjust) / s * _scale;
|
_y = focalPoint.dy - adjust - (focalPoint.dy - _y - adjust) / s * _scale;
|
||||||
|
if (isMobile) {
|
||||||
|
isMobileCanvasChanged = true;
|
||||||
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1941,6 +1954,8 @@ class CursorModel with ChangeNotifier {
|
|||||||
bool _lastIsBlocked = false;
|
bool _lastIsBlocked = false;
|
||||||
bool _lastKeyboardIsVisible = false;
|
bool _lastKeyboardIsVisible = false;
|
||||||
|
|
||||||
|
bool get lastKeyboardIsVisible => _lastKeyboardIsVisible;
|
||||||
|
|
||||||
Rect? get keyHelpToolsRectToAdjustCanvas =>
|
Rect? get keyHelpToolsRectToAdjustCanvas =>
|
||||||
_lastKeyboardIsVisible ? _keyHelpToolsRect : null;
|
_lastKeyboardIsVisible ? _keyHelpToolsRect : null;
|
||||||
keyHelpToolsVisibilityChanged(Rect? r, bool keyboardIsVisible) {
|
keyHelpToolsVisibilityChanged(Rect? r, bool keyboardIsVisible) {
|
||||||
@ -1955,6 +1970,7 @@ class CursorModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
if (isMobile && _lastKeyboardIsVisible != keyboardIsVisible) {
|
if (isMobile && _lastKeyboardIsVisible != keyboardIsVisible) {
|
||||||
parent.target?.canvasModel.mobileFocusCanvasCursor();
|
parent.target?.canvasModel.mobileFocusCanvasCursor();
|
||||||
|
parent.target?.canvasModel.isMobileCanvasChanged = false;
|
||||||
}
|
}
|
||||||
_lastKeyboardIsVisible = keyboardIsVisible;
|
_lastKeyboardIsVisible = keyboardIsVisible;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user