From ac33924a9c271a625e9ff2b1b982b7cb79727f87 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Thu, 1 Dec 2022 11:19:51 +0800 Subject: [PATCH 1/3] remove flutter tray --- .../lib/desktop/pages/desktop_home_page.dart | 41 +------------------ flutter/pubspec.lock | 29 ++----------- flutter/pubspec.yaml | 4 -- 3 files changed, 4 insertions(+), 70 deletions(-) diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart index 53f4d4d90..058710aaf 100644 --- a/flutter/lib/desktop/pages/desktop_home_page.dart +++ b/flutter/lib/desktop/pages/desktop_home_page.dart @@ -14,11 +14,8 @@ 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'; -import 'package:window_manager/window_manager.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:window_size/window_size.dart' as window_size; @@ -34,7 +31,7 @@ class DesktopHomePage extends StatefulWidget { const borderColor = Color(0xFF2F65BA); class _DesktopHomePageState extends State - with TrayListener, AutomaticKeepAliveClientMixin { + with AutomaticKeepAliveClientMixin { final _leftPaneScrollController = ScrollController(); @override @@ -428,35 +425,6 @@ class _DesktopHomePageState extends State ); } - @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) { - switch (menuItem.key) { - case kTrayItemQuitKey: - windowManager.close(); - break; - case kTrayItemShowKey: - windowManager.show(); - windowManager.focus(); - break; - default: - break; - } - } - @override void initState() { super.initState(); @@ -492,9 +460,6 @@ class _DesktopHomePageState extends State } }); Get.put(svcStopped, tag: 'stop-service'); - // disable this tray because we use tray function provided by rust now - // initTray(); - trayManager.addListener(this); rustDeskWinManager.registerActiveWindowListener(onActiveWindowChanged); rustDeskWinManager.setMethodHandler((call, fromWindowId) async { @@ -536,10 +501,6 @@ class _DesktopHomePageState extends State @override void dispose() { - // destoryTray(); - // fix: disable unregister to prevent from receiving events from other windows - // rustDeskWinManager.unregisterActiveWindowListener(onActiveWindowChanged); - trayManager.removeListener(this); _uniLinksSubscription?.cancel(); Get.delete(tag: 'stop-service'); _updateTimer?.cancel(); diff --git a/flutter/pubspec.lock b/flutter/pubspec.lock index 7440b5b9e..9803f065c 100644 --- a/flutter/pubspec.lock +++ b/flutter/pubspec.lock @@ -383,8 +383,8 @@ packages: dependency: "direct main" description: path: "." - ref: bfb19c84a8244771488bc05cc5f9c9b5e0324cfd - resolved-ref: bfb19c84a8244771488bc05cc5f9c9b5e0324cfd + ref: "74b1b314142b6775c1243067a3503ac568ebc74b" + resolved-ref: "74b1b314142b6775c1243067a3503ac568ebc74b" url: "https://github.com/Kingtous/rustdesk_flutter_custom_cursor" source: git version: "0.0.1" @@ -617,13 +617,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.4" - menu_base: - dependency: transitive - description: - name: menu_base - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.1" meta: dependency: transitive description: @@ -892,13 +885,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.3" - shortid: - dependency: transitive - description: - name: shortid - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.2" sky_engine: dependency: transitive description: flutter @@ -988,15 +974,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.4.0" - tray_manager: - dependency: "direct main" - description: - path: "." - ref: "3aa37c86e47ea748e7b5507cbe59f2c54ebdb23a" - resolved-ref: "3aa37c86e47ea748e7b5507cbe59f2c54ebdb23a" - url: "https://github.com/Kingtous/rustdesk_tray_manager" - source: git - version: "0.1.8" tuple: dependency: "direct main" description: @@ -1210,7 +1187,7 @@ packages: source: hosted version: "2.2.0" win32: - dependency: transitive + dependency: "direct main" description: name: win32 url: "https://pub.dartlang.org" diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index 8de0be4d6..3d34c30bc 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -65,10 +65,6 @@ dependencies: url: https://github.com/Kingtous/rustdesk_desktop_multi_window ref: cb086219bd4760a95a483cb14c1791d2a39ca5a0 freezed_annotation: ^2.0.3 - tray_manager: - git: - url: https://github.com/Kingtous/rustdesk_tray_manager - ref: 3aa37c86e47ea748e7b5507cbe59f2c54ebdb23a flutter_custom_cursor: git: url: https://github.com/Kingtous/rustdesk_flutter_custom_cursor From 7c09e6690206753632317ac518caecf7c826c4ac Mon Sep 17 00:00:00 2001 From: fufesou Date: Thu, 1 Dec 2022 13:52:12 +0800 Subject: [PATCH 2/3] fix connect on subwindow, notify main window Signed-off-by: fufesou --- flutter/lib/common.dart | 33 +++++++++++++++---- flutter/lib/consts.dart | 3 ++ .../lib/desktop/pages/desktop_home_page.dart | 11 +++++-- .../lib/desktop/widgets/remote_menubar.dart | 4 ++- .../lib/desktop/widgets/tabbar_widget.dart | 4 +-- 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 63ab39df2..eac7fbf9b 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -1290,11 +1290,24 @@ bool callUniLinksUriHandler(Uri uri) { return false; } +connectMainDesktop(String id, + {required bool isFileTransfer, + required bool isTcpTunneling, + required bool isRDP}) async { + if (isFileTransfer) { + await rustDeskWinManager.newFileTransfer(id); + } else if (isTcpTunneling || isRDP) { + await rustDeskWinManager.newPortForward(id, isRDP); + } else { + await rustDeskWinManager.newRemoteDesktop(id); + } +} + /// Connect to a peer with [id]. /// If [isFileTransfer], starts a session only for file transfer. /// If [isTcpTunneling], starts a session only for tcp tunneling. /// If [isRDP], starts a session only for rdp. -void connect(BuildContext context, String id, +connect(BuildContext context, String id, {bool isFileTransfer = false, bool isTcpTunneling = false, bool isRDP = false}) async { @@ -1304,12 +1317,20 @@ void connect(BuildContext context, String id, "more than one connect type"); if (isDesktop) { - if (isFileTransfer) { - await rustDeskWinManager.newFileTransfer(id); - } else if (isTcpTunneling || isRDP) { - await rustDeskWinManager.newPortForward(id, isRDP); + if (desktopType == DesktopType.main) { + await connectMainDesktop( + id, + isFileTransfer: isFileTransfer, + isTcpTunneling: isTcpTunneling, + isRDP: isRDP, + ); } else { - await rustDeskWinManager.newRemoteDesktop(id); + await rustDeskWinManager.call(WindowType.Main, kWindowConnect, { + 'id': id, + 'isFileTransfer': isFileTransfer, + 'isTcpTunneling': isTcpTunneling, + 'isRDP': isRDP, + }); } } else { if (isFileTransfer) { diff --git a/flutter/lib/consts.dart b/flutter/lib/consts.dart index b0099ca7c..50e7f594b 100644 --- a/flutter/lib/consts.dart +++ b/flutter/lib/consts.dart @@ -11,9 +11,12 @@ const String kAppTypeDesktopRemote = "remote"; const String kAppTypeDesktopFileTransfer = "file transfer"; const String kAppTypeDesktopPortForward = "port forward"; +const String kWindowMainWindowOnTop = "main_window_on_top"; +const String kWindowGetWindowInfo = "get_window_info"; const String kWindowActionRebuild = "rebuild"; const String kWindowEventHide = "hide"; const String kWindowEventShow = "show"; +const String kWindowConnect = "connect"; const String kUniLinksPrefix = "rustdesk://"; const String kActionNewConnection = "connection/new/"; diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart index 53f4d4d90..f387c450f 100644 --- a/flutter/lib/desktop/pages/desktop_home_page.dart +++ b/flutter/lib/desktop/pages/desktop_home_page.dart @@ -500,9 +500,9 @@ class _DesktopHomePageState extends State rustDeskWinManager.setMethodHandler((call, fromWindowId) async { debugPrint( "[Main] call ${call.method} with args ${call.arguments} from window $fromWindowId"); - if (call.method == "main_window_on_top") { + if (call.method == kWindowMainWindowOnTop) { window_on_top(null); - } else if (call.method == "get_window_info") { + } else if (call.method == kWindowGetWindowInfo) { final screen = (await window_size.getWindowInfo()).screen; if (screen == null) { return ""; @@ -529,6 +529,13 @@ class _DesktopHomePageState extends State rustDeskWinManager.registerActiveWindow(call.arguments["id"]); } else if (call.method == kWindowEventHide) { rustDeskWinManager.unregisterActiveWindow(call.arguments["id"]); + } else if (call.method == kWindowConnect) { + await connectMainDesktop( + call.arguments['id'], + isFileTransfer: call.arguments['isFileTransfer'], + isTcpTunneling: call.arguments['isTcpTunneling'], + isRDP: call.arguments['isRDP'], + ); } }); _uniLinksSubscription = listenUniLinks(); diff --git a/flutter/lib/desktop/widgets/remote_menubar.dart b/flutter/lib/desktop/widgets/remote_menubar.dart index d40a21e5d..250910396 100644 --- a/flutter/lib/desktop/widgets/remote_menubar.dart +++ b/flutter/lib/desktop/widgets/remote_menubar.dart @@ -8,6 +8,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_hbb/models/chat_model.dart'; import 'package:flutter_hbb/models/state_model.dart'; import 'package:flutter_hbb/consts.dart'; +import 'package:flutter_hbb/utils/multi_window_manager.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; import 'package:rxdart/rxdart.dart' as rxdart; @@ -201,7 +202,8 @@ class _RemoteMenubarState extends State { } _updateScreen() async { - final v = await DesktopMultiWindow.invokeMethod(0, 'get_window_info', ''); + final v = await rustDeskWinManager.call( + WindowType.Main, kWindowGetWindowInfo, ''); final String valueStr = v; if (valueStr.isEmpty) { _screen = null; diff --git a/flutter/lib/desktop/widgets/tabbar_widget.dart b/flutter/lib/desktop/widgets/tabbar_widget.dart index daf9272f7..436011cb5 100644 --- a/flutter/lib/desktop/widgets/tabbar_widget.dart +++ b/flutter/lib/desktop/widgets/tabbar_widget.dart @@ -1033,8 +1033,8 @@ class AddButton extends StatelessWidget { return ActionIcon( message: 'New Connection', icon: IconFont.add, - onTap: () => - rustDeskWinManager.call(WindowType.Main, "main_window_on_top", ""), + onTap: () => rustDeskWinManager.call( + WindowType.Main, kWindowMainWindowOnTop, ""), isClose: false); } } From 60d0b9209b3daf31c14cf6ffb6a9437699f6b04c Mon Sep 17 00:00:00 2001 From: rustdesk Date: Thu, 1 Dec 2022 14:11:09 +0800 Subject: [PATCH 3/3] fix sq.rs --- src/lang/sq.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lang/sq.rs b/src/lang/sq.rs index e9bac2449..626606dd2 100644 --- a/src/lang/sq.rs +++ b/src/lang/sq.rs @@ -2,7 +2,7 @@ lazy_static::lazy_static! { pub static ref T: std::collections::HashMap<&'static str, &'static str> = [ ("desk_tip", "Desktopi juaj mund të aksesohet me këtë ID dhe fjalëkalim."), - ("connecting_status", "Duke u lidhur me rrjetin RustDesk.") + ("connecting_status", "Duke u lidhur me rrjetin RustDesk."), ("not_ready_status", "Jo gati.Ju lutem kontolloni lidhjen tuaj."), ("id_change_tip", "Lejohen Vetëm karkteret a-z,A-Z,0-9 dhe _(nënvizimet).Shkronja e parë duhet të jetë a-z, A-Z. Gjatesia midis 6 dhe 16."), ("install_tip", "Për shkak të UAC, Rustdesk nuk mund të punoj sic duhet si nje remote në distancë në disa raste. Për të shamngur UAC, ju lutem klikoni butonin më poshtë për të instaluar RustDesk në sistem."),