mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -959,7 +959,6 @@ class CustomAlertDialog extends StatelessWidget {
|
||||
void msgBox(SessionID sessionId, String type, String title, String text,
|
||||
String link, OverlayDialogManager dialogManager,
|
||||
{bool? hasCancel, ReconnectHandle? reconnect, int? reconnectTimeout}) {
|
||||
|
||||
dialogManager.dismissAll();
|
||||
List<Widget> buttons = [];
|
||||
bool hasOk = false;
|
||||
@@ -2766,6 +2765,8 @@ parseParamScreenRect(Map<String, dynamic> params) {
|
||||
return screenRect;
|
||||
}
|
||||
|
||||
get isInputSourceFlutter => stateGlobal.getInputSource() == "Input source 2";
|
||||
|
||||
class _ReconnectCountDownButton extends StatefulWidget {
|
||||
_ReconnectCountDownButton({
|
||||
Key? key,
|
||||
|
||||
@@ -45,6 +45,7 @@ const String kAppTypeDesktopPortForward = "port forward";
|
||||
const String kWindowMainWindowOnTop = "main_window_on_top";
|
||||
const String kWindowGetWindowInfo = "get_window_info";
|
||||
const String kWindowGetScreenList = "get_screen_list";
|
||||
// This method is not used, maybe it can be removed.
|
||||
const String kWindowDisableGrabKeyboard = "disable_grab_keyboard";
|
||||
const String kWindowActionRebuild = "rebuild";
|
||||
const String kWindowEventHide = "hide";
|
||||
@@ -68,6 +69,8 @@ const String kOptionOpenInTabs = "allow-open-in-tabs";
|
||||
const String kOptionOpenInWindows = "allow-open-in-windows";
|
||||
const String kOptionForceAlwaysRelay = "force-always-relay";
|
||||
|
||||
const String kOptionInputSource = "input-source";
|
||||
|
||||
const String kUniLinksPrefix = "rustdesk://";
|
||||
const String kUrlActionClose = "close";
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
),
|
||||
));
|
||||
} else if (call.method == kWindowDisableGrabKeyboard) {
|
||||
stateGlobal.grabKeyboard = false;
|
||||
// ???
|
||||
} else if (call.method == "onDestroy") {
|
||||
tabController.clear();
|
||||
} else if (call.method == kWindowActionRebuild) {
|
||||
|
||||
@@ -12,9 +12,8 @@ class DesktopRemoteScreen extends StatelessWidget {
|
||||
final Map<String, dynamic> params;
|
||||
|
||||
DesktopRemoteScreen({Key? key, required this.params}) : super(key: key) {
|
||||
if (!bind.mainStartGrabKeyboard()) {
|
||||
stateGlobal.grabKeyboard = true;
|
||||
}
|
||||
bind.mainInitInputSource();
|
||||
stateGlobal.getInputSource(force: true);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1585,7 +1585,7 @@ class _KeyboardMenu extends StatelessWidget {
|
||||
// If use flutter to grab keys, we can only use one mode.
|
||||
// Map mode and Legacy mode, at least one of them is supported.
|
||||
String? modeOnly;
|
||||
if (stateGlobal.grabKeyboard) {
|
||||
if (isInputSourceFlutter) {
|
||||
if (bind.sessionIsKeyboardModeSupported(
|
||||
sessionId: ffi.sessionId, mode: kKeyMapMode)) {
|
||||
modeOnly = kKeyMapMode;
|
||||
@@ -1604,6 +1604,8 @@ class _KeyboardMenu extends StatelessWidget {
|
||||
keyboardMode(modeOnly),
|
||||
localKeyboardType(),
|
||||
Divider(),
|
||||
inputSource(),
|
||||
Divider(),
|
||||
viewMode(),
|
||||
Divider(),
|
||||
reverseMouseWheel(),
|
||||
@@ -1678,6 +1680,39 @@ class _KeyboardMenu extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
inputSource() {
|
||||
final supportedInputSource = bind.mainSupportedInputSource();
|
||||
if (supportedInputSource.isEmpty) return Offstage();
|
||||
late final List<dynamic> supportedInputSourceList;
|
||||
try {
|
||||
supportedInputSourceList = jsonDecode(supportedInputSource);
|
||||
} catch (e) {
|
||||
debugPrint('Failed to decode $supportedInputSource, $e');
|
||||
return;
|
||||
}
|
||||
if (supportedInputSourceList.length < 2) return Offstage();
|
||||
final inputSource = stateGlobal.getInputSource();
|
||||
final enabled = !ffi.ffiModel.viewOnly;
|
||||
return Column(
|
||||
children: supportedInputSourceList.map((e) {
|
||||
final d = e as List<dynamic>;
|
||||
return RdoMenuButton<String>(
|
||||
child: Text(translate(d[1] as String)),
|
||||
value: d[0] as String,
|
||||
groupValue: inputSource,
|
||||
onChanged: enabled
|
||||
? (e) {
|
||||
if (e != null) {
|
||||
stateGlobal.setInputSource(e);
|
||||
}
|
||||
}
|
||||
: null,
|
||||
ffi: ffi,
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
viewMode() {
|
||||
final ffiModel = ffi.ffiModel;
|
||||
final enabled = versionCmp(pi.version, '1.2.0') >= 0 && ffiModel.keyboard;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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._();
|
||||
|
||||
Reference in New Issue
Block a user