Merge branch 'rustdesk:master' into master

This commit is contained in:
Miguel F. G 2022-11-02 07:45:50 +01:00 committed by GitHub
commit 44bdcfc538
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 62 additions and 30 deletions

BIN
flutter/assets/logo.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

BIN
flutter/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -13,6 +13,7 @@ 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/utils/multi_window_manager.dart';
import 'package:flutter_hbb/utils/tray_manager.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'package:tray_manager/tray_manager.dart';
@ -395,14 +396,29 @@ class _DesktopHomePageState extends State<DesktopHomePage>
);
}
@override
void onTrayIconMouseDown() {
windowManager.show();
}
@override
void onTrayIconRightMouseDown() {
// linux does not support popup menu manually.
// linux will handle popup action ifself.
if (Platform.isMacOS || Platform.isWindows) {
trayManager.popUpContextMenu();
}
}
@override
void onTrayMenuItemClick(MenuItem menuItem) {
debugPrint('click ${menuItem.key}');
switch (menuItem.key) {
case "quit":
exit(0);
case "show":
// windowManager.show();
case kTrayItemQuitKey:
windowManager.close();
break;
case kTrayItemShowKey:
windowManager.show();
windowManager.focus();
break;
default:
break;
@ -416,6 +432,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
updateUrl = await bind.mainGetSoftwareUpdateUrl();
if (updateUrl.isNotEmpty) setState(() {});
});
initTray();
trayManager.addListener(this);
windowManager.addListener(this);
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
@ -456,6 +473,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
@override
void dispose() {
destoryTray();
trayManager.removeListener(this);
windowManager.removeListener(this);
_uniLinksSubscription?.cancel();

View File

@ -443,11 +443,14 @@ class ImagePaint extends StatelessWidget {
Widget _buildCrossScrollbar(BuildContext context, Widget child, Size size) {
var layoutSize = MediaQuery.of(context).size;
// If minimized, w or h may be negative here.
final w = layoutSize.width - kWindowBorderWidth * 2;
final h =
layoutSize.height - kWindowBorderWidth * 2 - kDesktopRemoteTabBarHeight;
layoutSize = Size(
layoutSize.width - kWindowBorderWidth * 2,
layoutSize.height -
kWindowBorderWidth * 2 -
kDesktopRemoteTabBarHeight);
w < 0 ? 0 : w,
h < 0 ? 0 : h,
);
bool overflow =
layoutSize.width < size.width || layoutSize.height < size.height;
return overflow

View File

@ -509,14 +509,15 @@ class WindowActionPanelState extends State<WindowActionPanel>
onTap: () async {
final res = await widget.onClose?.call() ?? true;
if (res) {
if (widget.isMainWindow) {
windowManager.close();
} else {
// only hide for multi window, not close
Future.delayed(Duration.zero, () {
WindowController.fromWindowId(windowId!).hide();
});
}
// hide for all window
// note: the main window can be restored by tray icon
Future.delayed(Duration.zero, () async {
if (widget.isMainWindow) {
await windowManager.hide();
} else {
await WindowController.fromWindowId(windowId!).hide();
}
});
}
},
isClose: true,

View File

@ -101,8 +101,6 @@ void runMainApp(bool startService) async {
await bind.mainCheckConnectStatus();
if (startService) {
// await windowManager.ensureInitialized();
// disable tray
// initTray();
gFFI.serverModel.startService();
}
runApp(App());

View File

@ -577,8 +577,10 @@ class CanvasModel with ChangeNotifier {
Size get size {
final size = MediaQueryData.fromWindow(ui.window).size;
return Size(size.width - windowBorderWidth * 2,
size.height - tabBarHeight - windowBorderWidth * 2);
// If minimized, w or h may be negative here.
double w = size.width - windowBorderWidth * 2;
double h = size.height - tabBarHeight - windowBorderWidth * 2;
return Size(w < 0 ? 0 : w, h < 0 ? 0 : h);
}
moveDesktopMouse(double x, double y) {

View File

@ -4,20 +4,29 @@ import 'package:tray_manager/tray_manager.dart';
import '../common.dart';
const kTrayItemShowKey = "show";
const kTrayItemQuitKey = "quit";
Future<void> initTray({List<MenuItem>? extra_item}) async {
List<MenuItem> items = [
MenuItem(key: "show", label: translate("show rustdesk")),
MenuItem(key: kTrayItemShowKey, label: translate("Show RustDesk")),
MenuItem.separator(),
MenuItem(key: "quit", label: translate("quit rustdesk")),
MenuItem(key: kTrayItemQuitKey, label: translate("Quit")),
];
if (extra_item != null) {
items.insertAll(0, extra_item);
}
await Future.wait([
trayManager
.setIcon(Platform.isWindows ? "assets/logo.ico" : "assets/logo.png"),
trayManager.setContextMenu(Menu(items: items)),
trayManager.setToolTip("rustdesk"),
trayManager.setTitle("rustdesk")
]);
if (Platform.isMacOS || Platform.isWindows) {
await trayManager.setToolTip("rustdesk");
}
if (Platform.isMacOS || Platform.isLinux) {
await trayManager.setTitle("rustdesk");
}
await trayManager
.setIcon(Platform.isWindows ? "assets/logo.ico" : "assets/logo.png");
await trayManager.setContextMenu(Menu(items: items));
}
Future<void> destoryTray() async {
return trayManager.destroy();
}

View File

@ -385,5 +385,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Wayland requires higher version of linux distro. Please try X11 desktop or change your OS.", "Wayland 需要更高版本的 linux 发行版。 请尝试 X11 桌面或更改您的操作系统。"),
("JumpLink", "查看"),
("Please Select the screen to be shared(Operate on the peer side).", "请选择要分享的画面(对端操作)。"),
("Show RustDesk", "显示rustdesk"),
].iter().cloned().collect();
}