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