Merge remote-tracking branch 'upstream/master' into file-manager-redesign

This commit is contained in:
NicKoehler
2023-02-22 23:01:31 +01:00
parent 922a70adb4
commit 12a33cdfbb
31 changed files with 488 additions and 282 deletions

View File

@@ -43,11 +43,8 @@ class _AddressBookState extends State<AddressBook> {
return Obx(() {
if (gFFI.userModel.userName.value.isEmpty) {
return Center(
child: ElevatedButton(
onPressed: loginDialog,
child: Text(translate("Login"))
)
);
child: ElevatedButton(
onPressed: loginDialog, child: Text(translate("Login"))));
} else {
if (gFFI.abModel.abLoading.value) {
return const Center(
@@ -153,13 +150,13 @@ class _AddressBookState extends State<AddressBook> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(translate('Tags')),
GestureDetector(
onTapDown: (e) {
final x = e.globalPosition.dx;
final y = e.globalPosition.dy;
Listener(
onPointerDown: (e) {
final x = e.position.dx;
final y = e.position.dy;
menuPos = RelativeRect.fromLTRB(x, y, x, y);
},
onTap: () => _showMenu(menuPos),
onPointerUp: (_) => _showMenu(menuPos),
child: ActionMore()),
],
);

View File

@@ -1,8 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hbb/models/state_model.dart';
import '../../common.dart';
import '../../models/input_model.dart';
class RawKeyFocusScope extends StatelessWidget {
@@ -20,13 +18,6 @@ class RawKeyFocusScope extends StatelessWidget {
@override
Widget build(BuildContext context) {
final FocusOnKeyCallback? onKey;
if (isAndroid) {
onKey = inputModel.handleRawKeyEvent;
} else {
onKey = stateGlobal.grabKeyboard ? inputModel.handleRawKeyEvent : null;
}
return FocusScope(
autofocus: true,
child: Focus(
@@ -34,7 +25,7 @@ class RawKeyFocusScope extends StatelessWidget {
canRequestFocus: true,
focusNode: focusNode,
onFocusChange: onFocusChange,
onKey: onKey,
onKey: inputModel.handleRawKeyEvent,
child: child));
}
}

View File

@@ -20,6 +20,7 @@ const String kAppTypeDesktopPortForward = "port forward";
const String kWindowMainWindowOnTop = "main_window_on_top";
const String kWindowGetWindowInfo = "get_window_info";
const String kWindowDisableGrabKeyboard = "disable_grab_keyboard";
const String kWindowActionRebuild = "rebuild";
const String kWindowEventHide = "hide";
const String kWindowEventShow = "show";

View File

@@ -14,6 +14,7 @@ import 'package:flutter_hbb/desktop/pages/desktop_tab_page.dart';
import 'package:flutter_hbb/desktop/widgets/scroll_wrapper.dart';
import 'package:flutter_hbb/models/platform_model.dart';
import 'package:flutter_hbb/models/server_model.dart';
import 'package:flutter_hbb/models/state_model.dart';
import 'package:flutter_hbb/utils/multi_window_manager.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
@@ -498,6 +499,10 @@ class _DesktopHomePageState extends State<DesktopHomePage>
if (watchIsInputMonitoring) {
if (bind.mainIsCanInputMonitoring(prompt: false)) {
watchIsInputMonitoring = false;
// Do not notify for now.
// Monitoring may not take effect until the process is restarted.
// rustDeskWinManager.call(
// WindowType.RemoteDesktop, kWindowDisableGrabKeyboard, '');
setState(() {});
}
}

View File

@@ -111,6 +111,8 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
forceRelay: args['forceRelay'],
),
));
} else if (call.method == kWindowDisableGrabKeyboard) {
stateGlobal.grabKeyboard = false;
} else if (call.method == "onDestroy") {
tabController.clear();
} else if (call.method == kWindowActionRebuild) {

View File

@@ -650,6 +650,12 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
}
Widget _buildKeyboard(BuildContext context) {
// Do not support peer 1.1.9.
if (stateGlobal.grabKeyboard) {
bind.sessionSetKeyboardMode(id: widget.id, value: 'map');
return Offstage();
}
FfiModel ffiModel = Provider.of<FfiModel>(context);
if (ffiModel.permissions['keyboard'] == false) {
return Offstage();

View File

@@ -548,13 +548,20 @@ class WindowActionPanelState extends State<WindowActionPanel>
if (rustDeskWinManager.getActiveWindows().contains(kMainWindowId)) {
await rustDeskWinManager.unregisterActiveWindow(kMainWindowId);
}
// `hide` must be placed after unregisterActiveWindow, because once all windows are hidden,
// flutter closes the application on macOS. We should ensure the post-run logic has ran successfully.
// e.g.: saving window position.
// macOS specific workaround, the window is not hiding when in fullscreen.
if (Platform.isMacOS && await windowManager.isFullScreen()) {
await windowManager.setFullScreen(false);
await Future.delayed(Duration(seconds: 1));
}
await windowManager.hide();
} else {
// it's safe to hide the subwindow
await WindowController.fromWindowId(kWindowId!).hide();
final controller = WindowController.fromWindowId(kWindowId!);
if (Platform.isMacOS && await controller.isFullScreen()) {
await controller.setFullscreen(false);
await Future.delayed(Duration(seconds: 1));
}
await controller.hide();
await Future.wait([
rustDeskWinManager
.call(WindowType.Main, kWindowEventHide, {"id": kWindowId!}),

View File

@@ -58,6 +58,10 @@ class InputModel {
InputModel(this.parent);
KeyEventResult handleRawKeyEvent(FocusNode data, RawKeyEvent e) {
if (!stateGlobal.grabKeyboard) {
return KeyEventResult.handled;
}
// * Currently mobile does not enable map mode
if (isDesktop) {
bind.sessionGetKeyboardMode(id: id).then((result) {