mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge pull request #5489 from fufesou/fix/enable_menu_before_image
Fix/enable menu before image
This commit is contained in:
@@ -228,49 +228,67 @@ class _RemotePageState extends State<RemotePage>
|
||||
removeSharedStates(widget.id);
|
||||
}
|
||||
|
||||
Widget buildBody(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Theme.of(context).colorScheme.background,
|
||||
|
||||
/// the Overlay key will be set with _blockableOverlayState in BlockableOverlay
|
||||
/// see override build() in [BlockableOverlay]
|
||||
body: BlockableOverlay(
|
||||
Widget emptyOverlay() => BlockableOverlay(
|
||||
/// the Overlay key will be set with _blockableOverlayState in BlockableOverlay
|
||||
/// see override build() in [BlockableOverlay]
|
||||
state: _blockableOverlayState,
|
||||
underlying: Container(
|
||||
color: Colors.black,
|
||||
child: RawKeyFocusScope(
|
||||
focusNode: _rawKeyFocusNode,
|
||||
onFocusChange: (bool imageFocused) {
|
||||
debugPrint(
|
||||
"onFocusChange(window active:${!_isWindowBlur}) $imageFocused");
|
||||
// See [onWindowBlur].
|
||||
if (Platform.isWindows) {
|
||||
if (_isWindowBlur) {
|
||||
imageFocused = false;
|
||||
Future.delayed(Duration.zero, () {
|
||||
_rawKeyFocusNode.unfocus();
|
||||
});
|
||||
color: Colors.transparent,
|
||||
),
|
||||
);
|
||||
|
||||
Widget buildBody(BuildContext context) {
|
||||
remoteToolbar(BuildContext context) => RemoteToolbar(
|
||||
id: widget.id,
|
||||
ffi: _ffi,
|
||||
state: widget.toolbarState,
|
||||
onEnterOrLeaveImageSetter: (func) =>
|
||||
_onEnterOrLeaveImage4Toolbar = func,
|
||||
onEnterOrLeaveImageCleaner: () => _onEnterOrLeaveImage4Toolbar = null,
|
||||
);
|
||||
return Scaffold(
|
||||
backgroundColor: Theme.of(context).colorScheme.background,
|
||||
body: Stack(
|
||||
children: [
|
||||
Container(
|
||||
color: Colors.black,
|
||||
child: RawKeyFocusScope(
|
||||
focusNode: _rawKeyFocusNode,
|
||||
onFocusChange: (bool imageFocused) {
|
||||
debugPrint(
|
||||
"onFocusChange(window active:${!_isWindowBlur}) $imageFocused");
|
||||
// See [onWindowBlur].
|
||||
if (Platform.isWindows) {
|
||||
if (_isWindowBlur) {
|
||||
imageFocused = false;
|
||||
Future.delayed(Duration.zero, () {
|
||||
_rawKeyFocusNode.unfocus();
|
||||
});
|
||||
}
|
||||
if (imageFocused) {
|
||||
_ffi.inputModel.enterOrLeave(true);
|
||||
} else {
|
||||
_ffi.inputModel.enterOrLeave(false);
|
||||
}
|
||||
}
|
||||
if (imageFocused) {
|
||||
_ffi.inputModel.enterOrLeave(true);
|
||||
} else {
|
||||
_ffi.inputModel.enterOrLeave(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
inputModel: _ffi.inputModel,
|
||||
child: getBodyForDesktop(context))),
|
||||
upperLayer: [
|
||||
OverlayEntry(
|
||||
builder: (context) => RemoteToolbar(
|
||||
id: widget.id,
|
||||
ffi: _ffi,
|
||||
state: widget.toolbarState,
|
||||
onEnterOrLeaveImageSetter: (func) =>
|
||||
_onEnterOrLeaveImage4Toolbar = func,
|
||||
onEnterOrLeaveImageCleaner: () =>
|
||||
_onEnterOrLeaveImage4Toolbar = null,
|
||||
))
|
||||
},
|
||||
inputModel: _ffi.inputModel,
|
||||
child: getBodyForDesktop(context))),
|
||||
Obx(() => Stack(
|
||||
children: [
|
||||
_ffi.ffiModel.pi.isSet.isTrue &&
|
||||
_ffi.ffiModel.waitForFirstImage.isTrue
|
||||
? emptyOverlay()
|
||||
: Offstage(),
|
||||
// Use Overlay to enable rebuild every time on menu button click.
|
||||
_ffi.ffiModel.pi.isSet.isTrue
|
||||
? Overlay(initialEntries: [
|
||||
OverlayEntry(builder: remoteToolbar)
|
||||
])
|
||||
: remoteToolbar(context),
|
||||
_ffi.ffiModel.pi.isSet.isFalse ? emptyOverlay() : Offstage(),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -266,7 +266,11 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
if (e.kind != ui.PointerDeviceKind.mouse) {
|
||||
return;
|
||||
}
|
||||
if (e.buttons == 2) {
|
||||
final remotePage = tabController.state.value.tabs
|
||||
.firstWhere((tab) => tab.key == key)
|
||||
.page as RemotePage;
|
||||
if (remotePage.ffi.ffiModel.pi.isSet.isTrue &&
|
||||
e.buttons == 2) {
|
||||
showRightMenu(
|
||||
(CancelFunc cancelFunc) {
|
||||
return _tabMenuBuilder(key, cancelFunc);
|
||||
|
||||
@@ -77,7 +77,7 @@ CancelFunc showRightMenu(ToastBuilder builder,
|
||||
targetContext: context,
|
||||
verticalOffset: 0,
|
||||
horizontalOffset: 0,
|
||||
duration: Duration(seconds: 4),
|
||||
duration: Duration(seconds: 300),
|
||||
animationDuration: Duration(milliseconds: 0),
|
||||
animationReverseDuration: Duration(milliseconds: 0),
|
||||
preferDirection: PreferDirection.rightTop,
|
||||
|
||||
@@ -38,8 +38,6 @@ import 'platform_model.dart';
|
||||
|
||||
typedef HandleMsgBox = Function(Map<String, dynamic> evt, String id);
|
||||
typedef ReconnectHandle = Function(OverlayDialogManager, SessionID, bool);
|
||||
final _waitForImageDialogShow = <UuidValue, bool>{};
|
||||
final _waitForFirstImage = <UuidValue, bool>{};
|
||||
final _constSessionId = Uuid().v4obj();
|
||||
|
||||
class CachedPeerData {
|
||||
@@ -100,6 +98,10 @@ class FfiModel with ChangeNotifier {
|
||||
WeakReference<FFI> parent;
|
||||
late final SessionID sessionId;
|
||||
|
||||
RxBool waitForImageDialogShow = true.obs;
|
||||
Timer? waitForImageTimer;
|
||||
RxBool waitForFirstImage = true.obs;
|
||||
|
||||
Map<String, bool> get permissions => _permissions;
|
||||
|
||||
Display get display => _display;
|
||||
@@ -158,6 +160,7 @@ class FfiModel with ChangeNotifier {
|
||||
_timer?.cancel();
|
||||
_timer = null;
|
||||
clearPermissions();
|
||||
waitForImageTimer?.cancel();
|
||||
}
|
||||
|
||||
setConnectionType(String peerId, bool secure, bool direct) {
|
||||
@@ -498,7 +501,7 @@ class FfiModel with ChangeNotifier {
|
||||
closeConnection();
|
||||
}
|
||||
|
||||
if (_waitForFirstImage[sessionId] == false) return;
|
||||
if (waitForFirstImage.isFalse) return;
|
||||
dialogManager.show(
|
||||
(setState, close, context) => CustomAlertDialog(
|
||||
title: null,
|
||||
@@ -509,7 +512,12 @@ class FfiModel with ChangeNotifier {
|
||||
onCancel: onClose),
|
||||
tag: '$sessionId-waiting-for-image',
|
||||
);
|
||||
_waitForImageDialogShow[sessionId] = true;
|
||||
waitForImageDialogShow.value = true;
|
||||
waitForImageTimer = Timer(Duration(milliseconds: 1500), () {
|
||||
if (waitForFirstImage.isTrue) {
|
||||
bind.sessionInputOsPassword(sessionId: sessionId, value: '');
|
||||
}
|
||||
});
|
||||
bind.sessionOnWaitingForImageDialogShow(sessionId: sessionId);
|
||||
}
|
||||
|
||||
@@ -578,7 +586,7 @@ class FfiModel with ChangeNotifier {
|
||||
}
|
||||
if (displays.isNotEmpty) {
|
||||
_reconnects = 1;
|
||||
_waitForFirstImage[sessionId] = true;
|
||||
waitForFirstImage.value = true;
|
||||
}
|
||||
Map<String, dynamic> features = json.decode(evt['features']);
|
||||
_pi.features.privacyMode = features['privacy_mode'] == 1;
|
||||
@@ -602,6 +610,7 @@ class FfiModel with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
_pi.isSet.value = true;
|
||||
stateGlobal.resetLastResolutionGroupValues(peerId);
|
||||
|
||||
notifyListeners();
|
||||
@@ -1814,12 +1823,13 @@ class FFI {
|
||||
}
|
||||
|
||||
void onEvent2UIRgba() async {
|
||||
if (_waitForImageDialogShow[sessionId] == true) {
|
||||
_waitForImageDialogShow[sessionId] = false;
|
||||
if (ffiModel.waitForImageDialogShow.isTrue) {
|
||||
ffiModel.waitForImageDialogShow.value = false;
|
||||
ffiModel.waitForImageTimer?.cancel();
|
||||
clearWaitingForImage(dialogManager, sessionId);
|
||||
}
|
||||
if (_waitForFirstImage[sessionId] == true) {
|
||||
_waitForFirstImage[sessionId] = false;
|
||||
if (ffiModel.waitForFirstImage.value == true) {
|
||||
ffiModel.waitForFirstImage.value = false;
|
||||
dialogManager.dismissAll();
|
||||
await canvasModel.updateViewStyle();
|
||||
await canvasModel.updateScrollStyle();
|
||||
@@ -1934,7 +1944,7 @@ class Features {
|
||||
bool privacyMode = false;
|
||||
}
|
||||
|
||||
class PeerInfo {
|
||||
class PeerInfo with ChangeNotifier {
|
||||
String version = '';
|
||||
String username = '';
|
||||
String hostname = '';
|
||||
@@ -1946,6 +1956,8 @@ class PeerInfo {
|
||||
List<Resolution> resolutions = [];
|
||||
Map<String, dynamic> platform_additions = {};
|
||||
|
||||
RxBool isSet = false.obs;
|
||||
|
||||
bool get is_wayland => platform_additions['is_wayland'] == true;
|
||||
bool get is_headless => platform_additions['headless'] == true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user