From bf63d397e026b5ff5b8c593a60340289a16f9f6b Mon Sep 17 00:00:00 2001 From: Kingtous Date: Thu, 29 Dec 2022 17:51:00 +0800 Subject: [PATCH] opt: add a double check on focus --- flutter/lib/desktop/pages/remote_page.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index b9f25e0dd..2ecc1e6c9 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -294,6 +294,16 @@ class _RemotePageState extends State onEnter: enterView, onExit: leaveView, onPointerDown: (event) { + // A double check for blur status. + // Note: If there's an `onPointerDown` event is triggered, `_isWindowBlur` is expected being false. + // Sometimes the system does not send the necessary focus event to flutter. We should manually + // handle this inconsistent status by setting `_isWindowBlur` to false. So we can + // ensure the grab-key thread is running when our users are clicking the remote canvas. + if (_isWindowBlur) { + debugPrint( + "Unexpected status: onPointerDown is triggered while the remote window is in blur status"); + _isWindowBlur = false; + } if (!_rawKeyFocusNode.hasFocus) { _rawKeyFocusNode.requestFocus(); }