mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-22 10:03:01 +08:00
refact: web, keyboard, translate mode (#9432)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
f3f3bb538f
commit
f535406962
@ -469,8 +469,12 @@ class InputModel {
|
||||
|
||||
KeyEventResult handleRawKeyEvent(RawKeyEvent e) {
|
||||
if (isViewOnly) return KeyEventResult.handled;
|
||||
if ((isDesktop || isWebDesktop) && !isInputSourceFlutter) {
|
||||
return KeyEventResult.handled;
|
||||
if (!isInputSourceFlutter) {
|
||||
if (isDesktop) {
|
||||
return KeyEventResult.handled;
|
||||
} else if (isWeb) {
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
}
|
||||
|
||||
final key = e.logicalKey;
|
||||
@ -519,8 +523,12 @@ class InputModel {
|
||||
|
||||
KeyEventResult handleKeyEvent(KeyEvent e) {
|
||||
if (isViewOnly) return KeyEventResult.handled;
|
||||
if ((isDesktop || isWebDesktop) && !isInputSourceFlutter) {
|
||||
return KeyEventResult.handled;
|
||||
if (!isInputSourceFlutter) {
|
||||
if (isDesktop) {
|
||||
return KeyEventResult.handled;
|
||||
} else if (isWeb) {
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
}
|
||||
if (isWindows || isLinux) {
|
||||
// Ignore meta keys. Because flutter window will loose focus if meta key is pressed.
|
||||
|
@ -352,7 +352,11 @@ class RustdeskImpl {
|
||||
|
||||
bool sessionIsKeyboardModeSupported(
|
||||
{required UuidValue sessionId, required String mode, dynamic hint}) {
|
||||
return [kKeyLegacyMode, kKeyMapMode].contains(mode);
|
||||
if (mainGetInputSource(hint: hint) == 'Input source 1') {
|
||||
return [kKeyMapMode, kKeyTranslateMode].contains(mode);
|
||||
} else {
|
||||
return [kKeyLegacyMode, kKeyMapMode].contains(mode);
|
||||
}
|
||||
}
|
||||
|
||||
bool sessionIsMultiUiSession({required UuidValue sessionId, dynamic hint}) {
|
||||
@ -429,7 +433,7 @@ class RustdeskImpl {
|
||||
|
||||
void sessionEnterOrLeave(
|
||||
{required UuidValue sessionId, required bool enter, dynamic hint}) {
|
||||
throw UnimplementedError();
|
||||
js.context.callMethod('setByName', ['enter_or_leave', enter]);
|
||||
}
|
||||
|
||||
Future<void> sessionInputKey(
|
||||
@ -846,16 +850,21 @@ class RustdeskImpl {
|
||||
}
|
||||
|
||||
String mainGetInputSource({dynamic hint}) {
|
||||
// // rdev grab mode
|
||||
// const CONFIG_INPUT_SOURCE_1 = "Input source 1";
|
||||
final inputSource =
|
||||
js.context.callMethod('getByName', ['option:local', 'input-source']);
|
||||
// // js grab mode
|
||||
// export const CONFIG_INPUT_SOURCE_1 = "Input source 1";
|
||||
// // flutter grab mode
|
||||
// const CONFIG_INPUT_SOURCE_2 = "Input source 2";
|
||||
return 'Input source 2';
|
||||
// export const CONFIG_INPUT_SOURCE_2 = "Input source 2";
|
||||
return inputSource != '' ? inputSource : 'Input source 1';
|
||||
}
|
||||
|
||||
Future<void> mainSetInputSource(
|
||||
{required UuidValue sessionId, required String value, dynamic hint}) {
|
||||
return Future.value();
|
||||
return Future(() => js.context.callMethod('setByName', [
|
||||
'option:local',
|
||||
jsonEncode({'name': 'input-source', 'value': value})
|
||||
]));
|
||||
}
|
||||
|
||||
Future<String> mainGetMyId({dynamic hint}) {
|
||||
@ -1610,6 +1619,7 @@ class RustdeskImpl {
|
||||
|
||||
String mainSupportedInputSource({dynamic hint}) {
|
||||
return jsonEncode([
|
||||
['Input source 1', 'input_source_1_tip'],
|
||||
['Input source 2', 'input_source_2_tip']
|
||||
]);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
import 'dart:js' as js;
|
||||
import 'dart:html' as html;
|
||||
// cycle imports, maybe we can improve this
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
|
||||
final isAndroid_ = false;
|
||||
final isIOS_ = false;
|
||||
@ -13,8 +15,7 @@ final isDesktop_ = false;
|
||||
|
||||
String get screenInfo_ => js.context.callMethod('getByName', ['screen_info']);
|
||||
|
||||
final _userAgent = html.window.navigator.userAgent.toLowerCase();
|
||||
|
||||
final isWebOnWindows_ = _userAgent.contains('win');
|
||||
final isWebOnLinux_ = _userAgent.contains('linux');
|
||||
final isWebOnMacOS_ = _userAgent.contains('mac');
|
||||
final _localOs = js.context.callMethod('getByName', ['local_os', '']);
|
||||
final isWebOnWindows_ = _localOs == kPeerPlatformWindows;
|
||||
final isWebOnLinux_ = _localOs == kPeerPlatformLinux;
|
||||
final isWebOnMacOS_ = _localOs == kPeerPlatformMacOS;
|
||||
|
Loading…
Reference in New Issue
Block a user