add MOUSE_MOVE_TIME to key event, may work for

https://github.com/rustdesk/rustdesk/issues/8633 when window resume via
keyboard rather than mouse
This commit is contained in:
rustdesk 2024-07-08 11:38:42 +08:00
parent 7d961d895b
commit 3c7e24c605
2 changed files with 20 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import 'package:flutter_hbb/models/platform_model.dart';
import 'package:flutter_hbb/models/state_model.dart';
import 'package:get/get.dart';
import 'package:window_manager/window_manager.dart';
// import 'package:flutter/services.dart';
import '../../common/shared_state.dart';
@ -41,6 +42,7 @@ class _DesktopTabPageState extends State<DesktopTabPage>
final tabController = DesktopTabController(tabType: DesktopTabType.main);
final RxBool _block = false.obs;
// bool mouseIn = false;
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
@ -53,6 +55,7 @@ class _DesktopTabPageState extends State<DesktopTabPage>
@override
void initState() {
super.initState();
// HardwareKeyboard.instance.addHandler(_handleKeyEvent);
WidgetsBinding.instance.addObserver(this);
Get.put<DesktopTabController>(tabController);
RemoteCountState.init();
@ -78,8 +81,19 @@ class _DesktopTabPageState extends State<DesktopTabPage>
}
}
/*
bool _handleKeyEvent(KeyEvent event) {
if (!mouseIn && event is KeyDownEvent) {
print('key down: ${event.logicalKey}');
shouldBeBlocked(_block, canBeBlocked);
}
return false; // allow it to propagate
}
*/
@override
void dispose() {
// HardwareKeyboard.instance.removeHandler(_handleKeyEvent);
WidgetsBinding.instance.removeObserver(this);
Get.delete<DesktopTabController>();
@ -105,8 +119,12 @@ class _DesktopTabPageState extends State<DesktopTabPage>
)));
widget() => MouseRegion(
onEnter: (_) async {
// mouseIn = true;
await shouldBeBlocked(_block, canBeBlocked);
},
onExit: (_) {
// mouseIn = false;
},
child: FocusScope(child: tabWidget, canRequestFocus: !_block.value));
return isMacOS || kUseCompatibleUiMode
? Obx(() => widget())

View File

@ -1999,6 +1999,8 @@ impl Connection {
if is_enter(&me) {
CLICK_TIME.store(get_time(), Ordering::SeqCst);
}
// https://github.com/rustdesk/rustdesk/issues/8633
MOUSE_MOVE_TIME.store(get_time(), Ordering::SeqCst);
// handle all down as press
// fix unexpected repeating key on remote linux, seems also fix abnormal alt/shift, which
// make sure all key are released