feat, open multi windows

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow
2023-10-17 00:30:34 +08:00
parent f5d8e99fc7
commit bf83d552f8
47 changed files with 363 additions and 80 deletions

View File

@@ -48,6 +48,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
late ToolbarState _toolbarState;
String? peerId;
bool isScreenRectSet = false;
var connectionMap = RxList<Widget>.empty(growable: true);
@@ -59,6 +60,9 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
final tabWindowId = params['tab_window_id'];
final display = params['display'];
final displays = params['displays'];
final screenRect = parseScreenRect(params);
isScreenRectSet = screenRect != null;
tryMoveToScreenAndSetFullscreen(screenRect);
if (peerId != null) {
ConnectionTypeState.init(peerId!);
tabController.onSelected = (id) {
@@ -95,6 +99,18 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
}
}
parseScreenRect(Map<String, dynamic> params) {
Rect? screenRect;
if (params['screen_rect'] != null) {
double l = params['screen_rect']['l'];
double t = params['screen_rect']['t'];
double r = params['screen_rect']['r'];
double b = params['screen_rect']['b'];
screenRect = Rect.fromLTRB(l, t, r, b);
}
return screenRect;
}
@override
void initState() {
super.initState();
@@ -115,7 +131,9 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
final tabWindowId = args['tab_window_id'];
final display = args['display'];
final displays = args['displays'];
final screenRect = parseScreenRect(args);
windowOnTop(windowId());
tryMoveToScreenAndSetFullscreen(screenRect);
if (tabController.length == 0) {
if (Platform.isMacOS && stateGlobal.closeOnFullscreen) {
stateGlobal.setFullscreen(true);
@@ -196,15 +214,17 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
_update_remote_count();
return returnValue;
});
Future.delayed(Duration.zero, () {
restoreWindowPosition(
WindowType.RemoteDesktop,
windowId: windowId(),
peerId: tabController.state.value.tabs.isEmpty
? null
: tabController.state.value.tabs[0].key,
);
});
if (!isScreenRectSet) {
Future.delayed(Duration.zero, () {
restoreWindowPosition(
WindowType.RemoteDesktop,
windowId: windowId(),
peerId: tabController.state.value.tabs.isEmpty
? null
: tabController.state.value.tabs[0].key,
);
});
}
}
@override
@@ -451,6 +471,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
c++;
}
}
loopCloseWindow();
}
ConnectionTypeState.delete(id);