flutter cmd/win for mac/win

This commit is contained in:
rustdesk 2021-08-11 00:22:47 +08:00
parent 0704cc8ee4
commit b4cd94c488

View File

@ -399,6 +399,8 @@ class _RemotePageState extends State<RemotePage> {
}); });
}, _right) }, _right)
]; ];
final pi = FFI.ffiModel.pi;
final isMac = pi.platform == "Mac OS";
final modifiers = <Widget>[ final modifiers = <Widget>[
wrap('Ctrl', () { wrap('Ctrl', () {
setState(() => FFI.ctrl = !FFI.ctrl); setState(() => FFI.ctrl = !FFI.ctrl);
@ -409,7 +411,7 @@ class _RemotePageState extends State<RemotePage> {
wrap('Shift', () { wrap('Shift', () {
setState(() => FFI.shift = !FFI.shift); setState(() => FFI.shift = !FFI.shift);
}, FFI.shift), }, FFI.shift),
wrap('Cmd', () { wrap(isMac ? 'Cmd' : 'Win', () {
setState(() => FFI.command = !FFI.command); setState(() => FFI.command = !FFI.command);
}, FFI.command), }, FFI.command),
]; ];
@ -482,29 +484,14 @@ class _RemotePageState extends State<RemotePage> {
wrap('', () { wrap('', () {
FFI.inputKey('VK_RIGHT'); FFI.inputKey('VK_RIGHT');
}, false, Icons.keyboard_arrow_right), }, false, Icons.keyboard_arrow_right),
wrap('Ctrl+C', () { wrap(isMac ? 'Cmd+C' : 'Ctrl+C', () {
var old = FFI.ctrl; sendPrompt(isMac, 'VK_C');
FFI.ctrl = true;
FFI.inputKey(
'VK_C',
);
FFI.ctrl = old;
}), }),
wrap('Ctrl+V', () { wrap(isMac ? 'Cmd+V' : 'Ctrl+V', () {
var old = FFI.ctrl; sendPrompt(isMac, 'VK_V');
FFI.ctrl = true;
FFI.inputKey(
'VK_V',
);
FFI.ctrl = old;
}), }),
wrap('Ctrl+S', () { wrap(isMac ? 'Cmd+S' : 'Ctrl+S', () {
var old = FFI.ctrl; sendPrompt(isMac, 'VK_S');
FFI.ctrl = true;
FFI.inputKey(
'VK_S',
);
FFI.ctrl = old;
}), }),
]; ];
return Container( return Container(
@ -885,3 +872,18 @@ void showSetOSPassword(BuildContext context, bool login) {
], ],
)); ));
} }
void sendPrompt(bool isMac, String key) {
final old = isMac ? FFI.command : FFI.ctrl;
if (isMac) {
FFI.command = true;
} else {
FFI.ctrl = true;
}
FFI.inputKey(key);
if (isMac) {
FFI.command = old;
} else {
FFI.ctrl = old;
}
}