From ec3f7a8e91b24030bb4130ab2a104f007965b8c3 Mon Sep 17 00:00:00 2001 From: kingtous Date: Tue, 9 Aug 2022 19:32:19 +0800 Subject: [PATCH 1/3] add: multi window focus --- flutter/lib/common.dart | 14 ++++++++++---- flutter/lib/desktop/pages/connection_tab_page.dart | 2 +- flutter/lib/desktop/pages/desktop_home_page.dart | 2 +- .../lib/desktop/pages/file_manager_tab_page.dart | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 1a0d59e16..26398b7e4 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:io'; +import 'package:desktop_multi_window/desktop_multi_window.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -110,10 +111,15 @@ backToHome() { Navigator.popUntil(globalKey.currentContext!, ModalRoute.withName("/")); } -void window_on_top() { - windowManager.restore(); - windowManager.show(); - windowManager.focus(); +void window_on_top(int? id) { + if (id == null) { + // main window + windowManager.restore(); + windowManager.show(); + windowManager.focus(); + } else { + WindowController.fromWindowId(id)..focus()..show(); + } } typedef DialogBuilder = CustomAlertDialog Function( diff --git a/flutter/lib/desktop/pages/connection_tab_page.dart b/flutter/lib/desktop/pages/connection_tab_page.dart index 8de2d84d0..ffe984943 100644 --- a/flutter/lib/desktop/pages/connection_tab_page.dart +++ b/flutter/lib/desktop/pages/connection_tab_page.dart @@ -49,9 +49,9 @@ class _ConnectionTabPageState extends State "call ${call.method} with args ${call.arguments} from window ${fromWindowId}"); // for simplify, just replace connectionId if (call.method == "new_remote_desktop") { - window_on_top(); final args = jsonDecode(call.arguments); final id = args['id']; + window_on_top(windowId()); final indexOf = connectionIds.indexOf(id); if (indexOf >= 0) { initialIndex = indexOf; diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart index a8f2e51af..e8cd7eff6 100644 --- a/flutter/lib/desktop/pages/desktop_home_page.dart +++ b/flutter/lib/desktop/pages/desktop_home_page.dart @@ -472,7 +472,7 @@ class _DesktopHomePageState extends State with TrayListener, Wi print( "call ${call.method} with args ${call.arguments} from window ${fromWindowId}"); if (call.method == "main_window_on_top") { - window_on_top(); + window_on_top(null); } }); } diff --git a/flutter/lib/desktop/pages/file_manager_tab_page.dart b/flutter/lib/desktop/pages/file_manager_tab_page.dart index 723975d62..c06dd331d 100644 --- a/flutter/lib/desktop/pages/file_manager_tab_page.dart +++ b/flutter/lib/desktop/pages/file_manager_tab_page.dart @@ -46,9 +46,9 @@ class _FileManagerTabPageState extends State "call ${call.method} with args ${call.arguments} from window ${fromWindowId}"); // for simplify, just replace connectionId if (call.method == "new_file_transfer") { - window_on_top(); final args = jsonDecode(call.arguments); final id = args['id']; + window_on_top(windowId()); final indexOf = connectionIds.indexOf(id); if (indexOf >= 0) { initialIndex = indexOf; From eab7ffba7dfaf681c8d44fcac0d84da70844c47a Mon Sep 17 00:00:00 2001 From: kingtous Date: Tue, 9 Aug 2022 19:39:33 +0800 Subject: [PATCH 2/3] feat: focus with restore --- flutter/pubspec.lock | 4 ++-- flutter/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flutter/pubspec.lock b/flutter/pubspec.lock index 2c402951f..6bcf5a159 100644 --- a/flutter/pubspec.lock +++ b/flutter/pubspec.lock @@ -236,8 +236,8 @@ packages: dependency: "direct main" description: path: "." - ref: ce9e333d822fe6cbf91c8634bae023bf78700d94 - resolved-ref: ce9e333d822fe6cbf91c8634bae023bf78700d94 + ref: bbe24b8af079a756f2d39158dd2034127f0e1c73 + resolved-ref: bbe24b8af079a756f2d39158dd2034127f0e1c73 url: "https://github.com/Kingtous/rustdesk_desktop_multi_window" source: git version: "0.1.0" diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index 02d1b42fb..c6d878dee 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -62,7 +62,7 @@ dependencies: desktop_multi_window: git: url: https://github.com/Kingtous/rustdesk_desktop_multi_window - ref: ce9e333d822fe6cbf91c8634bae023bf78700d94 + ref: bbe24b8af079a756f2d39158dd2034127f0e1c73 # bitsdojo_window: ^0.1.2 freezed_annotation: ^2.0.3 tray_manager: 0.1.7 From 0dd91acf0df59193362c2c00ce61485bf38f5ef9 Mon Sep 17 00:00:00 2001 From: Kingtous Date: Tue, 9 Aug 2022 19:49:18 +0800 Subject: [PATCH 3/3] feat: add focus with restore Signed-off-by: Kingtous --- flutter/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index c6d878dee..4ecce228a 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -62,7 +62,7 @@ dependencies: desktop_multi_window: git: url: https://github.com/Kingtous/rustdesk_desktop_multi_window - ref: bbe24b8af079a756f2d39158dd2034127f0e1c73 + ref: c53879e9ce4ed038af393a02bf2c7084ad4b53aa # bitsdojo_window: ^0.1.2 freezed_annotation: ^2.0.3 tray_manager: 0.1.7