mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge pull request #1285 from Heap-Hop/flutter_desktop
Update flutter_desktop smalls
This commit is contained in:
commit
f89777fa92
@ -92,7 +92,7 @@ typedef DialogBuilder = CustomAlertDialog Function(
|
|||||||
|
|
||||||
class Dialog<T> {
|
class Dialog<T> {
|
||||||
OverlayEntry? entry;
|
OverlayEntry? entry;
|
||||||
Completer<T?> completer = Completer<T>();
|
Completer<T?> completer = Completer<T?>();
|
||||||
|
|
||||||
Dialog();
|
Dialog();
|
||||||
|
|
||||||
@ -101,9 +101,10 @@ class Dialog<T> {
|
|||||||
if (!completer.isCompleted) {
|
if (!completer.isCompleted) {
|
||||||
completer.complete(res);
|
completer.complete(res);
|
||||||
}
|
}
|
||||||
entry?.remove();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint("Dialog complete catch error: $e");
|
debugPrint("Dialog complete catch error: $e");
|
||||||
|
} finally {
|
||||||
|
entry?.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +201,6 @@ class OverlayDialogManager {
|
|||||||
VoidCallback? onCancel}) {
|
VoidCallback? onCancel}) {
|
||||||
show((setState, close) => CustomAlertDialog(
|
show((setState, close) => CustomAlertDialog(
|
||||||
content: Container(
|
content: Container(
|
||||||
color: MyTheme.white,
|
|
||||||
constraints: BoxConstraints(maxWidth: 240),
|
constraints: BoxConstraints(maxWidth: 240),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@ -480,7 +480,8 @@ RadioListTile<T> getRadio<T>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
CheckboxListTile getToggle(
|
CheckboxListTile getToggle(
|
||||||
String id, void Function(void Function()) setState, option, name) {
|
String id, void Function(void Function()) setState, option, name,
|
||||||
|
{FFI? ffi}) {
|
||||||
final opt = bind.getSessionToggleOptionSync(id: id, arg: option);
|
final opt = bind.getSessionToggleOptionSync(id: id, arg: option);
|
||||||
return CheckboxListTile(
|
return CheckboxListTile(
|
||||||
value: opt,
|
value: opt,
|
||||||
@ -489,7 +490,7 @@ CheckboxListTile getToggle(
|
|||||||
bind.sessionToggleOption(id: id, value: option);
|
bind.sessionToggleOption(id: id, value: option);
|
||||||
});
|
});
|
||||||
if (option == "show-quality-monitor") {
|
if (option == "show-quality-monitor") {
|
||||||
gFFI.qualityMonitorModel.checkShowQualityMonitor(id);
|
(ffi ?? gFFI).qualityMonitorModel.checkShowQualityMonitor(id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dense: true,
|
dense: true,
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import 'dart:ui' as ui;
|
|||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_hbb/mobile/widgets/gesture_help.dart';
|
|
||||||
import 'package:flutter_hbb/models/chat_model.dart';
|
import 'package:flutter_hbb/models/chat_model.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@ -34,20 +33,13 @@ class RemotePage extends StatefulWidget {
|
|||||||
|
|
||||||
class _RemotePageState extends State<RemotePage>
|
class _RemotePageState extends State<RemotePage>
|
||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin {
|
||||||
Timer? _interval;
|
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
bool _showBar = !isWebDesktop;
|
bool _showBar = !isWebDesktop;
|
||||||
double _bottom = 0;
|
|
||||||
String _value = '';
|
String _value = '';
|
||||||
double _scale = 1;
|
|
||||||
double _mouseScrollIntegral = 0; // mouse scroll speed controller
|
|
||||||
var _cursorOverImage = false.obs;
|
var _cursorOverImage = false.obs;
|
||||||
|
|
||||||
var _more = true;
|
|
||||||
var _fn = false;
|
|
||||||
final FocusNode _mobileFocusNode = FocusNode();
|
final FocusNode _mobileFocusNode = FocusNode();
|
||||||
final FocusNode _physicalFocusNode = FocusNode();
|
final FocusNode _physicalFocusNode = FocusNode();
|
||||||
var _showEdit = false; // use soft keyboard
|
|
||||||
var _isPhysicalMouse = false;
|
var _isPhysicalMouse = false;
|
||||||
|
|
||||||
late FFI _ffi;
|
late FFI _ffi;
|
||||||
@ -63,8 +55,6 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||||
_ffi.dialogManager
|
_ffi.dialogManager
|
||||||
.showLoading(translate('Connecting...'), onCancel: backToHomePage);
|
.showLoading(translate('Connecting...'), onCancel: backToHomePage);
|
||||||
_interval =
|
|
||||||
Timer.periodic(Duration(milliseconds: 30), (timer) => interval());
|
|
||||||
});
|
});
|
||||||
if (!Platform.isLinux) {
|
if (!Platform.isLinux) {
|
||||||
Wakelock.enable();
|
Wakelock.enable();
|
||||||
@ -72,6 +62,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
_physicalFocusNode.requestFocus();
|
_physicalFocusNode.requestFocus();
|
||||||
_ffi.ffiModel.updateEventListener(widget.id);
|
_ffi.ffiModel.updateEventListener(widget.id);
|
||||||
_ffi.listenToMouse(true);
|
_ffi.listenToMouse(true);
|
||||||
|
_ffi.qualityMonitorModel.checkShowQualityMonitor(widget.id);
|
||||||
// WindowManager.instance.addListener(this);
|
// WindowManager.instance.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,11 +71,9 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
print("REMOTE PAGE dispose ${widget.id}");
|
print("REMOTE PAGE dispose ${widget.id}");
|
||||||
hideMobileActionsOverlay();
|
hideMobileActionsOverlay();
|
||||||
_ffi.listenToMouse(false);
|
_ffi.listenToMouse(false);
|
||||||
_ffi.invokeMethod("enable_soft_keyboard", true);
|
|
||||||
_mobileFocusNode.dispose();
|
_mobileFocusNode.dispose();
|
||||||
_physicalFocusNode.dispose();
|
_physicalFocusNode.dispose();
|
||||||
_ffi.close();
|
_ffi.close();
|
||||||
_interval?.cancel();
|
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
_ffi.dialogManager.dismissAll();
|
_ffi.dialogManager.dismissAll();
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
||||||
@ -101,31 +90,6 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
_ffi.resetModifiers();
|
_ffi.resetModifiers();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isKeyboardShown() {
|
|
||||||
return _bottom >= 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
// crash on web before widget initiated.
|
|
||||||
void intervalUnsafe() {
|
|
||||||
var v = MediaQuery.of(context).viewInsets.bottom;
|
|
||||||
if (v != _bottom) {
|
|
||||||
resetTool();
|
|
||||||
setState(() {
|
|
||||||
_bottom = v;
|
|
||||||
if (v < 100) {
|
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
|
||||||
overlays: []);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void interval() {
|
|
||||||
try {
|
|
||||||
intervalUnsafe();
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle mobile virtual keyboard
|
// handle mobile virtual keyboard
|
||||||
void handleInput(String newValue) {
|
void handleInput(String newValue) {
|
||||||
var oldValue = _value;
|
var oldValue = _value;
|
||||||
@ -185,7 +149,6 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
content == '【】')) {
|
content == '【】')) {
|
||||||
// can not only input content[0], because when input ], [ are also auo insert, which cause ] never be input
|
// can not only input content[0], because when input ], [ are also auo insert, which cause ] never be input
|
||||||
bind.sessionInputString(id: widget.id, value: content);
|
bind.sessionInputString(id: widget.id, value: content);
|
||||||
openKeyboard();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bind.sessionInputString(id: widget.id, value: content);
|
bind.sessionInputString(id: widget.id, value: content);
|
||||||
@ -204,25 +167,6 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
_ffi.inputKey(char);
|
_ffi.inputKey(char);
|
||||||
}
|
}
|
||||||
|
|
||||||
void openKeyboard() {
|
|
||||||
_ffi.invokeMethod("enable_soft_keyboard", true);
|
|
||||||
// destroy first, so that our _value trick can work
|
|
||||||
_value = initText;
|
|
||||||
setState(() => _showEdit = false);
|
|
||||||
_timer?.cancel();
|
|
||||||
_timer = Timer(Duration(milliseconds: 30), () {
|
|
||||||
// show now, and sleep a while to requestFocus to
|
|
||||||
// make sure edit ready, so that keyboard wont show/hide/show/hide happen
|
|
||||||
setState(() => _showEdit = true);
|
|
||||||
_timer?.cancel();
|
|
||||||
_timer = Timer(Duration(milliseconds: 30), () {
|
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
|
||||||
overlays: SystemUiOverlay.values);
|
|
||||||
_mobileFocusNode.requestFocus();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendRawKey(RawKeyEvent e, {bool? down, bool? press}) {
|
void sendRawKey(RawKeyEvent e, {bool? down, bool? press}) {
|
||||||
// for maximum compatibility
|
// for maximum compatibility
|
||||||
final label = _logicalKeyMap[e.logicalKey.keyId] ??
|
final label = _logicalKeyMap[e.logicalKey.keyId] ??
|
||||||
@ -233,28 +177,18 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
|
|
||||||
Widget buildBody(FfiModel ffiModel) {
|
Widget buildBody(FfiModel ffiModel) {
|
||||||
final hasDisplays = ffiModel.pi.displays.length > 0;
|
final hasDisplays = ffiModel.pi.displays.length > 0;
|
||||||
final hideKeyboard = isKeyboardShown() && _showEdit;
|
|
||||||
final showActionButton = !_showBar || hideKeyboard;
|
|
||||||
final keyboard = ffiModel.permissions['keyboard'] != false;
|
final keyboard = ffiModel.permissions['keyboard'] != false;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
// resizeToAvoidBottomInset: true,
|
// resizeToAvoidBottomInset: true,
|
||||||
floatingActionButton: !showActionButton
|
floatingActionButton: _showBar
|
||||||
? null
|
? null
|
||||||
: FloatingActionButton(
|
: FloatingActionButton(
|
||||||
mini: !hideKeyboard,
|
mini: true,
|
||||||
child:
|
child: Icon(Icons.expand_less),
|
||||||
Icon(hideKeyboard ? Icons.expand_more : Icons.expand_less),
|
|
||||||
backgroundColor: MyTheme.accent,
|
backgroundColor: MyTheme.accent,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (hideKeyboard) {
|
|
||||||
_showEdit = false;
|
|
||||||
_ffi.invokeMethod("enable_soft_keyboard", false);
|
|
||||||
_mobileFocusNode.unfocus();
|
|
||||||
_physicalFocusNode.requestFocus();
|
|
||||||
} else {
|
|
||||||
_showBar = !_showBar;
|
_showBar = !_showBar;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
bottomNavigationBar:
|
bottomNavigationBar:
|
||||||
@ -322,8 +256,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
sendRawKey(e, down: true);
|
sendRawKey(e, down: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// [!_showEdit] workaround for soft-keyboard's control_key like Backspace / Enter
|
if (e is RawKeyUpEvent) {
|
||||||
if (!_showEdit && e is RawKeyUpEvent) {
|
|
||||||
if (key == LogicalKeyboardKey.altLeft ||
|
if (key == LogicalKeyboardKey.altLeft ||
|
||||||
key == LogicalKeyboardKey.altRight) {
|
key == LogicalKeyboardKey.altRight) {
|
||||||
_ffi.alt = false;
|
_ffi.alt = false;
|
||||||
@ -369,8 +302,8 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
icon: Icon(Icons.tv),
|
icon: Icon(Icons.tv),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() => _showEdit = false);
|
_ffi.dialogManager.dismissAll();
|
||||||
showOptions(widget.id, _ffi.dialogManager);
|
showOptions(widget.id);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
] +
|
] +
|
||||||
@ -390,19 +323,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
: [
|
: []) +
|
||||||
IconButton(
|
|
||||||
color: Colors.white,
|
|
||||||
icon: Icon(Icons.keyboard),
|
|
||||||
onPressed: openKeyboard),
|
|
||||||
IconButton(
|
|
||||||
color: Colors.white,
|
|
||||||
icon: Icon(_ffi.ffiModel.touchMode
|
|
||||||
? Icons.touch_app
|
|
||||||
: Icons.mouse),
|
|
||||||
onPressed: changeTouchMode,
|
|
||||||
),
|
|
||||||
]) +
|
|
||||||
(isWeb
|
(isWeb
|
||||||
? []
|
? []
|
||||||
: <Widget>[
|
: <Widget>[
|
||||||
@ -421,7 +342,6 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
icon: Icon(Icons.more_vert),
|
icon: Icon(Icons.more_vert),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() => _showEdit = false);
|
|
||||||
showActions(widget.id, ffiModel);
|
showActions(widget.id, ffiModel);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -548,7 +468,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
id: widget.id,
|
id: widget.id,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
paints.add(getHelpTools());
|
paints.add(QualityMonitor(_ffi.qualityMonitorModel));
|
||||||
return Stack(
|
return Stack(
|
||||||
children: paints,
|
children: paints,
|
||||||
);
|
);
|
||||||
@ -589,11 +509,10 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
more.add(PopupMenuItem<String>(
|
more.add(PopupMenuItem<String>(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: ([
|
children: ([
|
||||||
Container(width: 100.0, child: Text(translate('OS Password'))),
|
Text(translate('OS Password')),
|
||||||
TextButton(
|
TextButton(
|
||||||
style: flatButtonStyle,
|
style: flatButtonStyle,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
|
||||||
showSetOSPassword(widget.id, false, _ffi.dialogManager);
|
showSetOSPassword(widget.id, false, _ffi.dialogManager);
|
||||||
},
|
},
|
||||||
child: Icon(Icons.edit, color: MyTheme.accent),
|
child: Icon(Icons.edit, color: MyTheme.accent),
|
||||||
@ -625,6 +544,13 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
value: 'block-input'));
|
value: 'block-input'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (gFFI.ffiModel.permissions["restart"] != false &&
|
||||||
|
(pi.platform == "Linux" ||
|
||||||
|
pi.platform == "Windows" ||
|
||||||
|
pi.platform == "Mac OS")) {
|
||||||
|
more.add(PopupMenuItem<String>(
|
||||||
|
child: Text(translate('Restart Remote Device')), value: 'restart'));
|
||||||
|
}
|
||||||
() async {
|
() async {
|
||||||
var value = await showMenu(
|
var value = await showMenu(
|
||||||
context: context,
|
context: context,
|
||||||
@ -652,6 +578,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
}();
|
}();
|
||||||
} else if (value == 'enter_os_password') {
|
} else if (value == 'enter_os_password') {
|
||||||
// FIXME:
|
// FIXME:
|
||||||
|
// TODO icon diff
|
||||||
// null means no session of id
|
// null means no session of id
|
||||||
// empty string means no password
|
// empty string means no password
|
||||||
var password = await bind.getSessionOption(id: id, arg: "os-password");
|
var password = await bind.getSessionOption(id: id, arg: "os-password");
|
||||||
@ -662,169 +589,12 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
}
|
}
|
||||||
} else if (value == 'reset_canvas') {
|
} else if (value == 'reset_canvas') {
|
||||||
_ffi.cursorModel.reset();
|
_ffi.cursorModel.reset();
|
||||||
|
} else if (value == 'restart') {
|
||||||
|
showRestartRemoteDevice(pi, widget.id, gFFI.dialogManager);
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeTouchMode() {
|
|
||||||
setState(() => _showEdit = false);
|
|
||||||
showModalBottomSheet(
|
|
||||||
backgroundColor: MyTheme.grayBg,
|
|
||||||
isScrollControlled: true,
|
|
||||||
context: context,
|
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(5))),
|
|
||||||
builder: (context) => DraggableScrollableSheet(
|
|
||||||
expand: false,
|
|
||||||
builder: (context, scrollController) {
|
|
||||||
return SingleChildScrollView(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 10),
|
|
||||||
child: GestureHelp(
|
|
||||||
touchMode: _ffi.ffiModel.touchMode,
|
|
||||||
onTouchModeChange: (t) {
|
|
||||||
_ffi.ffiModel.toggleTouchMode();
|
|
||||||
final v = _ffi.ffiModel.touchMode ? 'Y' : '';
|
|
||||||
bind.sessionPeerOption(
|
|
||||||
id: widget.id, name: "touch-mode", value: v);
|
|
||||||
}));
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget getHelpTools() {
|
|
||||||
final keyboard = isKeyboardShown();
|
|
||||||
if (!keyboard) {
|
|
||||||
return SizedBox();
|
|
||||||
}
|
|
||||||
var wrap = (String text, void Function() onPressed,
|
|
||||||
[bool? active, IconData? icon]) {
|
|
||||||
return TextButton(
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
minimumSize: Size(0, 0),
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 9.75),
|
|
||||||
//adds padding inside the button
|
|
||||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
||||||
//limits the touch area to the button area
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(5.0),
|
|
||||||
),
|
|
||||||
backgroundColor: active == true ? MyTheme.accent80 : null,
|
|
||||||
),
|
|
||||||
child: icon != null
|
|
||||||
? Icon(icon, size: 17, color: Colors.white)
|
|
||||||
: Text(translate(text),
|
|
||||||
style: TextStyle(color: Colors.white, fontSize: 11)),
|
|
||||||
onPressed: onPressed);
|
|
||||||
};
|
|
||||||
final pi = _ffi.ffiModel.pi;
|
|
||||||
final isMac = pi.platform == "Mac OS";
|
|
||||||
final modifiers = <Widget>[
|
|
||||||
wrap('Ctrl ', () {
|
|
||||||
setState(() => _ffi.ctrl = !_ffi.ctrl);
|
|
||||||
}, _ffi.ctrl),
|
|
||||||
wrap(' Alt ', () {
|
|
||||||
setState(() => _ffi.alt = !_ffi.alt);
|
|
||||||
}, _ffi.alt),
|
|
||||||
wrap('Shift', () {
|
|
||||||
setState(() => _ffi.shift = !_ffi.shift);
|
|
||||||
}, _ffi.shift),
|
|
||||||
wrap(isMac ? ' Cmd ' : ' Win ', () {
|
|
||||||
setState(() => _ffi.command = !_ffi.command);
|
|
||||||
}, _ffi.command),
|
|
||||||
];
|
|
||||||
final keys = <Widget>[
|
|
||||||
wrap(
|
|
||||||
' Fn ',
|
|
||||||
() => setState(
|
|
||||||
() {
|
|
||||||
_fn = !_fn;
|
|
||||||
if (_fn) {
|
|
||||||
_more = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
_fn),
|
|
||||||
wrap(
|
|
||||||
' ... ',
|
|
||||||
() => setState(
|
|
||||||
() {
|
|
||||||
_more = !_more;
|
|
||||||
if (_more) {
|
|
||||||
_fn = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
_more),
|
|
||||||
];
|
|
||||||
final fn = <Widget>[
|
|
||||||
SizedBox(width: 9999),
|
|
||||||
];
|
|
||||||
for (var i = 1; i <= 12; ++i) {
|
|
||||||
final name = 'F' + i.toString();
|
|
||||||
fn.add(wrap(name, () {
|
|
||||||
_ffi.inputKey('VK_' + name);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
final more = <Widget>[
|
|
||||||
SizedBox(width: 9999),
|
|
||||||
wrap('Esc', () {
|
|
||||||
_ffi.inputKey('VK_ESCAPE');
|
|
||||||
}),
|
|
||||||
wrap('Tab', () {
|
|
||||||
_ffi.inputKey('VK_TAB');
|
|
||||||
}),
|
|
||||||
wrap('Home', () {
|
|
||||||
_ffi.inputKey('VK_HOME');
|
|
||||||
}),
|
|
||||||
wrap('End', () {
|
|
||||||
_ffi.inputKey('VK_END');
|
|
||||||
}),
|
|
||||||
wrap('Del', () {
|
|
||||||
_ffi.inputKey('VK_DELETE');
|
|
||||||
}),
|
|
||||||
wrap('PgUp', () {
|
|
||||||
_ffi.inputKey('VK_PRIOR');
|
|
||||||
}),
|
|
||||||
wrap('PgDn', () {
|
|
||||||
_ffi.inputKey('VK_NEXT');
|
|
||||||
}),
|
|
||||||
SizedBox(width: 9999),
|
|
||||||
wrap('', () {
|
|
||||||
_ffi.inputKey('VK_LEFT');
|
|
||||||
}, false, Icons.keyboard_arrow_left),
|
|
||||||
wrap('', () {
|
|
||||||
_ffi.inputKey('VK_UP');
|
|
||||||
}, false, Icons.keyboard_arrow_up),
|
|
||||||
wrap('', () {
|
|
||||||
_ffi.inputKey('VK_DOWN');
|
|
||||||
}, false, Icons.keyboard_arrow_down),
|
|
||||||
wrap('', () {
|
|
||||||
_ffi.inputKey('VK_RIGHT');
|
|
||||||
}, false, Icons.keyboard_arrow_right),
|
|
||||||
wrap(isMac ? 'Cmd+C' : 'Ctrl+C', () {
|
|
||||||
sendPrompt(widget.id, isMac, 'VK_C');
|
|
||||||
}),
|
|
||||||
wrap(isMac ? 'Cmd+V' : 'Ctrl+V', () {
|
|
||||||
sendPrompt(widget.id, isMac, 'VK_V');
|
|
||||||
}),
|
|
||||||
wrap(isMac ? 'Cmd+S' : 'Ctrl+S', () {
|
|
||||||
sendPrompt(widget.id, isMac, 'VK_S');
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
final space = MediaQuery.of(context).size.width > 320 ? 4.0 : 2.0;
|
|
||||||
return Container(
|
|
||||||
color: Color(0xAA000000),
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: keyboard ? 24 : 4, left: 0, right: 0, bottom: 8),
|
|
||||||
child: Wrap(
|
|
||||||
spacing: space,
|
|
||||||
runSpacing: space,
|
|
||||||
children: <Widget>[SizedBox(width: 9999)] +
|
|
||||||
(keyboard
|
|
||||||
? modifiers + keys + (_fn ? fn : []) + (_more ? more : [])
|
|
||||||
: modifiers),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onWindowEvent(String eventName) {
|
void onWindowEvent(String eventName) {
|
||||||
print("window event: $eventName");
|
print("window event: $eventName");
|
||||||
@ -992,7 +762,52 @@ class ImagePainter extends CustomPainter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void showOptions(String id, OverlayDialogManager dialogManager) async {
|
class QualityMonitor extends StatelessWidget {
|
||||||
|
final QualityMonitorModel qualityMonitorModel;
|
||||||
|
QualityMonitor(this.qualityMonitorModel);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => ChangeNotifierProvider.value(
|
||||||
|
value: qualityMonitorModel,
|
||||||
|
child: Consumer<QualityMonitorModel>(
|
||||||
|
builder: (context, qualityMonitorModel, child) => Positioned(
|
||||||
|
top: 10,
|
||||||
|
right: 10,
|
||||||
|
child: qualityMonitorModel.show
|
||||||
|
? Container(
|
||||||
|
padding: EdgeInsets.all(8),
|
||||||
|
color: MyTheme.canvasColor.withAlpha(120),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Speed: ${qualityMonitorModel.data.speed ?? ''}",
|
||||||
|
style: TextStyle(color: MyTheme.grayBg),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"FPS: ${qualityMonitorModel.data.fps ?? ''}",
|
||||||
|
style: TextStyle(color: MyTheme.grayBg),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"Delay: ${qualityMonitorModel.data.delay ?? ''} ms",
|
||||||
|
style: TextStyle(color: MyTheme.grayBg),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"Target Bitrate: ${qualityMonitorModel.data.targetBitrate ?? ''}kb",
|
||||||
|
style: TextStyle(color: MyTheme.grayBg),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"Codec: ${qualityMonitorModel.data.codecFormat ?? ''}",
|
||||||
|
style: TextStyle(color: MyTheme.grayBg),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: SizedBox.shrink())));
|
||||||
|
}
|
||||||
|
|
||||||
|
void showOptions(String id) async {
|
||||||
|
final _ffi = ffi(id);
|
||||||
String quality = await bind.getSessionImageQuality(id: id) ?? 'balanced';
|
String quality = await bind.getSessionImageQuality(id: id) ?? 'balanced';
|
||||||
if (quality == '') quality = 'balanced';
|
if (quality == '') quality = 'balanced';
|
||||||
String viewStyle =
|
String viewStyle =
|
||||||
@ -1000,8 +815,8 @@ void showOptions(String id, OverlayDialogManager dialogManager) async {
|
|||||||
String scrollStyle =
|
String scrollStyle =
|
||||||
await bind.getSessionOption(id: id, arg: 'scroll-style') ?? '';
|
await bind.getSessionOption(id: id, arg: 'scroll-style') ?? '';
|
||||||
var displays = <Widget>[];
|
var displays = <Widget>[];
|
||||||
final pi = ffi(id).ffiModel.pi;
|
final pi = _ffi.ffiModel.pi;
|
||||||
final image = ffi(id).ffiModel.getConnectionImage();
|
final image = _ffi.ffiModel.getConnectionImage();
|
||||||
if (image != null)
|
if (image != null)
|
||||||
displays.add(Padding(padding: const EdgeInsets.only(top: 8), child: image));
|
displays.add(Padding(padding: const EdgeInsets.only(top: 8), child: image));
|
||||||
if (pi.displays.length > 1) {
|
if (pi.displays.length > 1) {
|
||||||
@ -1012,7 +827,7 @@ void showOptions(String id, OverlayDialogManager dialogManager) async {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
if (i == cur) return;
|
if (i == cur) return;
|
||||||
bind.sessionSwitchDisplay(id: id, value: i);
|
bind.sessionSwitchDisplay(id: id, value: i);
|
||||||
dialogManager.dismissAll();
|
_ffi.dialogManager.dismissAll();
|
||||||
},
|
},
|
||||||
child: Ink(
|
child: Ink(
|
||||||
width: 40,
|
width: 40,
|
||||||
@ -1035,9 +850,9 @@ void showOptions(String id, OverlayDialogManager dialogManager) async {
|
|||||||
if (displays.isNotEmpty) {
|
if (displays.isNotEmpty) {
|
||||||
displays.add(Divider(color: MyTheme.border));
|
displays.add(Divider(color: MyTheme.border));
|
||||||
}
|
}
|
||||||
final perms = ffi(id).ffiModel.permissions;
|
final perms = _ffi.ffiModel.permissions;
|
||||||
|
|
||||||
dialogManager.show((setState, close) {
|
_ffi.dialogManager.show((setState, close) {
|
||||||
final more = <Widget>[];
|
final more = <Widget>[];
|
||||||
if (perms['audio'] != false) {
|
if (perms['audio'] != false) {
|
||||||
more.add(getToggle(id, setState, 'disable-audio', 'Mute'));
|
more.add(getToggle(id, setState, 'disable-audio', 'Mute'));
|
||||||
@ -1068,7 +883,7 @@ void showOptions(String id, OverlayDialogManager dialogManager) async {
|
|||||||
setState(() {
|
setState(() {
|
||||||
viewStyle = value;
|
viewStyle = value;
|
||||||
bind.sessionPeerOption(id: id, name: "view-style", value: value);
|
bind.sessionPeerOption(id: id, name: "view-style", value: value);
|
||||||
ffi(id).canvasModel.updateViewStyle();
|
_ffi.canvasModel.updateViewStyle();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var setScrollStyle = (String? value) {
|
var setScrollStyle = (String? value) {
|
||||||
@ -1076,7 +891,7 @@ void showOptions(String id, OverlayDialogManager dialogManager) async {
|
|||||||
setState(() {
|
setState(() {
|
||||||
scrollStyle = value;
|
scrollStyle = value;
|
||||||
bind.sessionPeerOption(id: id, name: "scroll-style", value: value);
|
bind.sessionPeerOption(id: id, name: "scroll-style", value: value);
|
||||||
ffi(id).canvasModel.updateScrollStyle();
|
_ffi.canvasModel.updateScrollStyle();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
@ -1099,6 +914,9 @@ void showOptions(String id, OverlayDialogManager dialogManager) async {
|
|||||||
Divider(color: MyTheme.border),
|
Divider(color: MyTheme.border),
|
||||||
getToggle(
|
getToggle(
|
||||||
id, setState, 'show-remote-cursor', 'Show remote cursor'),
|
id, setState, 'show-remote-cursor', 'Show remote cursor'),
|
||||||
|
getToggle(id, setState, 'show-quality-monitor',
|
||||||
|
'Show quality monitor',
|
||||||
|
ffi: _ffi),
|
||||||
] +
|
] +
|
||||||
more),
|
more),
|
||||||
actions: [],
|
actions: [],
|
||||||
|
|||||||
@ -53,7 +53,9 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
border: Border.all(color: Colors.transparent, width: 1.0),
|
border: Border.all(color: Colors.transparent, width: 1.0),
|
||||||
borderRadius: BorderRadius.circular(20));
|
borderRadius: BorderRadius.circular(20));
|
||||||
},
|
},
|
||||||
child: _buildPeerTile(context, peer, deco),
|
child: GestureDetector(
|
||||||
|
onDoubleTap: () => _connect(peer.id),
|
||||||
|
child: _buildPeerTile(context, peer, deco)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
_physicalFocusNode.requestFocus();
|
_physicalFocusNode.requestFocus();
|
||||||
gFFI.ffiModel.updateEventListener(widget.id);
|
gFFI.ffiModel.updateEventListener(widget.id);
|
||||||
gFFI.listenToMouse(true);
|
gFFI.listenToMouse(true);
|
||||||
|
gFFI.qualityMonitorModel.checkShowQualityMonitor(widget.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -670,7 +671,6 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: flatButtonStyle,
|
style: flatButtonStyle,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
|
||||||
showSetOSPassword(id, false, gFFI.dialogManager);
|
showSetOSPassword(id, false, gFFI.dialogManager);
|
||||||
},
|
},
|
||||||
child: Icon(Icons.edit, color: MyTheme.accent),
|
child: Icon(Icons.edit, color: MyTheme.accent),
|
||||||
@ -1110,28 +1110,6 @@ void showOptions(String id, OverlayDialogManager dialogManager) async {
|
|||||||
}, clickMaskDismiss: true, backDismiss: true);
|
}, clickMaskDismiss: true, backDismiss: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showRestartRemoteDevice(
|
|
||||||
PeerInfo pi, String id, OverlayDialogManager dialogManager) async {
|
|
||||||
final res =
|
|
||||||
await dialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
|
||||||
title: Row(children: [
|
|
||||||
Icon(Icons.warning_amber_sharp,
|
|
||||||
color: Colors.redAccent, size: 28),
|
|
||||||
SizedBox(width: 10),
|
|
||||||
Text(translate("Restart Remote Device")),
|
|
||||||
]),
|
|
||||||
content: Text(
|
|
||||||
"${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => close(), child: Text(translate("Cancel"))),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () => close(true), child: Text(translate("OK"))),
|
|
||||||
],
|
|
||||||
));
|
|
||||||
if (res == true) bind.sessionRestartRemoteDevice(id: id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void showSetOSPassword(
|
void showSetOSPassword(
|
||||||
String id, bool login, OverlayDialogManager dialogManager) async {
|
String id, bool login, OverlayDialogManager dialogManager) async {
|
||||||
final controller = TextEditingController();
|
final controller = TextEditingController();
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
|
import '../../models/model.dart';
|
||||||
import '../../models/platform_model.dart';
|
import '../../models/platform_model.dart';
|
||||||
|
|
||||||
void clientClose(OverlayDialogManager dialogManager) {
|
void clientClose(OverlayDialogManager dialogManager) {
|
||||||
@ -16,6 +17,28 @@ void showError() {
|
|||||||
showToast(translate("Error"));
|
showToast(translate("Error"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showRestartRemoteDevice(
|
||||||
|
PeerInfo pi, String id, OverlayDialogManager dialogManager) async {
|
||||||
|
final res =
|
||||||
|
await dialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||||
|
title: Row(children: [
|
||||||
|
Icon(Icons.warning_amber_sharp,
|
||||||
|
color: Colors.redAccent, size: 28),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Text(translate("Restart Remote Device")),
|
||||||
|
]),
|
||||||
|
content: Text(
|
||||||
|
"${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => close(), child: Text(translate("Cancel"))),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () => close(true), child: Text(translate("OK"))),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
if (res == true) bind.sessionRestartRemoteDevice(id: id);
|
||||||
|
}
|
||||||
|
|
||||||
void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
|
void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
|
||||||
final pw = await bind.mainGetPermanentPassword();
|
final pw = await bind.mainGetPermanentPassword();
|
||||||
final p0 = TextEditingController(text: pw);
|
final p0 = TextEditingController(text: pw);
|
||||||
|
|||||||
@ -1050,7 +1050,6 @@ class FFI {
|
|||||||
await for (final message in stream) {
|
await for (final message in stream) {
|
||||||
if (message is Event) {
|
if (message is Event) {
|
||||||
try {
|
try {
|
||||||
debugPrint("event:${message.field0}");
|
|
||||||
Map<String, dynamic> event = json.decode(message.field0);
|
Map<String, dynamic> event = json.decode(message.field0);
|
||||||
cb(event);
|
cb(event);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -31,9 +31,10 @@ use hbb_common::{
|
|||||||
Stream,
|
Stream,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::common::{
|
use crate::common::{self, make_fd_to_json, CLIPBOARD_INTERVAL};
|
||||||
self, check_clipboard, make_fd_to_json, update_clipboard, ClipboardContext, CLIPBOARD_INTERVAL,
|
|
||||||
};
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
use crate::common::{check_clipboard, update_clipboard, ClipboardContext};
|
||||||
|
|
||||||
use crate::{client::*, flutter_ffi::EventToUI, make_fd_flutter};
|
use crate::{client::*, flutter_ffi::EventToUI, make_fd_flutter};
|
||||||
|
|
||||||
@ -127,26 +128,18 @@ impl Session {
|
|||||||
}
|
}
|
||||||
lc.set_option(name, value);
|
lc.set_option(name, value);
|
||||||
}
|
}
|
||||||
// TODO
|
|
||||||
// input_os_password
|
|
||||||
// restart_remote_device
|
|
||||||
|
|
||||||
/// Input the OS password.
|
/// Input the OS password.
|
||||||
pub fn input_os_password(&self, pass: String, activate: bool) {
|
pub fn input_os_password(&self, pass: String, activate: bool) {
|
||||||
input_os_password(pass, activate, self.clone());
|
input_os_password(pass, activate, self.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl Interface
|
pub fn restart_remote_device(&self) {
|
||||||
/// Send message to the remote session.
|
let mut lc = self.lc.write().unwrap();
|
||||||
///
|
lc.restarting_remote_device = true;
|
||||||
/// # Arguments
|
let msg = lc.restart_remote_device();
|
||||||
///
|
self.send_msg(msg);
|
||||||
/// * `data` - The data to send. See [`Data`] for more details.
|
}
|
||||||
// fn send(data: Data) {
|
|
||||||
// if let Some(session) = SESSION.read().unwrap().as_ref() {
|
|
||||||
// session.send(data);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// Toggle an option.
|
/// Toggle an option.
|
||||||
pub fn toggle_option(&self, name: &str) {
|
pub fn toggle_option(&self, name: &str) {
|
||||||
@ -670,6 +663,7 @@ impl Connection {
|
|||||||
lc: Arc<RwLock<LoginConfigHandler>>,
|
lc: Arc<RwLock<LoginConfigHandler>>,
|
||||||
) -> Option<std::sync::mpsc::Sender<()>> {
|
) -> Option<std::sync::mpsc::Sender<()>> {
|
||||||
let (tx, rx) = std::sync::mpsc::channel();
|
let (tx, rx) = std::sync::mpsc::channel();
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
match ClipboardContext::new() {
|
match ClipboardContext::new() {
|
||||||
Ok(mut ctx) => {
|
Ok(mut ctx) => {
|
||||||
let old_clipboard: Arc<Mutex<String>> = Default::default();
|
let old_clipboard: Arc<Mutex<String>> = Default::default();
|
||||||
@ -856,6 +850,7 @@ impl Connection {
|
|||||||
};
|
};
|
||||||
if let Ok(true) = self.video_handler.handle_frame(vf) {
|
if let Ok(true) = self.video_handler.handle_frame(vf) {
|
||||||
let stream = self.session.events2ui.read().unwrap();
|
let stream = self.session.events2ui.read().unwrap();
|
||||||
|
self.frame_count.fetch_add(1, Ordering::Relaxed);
|
||||||
stream.add(EventToUI::Rgba(ZeroCopyBuffer(
|
stream.add(EventToUI::Rgba(ZeroCopyBuffer(
|
||||||
self.video_handler.rgb.clone(),
|
self.video_handler.rgb.clone(),
|
||||||
)));
|
)));
|
||||||
|
|||||||
@ -696,8 +696,9 @@ pub fn session_send_mouse(id: String, msg: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn session_restart_remote_device(id: String) {
|
pub fn session_restart_remote_device(id: String) {
|
||||||
// TODO
|
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||||
// Session::restart_remote_device();
|
session.restart_remote_device();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main_set_home_dir(home: String) {
|
pub fn main_set_home_dir(home: String) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user