Skip to content

Commit

Permalink
Merge branch 'rustdesk:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbo8418 authored Oct 29, 2024
2 parents f568d3c + 1c9b456 commit 31dbbdc
Show file tree
Hide file tree
Showing 5 changed files with 326 additions and 302 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ body:
id: os
attributes:
label: Operating system(s) on local side and remote side
description: What operating system(s) do you see this bug on? local side -> remote side.
description: What operating system(s) do you see this bug on? local (controlling) side -> remote (controlled) side.
placeholder: |
Windows 10 -> osx
validations:
Expand Down
26 changes: 16 additions & 10 deletions flutter/lib/mobile/pages/remote_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ class _RemotePageState extends State<RemotePage> {

final TextEditingController _textController =
TextEditingController(text: initText);
// This timer is used to check the composing status of the soft keyboard.
// It is used for Android, Korean(and other similar) input method.
Timer? _composingTimer;
bool _lastComposingChangeValid = false;

_RemotePageState(String id) {
initSharedStates(id);
Expand Down Expand Up @@ -99,6 +97,9 @@ class _RemotePageState extends State<RemotePage> {
showToast(translate('Automatically record outgoing sessions'));
}
});
if (isAndroid) {
_textController.addListener(textAndroidListener);
}
}

@override
Expand All @@ -114,7 +115,6 @@ class _RemotePageState extends State<RemotePage> {
_physicalFocusNode.dispose();
await gFFI.close();
_timer?.cancel();
_composingTimer?.cancel();
gFFI.dialogManager.dismissAll();
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
overlays: SystemUiOverlay.values);
Expand All @@ -127,6 +127,16 @@ class _RemotePageState extends State<RemotePage> {
// The inner logic of `on_voice_call_closed` will check if the voice call is active.
// Only one client is considered here for now.
gFFI.chatModel.onVoiceCallClosed("End connetion");
if (isAndroid) {
_textController.removeListener(textAndroidListener);
}
}

// This listener is used to handle the composing region changes for Android soft keyboard input.
void textAndroidListener() {
if (_lastComposingChangeValid) {
_handleNonIOSSoftKeyboardInput(_textController.text);
}
}

// to-do: It should be better to use transparent color instead of the bgColor.
Expand All @@ -150,7 +160,6 @@ class _RemotePageState extends State<RemotePage> {
gFFI.ffiModel.pi.version.isNotEmpty) {
gFFI.invokeMethod("enable_soft_keyboard", false);
}
_composingTimer?.cancel();
} else {
_timer?.cancel();
_timer = Timer(kMobileDelaySoftKeyboardFocus, () {
Expand Down Expand Up @@ -214,11 +223,8 @@ class _RemotePageState extends State<RemotePage> {
}

void _handleNonIOSSoftKeyboardInput(String newValue) {
_composingTimer?.cancel();
if (_textController.value.isComposingRangeValid) {
_composingTimer = Timer(Duration(milliseconds: 25), () {
_handleNonIOSSoftKeyboardInput(_textController.value.text);
});
_lastComposingChangeValid = _textController.value.isComposingRangeValid;
if (_lastComposingChangeValid) {
return;
}
var oldValue = _value;
Expand Down
20 changes: 19 additions & 1 deletion flutter/lib/models/input_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,25 @@ class InputModel {
handleKeyDownEventModifiers(e);
}

if (isMobile || (isDesktop || isWebDesktop) && keyboardMode == kKeyMapMode) {
// The physicalKey.usbHidUsage may be not correct for soft keyboard on Android.
// iOS does not have this issue.
// 1. Open the soft keyboard on Android
// 2. Switch to input method like zh/ko/ja
// 3. Click Backspace and Enter on the soft keyboard or physical keyboard
// 4. The physicalKey.usbHidUsage is not correct.
// PhysicalKeyboardKey#8ac83(usbHidUsage: "0x1100000042", debugName: "Key with ID 0x1100000042")
// LogicalKeyboardKey#2604c(keyId: "0x10000000d", keyLabel: "Enter", debugName: "Enter")
//
// The correct PhysicalKeyboardKey should be
// PhysicalKeyboardKey#e14a9(usbHidUsage: "0x00070028", debugName: "Enter")
// https://github.com/flutter/flutter/issues/157771
final isKeyMatch =
isIOS || isAndroid && e.logicalKey.debugName == e.physicalKey.debugName;
final isMobileAndPeerNotAndroid =
isMobile && peerPlatform != kPeerPlatformAndroid;
final isDesktopAndMapMode =
isDesktop || isWebDesktop && keyboardMode == kKeyMapMode;
if (isKeyMatch && (isMobileAndPeerNotAndroid || isDesktopAndMapMode)) {
// FIXME: e.character is wrong for dead keys, eg: ^ in de
newKeyboardMode(
e.character ?? '',
Expand Down
2 changes: 1 addition & 1 deletion src/lang/cn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("id_change_tip", "只可以使用字母 a-z, A-Z, 0-9, _ (下划线)。首字母必须是 a-z, A-Z。长度在 6 与 16 之间。"),
("Website", "网站"),
("About", "关于"),
("Slogan_tip", ""),
("Slogan_tip", "在这个混乱的世界中,用心制作!"),
("Privacy Statement", "隐私声明"),
("Mute", "静音"),
("Build Date", "构建日期"),
Expand Down
Loading

0 comments on commit 31dbbdc

Please sign in to comment.