From 17285720f1b8b09bed046bd015ecd3749145a344 Mon Sep 17 00:00:00 2001 From: fufesou Date: Thu, 26 Oct 2023 16:11:08 +0800 Subject: [PATCH] fix, dialog blocks tabs on the remote page Signed-off-by: fufesou --- flutter/lib/desktop/pages/remote_page.dart | 39 ++++++++++++++++++---- src/flutter_ffi.rs | 1 + 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index cb9cf49c9..6d0ba09cd 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -80,7 +80,7 @@ class _RemotePageState extends State late RxBool _keyboardEnabled; final Map _renderTextures = {}; - final _blockableOverlayState = BlockableOverlayState(); + var _blockableOverlayState = BlockableOverlayState(); final FocusNode _rawKeyFocusNode = FocusNode(debugLabel: "rawkeyFocusNode"); @@ -253,9 +253,9 @@ class _RemotePageState extends State onEnterOrLeaveImageCleaner: () => _onEnterOrLeaveImage4Toolbar = null, setRemoteState: setState, ); - return Scaffold( - backgroundColor: Theme.of(context).colorScheme.background, - body: Stack( + + bodyWidget() { + return Stack( children: [ Container( color: Colors.black, @@ -281,7 +281,7 @@ class _RemotePageState extends State }, inputModel: _ffi.inputModel, child: getBodyForDesktop(context))), - Obx(() => Stack( + Stack( children: [ _ffi.ffiModel.pi.isSet.isTrue && _ffi.ffiModel.waitForFirstImage.isTrue @@ -298,9 +298,34 @@ class _RemotePageState extends State : remoteToolbar(context), _ffi.ffiModel.pi.isSet.isFalse ? emptyOverlay() : Offstage(), ], - )), + ), ], - ), + ); + } + + return Scaffold( + backgroundColor: Theme.of(context).colorScheme.background, + body: Obx(() { + final imageReady = _ffi.ffiModel.pi.isSet.isTrue && + _ffi.ffiModel.waitForFirstImage.isFalse; + if (imageReady) { + // dismissAll() is ensure the state is clean. + // It's ok to call dismissAll() here. + _ffi.dialogManager.dismissAll(); + // Recreate the block state to refresh the state. + _blockableOverlayState = BlockableOverlayState(); + _blockableOverlayState.applyFfi(_ffi); + // Block the whole bodyWidget() when dialog shows. + return BlockableOverlay( + underlying: bodyWidget(), + state: _blockableOverlayState, + ); + } else { + // _blockableOverlayState is not recreated here. + // The block state for the toolbar will not work on reconnecting, but it's ok. + return bodyWidget(); + } + }), ); } diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 9661aa8b3..1484d2440 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -210,6 +210,7 @@ pub fn session_reconnect(session_id: SessionID, force_relay: bool) { if let Some(session) = sessions::get_session_by_session_id(&session_id) { session.reconnect(force_relay); } + session_on_waiting_for_image_dialog_show(session_id); } pub fn session_toggle_option(session_id: SessionID, value: String) {