mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-19 00:13:01 +08:00
fix: close all typed sessions when hide subwindow
This commit is contained in:
parent
d7aa8b43c5
commit
c72e48bef1
@ -63,7 +63,6 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
label: id,
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
closable: false,
|
||||
page: Obx(() => RemotePage(
|
||||
key: ValueKey(id),
|
||||
id: id,
|
||||
@ -71,7 +70,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight,
|
||||
))));
|
||||
} else if (call.method == "onDestroy") {
|
||||
tabController.state.value.tabs.clear();
|
||||
tabController.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -93,6 +92,9 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
theme: theme,
|
||||
isMainWindow: false,
|
||||
showTabBar: fullscreen.isFalse,
|
||||
onClose: () {
|
||||
tabController.clear();
|
||||
},
|
||||
tail: AddButton(
|
||||
theme: theme,
|
||||
).paddingOnly(left: 10),
|
||||
|
@ -19,12 +19,13 @@ class FileManagerTabPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
final tabController = Get.put(DesktopTabController());
|
||||
DesktopTabController get tabController => Get.find<DesktopTabController>();
|
||||
|
||||
static final IconData selectedIcon = Icons.file_copy_sharp;
|
||||
static final IconData unselectedIcon = Icons.file_copy_outlined;
|
||||
|
||||
_FileManagerTabPageState(Map<String, dynamic> params) {
|
||||
Get.put(DesktopTabController());
|
||||
tabController.add(TabInfo(
|
||||
key: params['id'],
|
||||
label: params['id'],
|
||||
@ -36,7 +37,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
|
||||
tabController.onRemove = (_, id) => onRemoveId(id);
|
||||
|
||||
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
|
||||
@ -54,7 +55,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
unselectedIcon: unselectedIcon,
|
||||
page: FileManagerPage(key: ValueKey(id), id: id)));
|
||||
} else if (call.method == "onDestroy") {
|
||||
tabController.state.value.tabs.clear();
|
||||
tabController.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -74,6 +75,9 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
controller: tabController,
|
||||
theme: theme,
|
||||
isMainWindow: false,
|
||||
onClose: () {
|
||||
tabController.clear();
|
||||
},
|
||||
tail: AddButton(
|
||||
theme: theme,
|
||||
).paddingOnly(left: 10),
|
||||
|
@ -58,7 +58,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
||||
unselectedIcon: unselectedIcon,
|
||||
page: PortForwardPage(id: id, isRDP: isRDP)));
|
||||
} else if (call.method == "onDestroy") {
|
||||
tabController.state.value.tabs.clear();
|
||||
tabController.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -77,6 +77,9 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
||||
controller: tabController,
|
||||
theme: theme,
|
||||
isMainWindow: false,
|
||||
onClose: () {
|
||||
tabController.clear();
|
||||
},
|
||||
tail: AddButton(
|
||||
theme: theme,
|
||||
).paddingOnly(left: 10),
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
@ -113,6 +114,11 @@ class DesktopTabController {
|
||||
remove(state.value.selected);
|
||||
}
|
||||
}
|
||||
|
||||
void clear() {
|
||||
state.value.tabs.clear();
|
||||
state.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
class DesktopTab extends StatelessWidget {
|
||||
@ -127,11 +133,12 @@ class DesktopTab extends StatelessWidget {
|
||||
final bool showClose;
|
||||
final Widget Function(Widget pageView)? pageViewBuilder;
|
||||
final Widget? tail;
|
||||
final VoidCallback? onClose;
|
||||
|
||||
final DesktopTabController controller;
|
||||
late final state = controller.state;
|
||||
Rx<DesktopTabState> get state => controller.state;
|
||||
|
||||
DesktopTab(
|
||||
const DesktopTab(
|
||||
{required this.controller,
|
||||
required this.isMainWindow,
|
||||
this.theme = const TarBarTheme.light(),
|
||||
@ -143,7 +150,8 @@ class DesktopTab extends StatelessWidget {
|
||||
this.showMaximize = true,
|
||||
this.showClose = true,
|
||||
this.pageViewBuilder,
|
||||
this.tail});
|
||||
this.tail,
|
||||
this.onClose});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -185,6 +193,9 @@ class DesktopTab extends StatelessWidget {
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Offstage(
|
||||
offstage: !Platform.isMacOS,
|
||||
child: const SizedBox(width: 78,)),
|
||||
Row(children: [
|
||||
Offstage(
|
||||
offstage: !showLogo,
|
||||
@ -229,6 +240,7 @@ class DesktopTab extends StatelessWidget {
|
||||
showMinimize: showMinimize,
|
||||
showMaximize: showMaximize,
|
||||
showClose: showClose,
|
||||
onClose: onClose,
|
||||
)
|
||||
],
|
||||
);
|
||||
@ -242,6 +254,7 @@ class WindowActionPanel extends StatelessWidget {
|
||||
final bool showMinimize;
|
||||
final bool showMaximize;
|
||||
final bool showClose;
|
||||
final VoidCallback? onClose;
|
||||
|
||||
const WindowActionPanel(
|
||||
{Key? key,
|
||||
@ -249,7 +262,8 @@ class WindowActionPanel extends StatelessWidget {
|
||||
required this.theme,
|
||||
this.showMinimize = true,
|
||||
this.showMaximize = true,
|
||||
this.showClose = true})
|
||||
this.showClose = true,
|
||||
this.onClose})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@ -324,8 +338,11 @@ class WindowActionPanel extends StatelessWidget {
|
||||
windowManager.close();
|
||||
} else {
|
||||
// only hide for multi window, not close
|
||||
WindowController.fromWindowId(windowId!).hide();
|
||||
Future.delayed(Duration.zero, () {
|
||||
WindowController.fromWindowId(windowId!).hide();
|
||||
});
|
||||
}
|
||||
onClose?.call();
|
||||
},
|
||||
is_close: true,
|
||||
)),
|
||||
@ -337,13 +354,12 @@ class WindowActionPanel extends StatelessWidget {
|
||||
// ignore: must_be_immutable
|
||||
class _ListView extends StatelessWidget {
|
||||
final DesktopTabController controller;
|
||||
late final Rx<DesktopTabState> state;
|
||||
final Function(String key)? onTabClose;
|
||||
final TarBarTheme theme;
|
||||
Rx<DesktopTabState> get state => controller.state;
|
||||
|
||||
_ListView(
|
||||
{required this.controller, required this.onTabClose, required this.theme})
|
||||
: this.state = controller.state;
|
||||
const _ListView(
|
||||
{required this.controller, required this.onTabClose, required this.theme});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -80,14 +80,7 @@ Future<void> initEnv(String appType) async {
|
||||
}
|
||||
|
||||
void runMainApp(bool startService) async {
|
||||
WindowOptions windowOptions = getHiddenTitleBarWindowOptions(Size(1280, 720));
|
||||
await Future.wait([
|
||||
initEnv(kAppTypeMain),
|
||||
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||
await windowManager.show();
|
||||
await windowManager.focus();
|
||||
})
|
||||
]);
|
||||
await initEnv(kAppTypeMain);
|
||||
if (startService) {
|
||||
// await windowManager.ensureInitialized();
|
||||
// disable tray
|
||||
@ -95,6 +88,12 @@ void runMainApp(bool startService) async {
|
||||
gFFI.serverModel.startService();
|
||||
}
|
||||
runApp(App());
|
||||
// set window option
|
||||
WindowOptions windowOptions = getHiddenTitleBarWindowOptions(const Size(1280, 720));
|
||||
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||
await windowManager.show();
|
||||
await windowManager.focus();
|
||||
});
|
||||
}
|
||||
|
||||
void runMobileApp() async {
|
||||
|
@ -117,7 +117,7 @@ class PlatformFFI {
|
||||
_homeDir = (await getDownloadsDirectory())?.path ?? "";
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
print("initialize failed: $e");
|
||||
}
|
||||
String id = 'NA';
|
||||
String name = 'Flutter';
|
||||
@ -151,7 +151,7 @@ class PlatformFFI {
|
||||
await _ffiBind.mainSetHomeDir(home: _homeDir);
|
||||
await _ffiBind.mainInit(appDir: _dir);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
print("initialize failed: $e");
|
||||
}
|
||||
version = await getVersion();
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ class RustDeskMultiWindowManager {
|
||||
// no such window already
|
||||
return;
|
||||
}
|
||||
await WindowController.fromWindowId(wId).hide();
|
||||
await WindowController.fromWindowId(wId).close();
|
||||
} on Error {
|
||||
return;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ dependencies:
|
||||
provider: ^6.0.3
|
||||
tuple: ^2.0.0
|
||||
wakelock: ^0.5.2
|
||||
device_info_plus: ^4.0.2
|
||||
device_info_plus: ^4.1.2
|
||||
firebase_analytics: ^9.1.5
|
||||
package_info_plus: ^1.4.2
|
||||
url_launcher: ^6.0.9
|
||||
|
Loading…
Reference in New Issue
Block a user