fix: cannot input alt+tab when cursor is outside

This commit is contained in:
Kingtous 2022-12-20 22:07:48 +08:00
parent f0653bb10a
commit 8bb62abd3e
2 changed files with 19 additions and 3 deletions

View File

@ -157,6 +157,11 @@ class _RemotePageState extends State<RemotePage>
focusNode: _rawKeyFocusNode, focusNode: _rawKeyFocusNode,
onFocusChange: (bool v) { onFocusChange: (bool v) {
_imageFocused = v; _imageFocused = v;
if (_imageFocused) {
_ffi.inputModel.enterOrLeave(true);
} else {
_ffi.inputModel.enterOrLeave(false);
}
}, },
inputModel: _ffi.inputModel, inputModel: _ffi.inputModel,
child: getBodyForDesktop(context))); child: getBodyForDesktop(context)));
@ -195,7 +200,6 @@ class _RemotePageState extends State<RemotePage>
// //
} }
} }
_ffi.inputModel.enterOrLeave(true);
} }
void leaveView(PointerExitEvent evt) { void leaveView(PointerExitEvent evt) {
@ -208,7 +212,6 @@ class _RemotePageState extends State<RemotePage>
// //
} }
} }
_ffi.inputModel.enterOrLeave(false);
} }
Widget getBodyForDesktop(BuildContext context) { Widget getBodyForDesktop(BuildContext context) {

View File

@ -37,7 +37,8 @@ class ConnectionTabPage extends StatefulWidget {
State<ConnectionTabPage> createState() => _ConnectionTabPageState(params); State<ConnectionTabPage> createState() => _ConnectionTabPageState(params);
} }
class _ConnectionTabPageState extends State<ConnectionTabPage> { class _ConnectionTabPageState extends State<ConnectionTabPage>
with MultiWindowListener {
final tabController = Get.put(DesktopTabController( final tabController = Get.put(DesktopTabController(
tabType: DesktopTabType.remoteScreen, tabType: DesktopTabType.remoteScreen,
onSelected: (_, id) => bind.setCurSessionId(id: id))); onSelected: (_, id) => bind.setCurSessionId(id: id)));
@ -105,14 +106,26 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
} }
_update_remote_count(); _update_remote_count();
}); });
DesktopMultiWindow.addListener(this);
} }
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
DesktopMultiWindow.removeListener(this);
_menubarState.save(); _menubarState.save();
} }
@override
void onWindowBlur() {
super.onWindowBlur();
final state = tabController.state.value;
if (state.tabs.isNotEmpty) {
final sessionId = state.tabs[state.selected].key;
bind.sessionEnterOrLeave(id: sessionId, enter: false);
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final tabWidget = Obx( final tabWidget = Obx(