tmp commit

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-11-28 23:57:48 +08:00
parent 19e8ca6c06
commit f11104fcb5
49 changed files with 296 additions and 46 deletions

View File

@@ -13,7 +13,6 @@ import '../../models/model.dart';
import '../../models/platform_model.dart';
import '../common.dart';
import '../consts.dart';
import './state_model.dart';
/// Mouse button enum.
enum MouseButtons { left, right, wheel }
@@ -91,7 +90,7 @@ class InputModel {
}
KeyEventResult handleRawKeyEvent(FocusNode data, RawKeyEvent e) {
if (isDesktop && !stateGlobal.grabKeyboard) {
if (isDesktop && !isInputSourceFlutter) {
return KeyEventResult.handled;
}
@@ -325,7 +324,9 @@ class InputModel {
resetModifiers();
}
_flingTimer?.cancel();
bind.sessionEnterOrLeave(sessionId: sessionId, enter: enter);
if (!isInputSourceFlutter) {
bind.sessionEnterOrLeave(sessionId: sessionId, enter: enter);
}
}
/// Send mouse movement event with distance in [x] and [y].
@@ -396,7 +397,8 @@ class InputModel {
}
if (x != 0 || y != 0) {
if (peerPlatform == kPeerPlatformAndroid) {
handlePointerEvent('touch', 'pan_update', Offset(x.toDouble(), y.toDouble()));
handlePointerEvent(
'touch', 'pan_update', Offset(x.toDouble(), y.toDouble()));
} else {
bind.sessionSendMouse(
sessionId: sessionId,

View File

@@ -744,8 +744,7 @@ class FfiModel with ChangeNotifier {
}
// If current keyboard mode is not supported, change to another one.
if (stateGlobal.grabKeyboard) {
if (isInputSourceFlutter) {
for (final mode in [kKeyMapMode, kKeyLegacyMode]) {
if (bind.sessionIsKeyboardModeSupported(
sessionId: sessionId, mode: mode)) {

View File

@@ -153,10 +153,10 @@ class PlatformFFI {
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
name = '${androidInfo.brand}-${androidInfo.model}';
id = androidInfo.id.hashCode.toString();
androidVersion = androidInfo.version.sdkInt ?? 0;
androidVersion = androidInfo.version.sdkInt;
} else if (Platform.isIOS) {
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
name = iosInfo.utsname.machine ?? '';
name = iosInfo.utsname.machine;
id = iosInfo.identifierForVendor.hashCode.toString();
} else if (Platform.isLinux) {
LinuxDeviceInfo linuxInfo = await deviceInfo.linuxInfo;

View File

@@ -5,12 +5,12 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../consts.dart';
import './platform_model.dart';
enum SvcStatus { notReady, connecting, ready }
class StateGlobal {
int _windowId = -1;
bool grabKeyboard = false;
final RxBool _fullscreen = false.obs;
bool _isMinimized = false;
final RxBool isMaximized = false.obs;
@@ -22,6 +22,8 @@ class StateGlobal {
// Only used for macOS
bool? closeOnFullscreen;
String _inputSource = '';
// Use for desktop -> remote toolbar -> resolution
final Map<String, Map<int, String?>> _lastResolutionGroupValues = {};
@@ -94,6 +96,18 @@ class StateGlobal {
}
}
String getInputSource({bool force = false}) {
if (force || _inputSource.isEmpty) {
_inputSource = bind.mainGetLocalOption(key: kOptionInputSource);
}
return _inputSource;
}
void setInputSource(String v) async {
await bind.mainSetLocalOption(key: kOptionInputSource, value: v);
_inputSource = bind.mainGetLocalOption(key: kOptionInputSource);
}
StateGlobal._();
static final StateGlobal instance = StateGlobal._();