mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-28 15:49:04 +08:00
fix: window close hook
Signed-off-by: Kingtous <kingtous@qq.com>
This commit is contained in:
parent
6c4f5dc007
commit
60a628aefe
@ -2,9 +2,13 @@ import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/remote_page.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/titlebar_widget.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../models/model.dart';
|
||||
|
||||
class ConnectionTabPage extends StatefulWidget {
|
||||
final Map<String, dynamic> params;
|
||||
@ -51,6 +55,15 @@ class _ConnectionTabPageState extends State<ConnectionTabPage>
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (call.method == "onDestroy") {
|
||||
print("executing onDestroy hook, closing ${connectionIds}");
|
||||
connectionIds.forEach((id) {
|
||||
final tag = '${id}';
|
||||
ffi(tag).close().then((_) {
|
||||
Get.delete<FFI>(tag: tag);
|
||||
});
|
||||
});
|
||||
Get.back();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2,8 +2,10 @@ import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/file_manager_page.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/titlebar_widget.dart';
|
||||
import 'package:flutter_hbb/models/model.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@ -21,7 +23,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
// refactor List<int> when using multi-tab
|
||||
// this singleton is only for test
|
||||
List<String> connectionIds = List.empty(growable: true);
|
||||
var connectionIds = List<String>.empty(growable: true).obs;
|
||||
var initialIndex = 0.obs;
|
||||
|
||||
_FileManagerTabPageState(Map<String, dynamic> params) {
|
||||
@ -47,6 +49,15 @@ class _FileManagerTabPageState extends State<FileManagerTabPage>
|
||||
connectionIds.add(id);
|
||||
initialIndex.value = connectionIds.length - 1;
|
||||
}
|
||||
} else if (call.method == "onDestroy") {
|
||||
print("executing onDestroy hook, closing ${connectionIds}");
|
||||
connectionIds.forEach((id) {
|
||||
final tag = 'ft_${id}';
|
||||
ffi(tag).close().then((_) {
|
||||
Get.delete<FFI>(tag: tag);
|
||||
});
|
||||
});
|
||||
Get.back();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -954,10 +954,10 @@ class FFI {
|
||||
}
|
||||
|
||||
/// Close the remote session.
|
||||
void close() {
|
||||
Future<void> close() async {
|
||||
chatModel.close();
|
||||
if (imageModel.image != null && !isWebDesktop) {
|
||||
savePreference(id, cursorModel.x, cursorModel.y, canvasModel.x,
|
||||
await savePreference(id, cursorModel.x, cursorModel.y, canvasModel.x,
|
||||
canvasModel.y, canvasModel.scale, ffiModel.pi.currentDisplay);
|
||||
}
|
||||
bind.sessionClose(id: id);
|
||||
@ -1085,8 +1085,8 @@ class PeerInfo {
|
||||
List<Display> displays = [];
|
||||
}
|
||||
|
||||
void savePreference(String id, double xCursor, double yCursor, double xCanvas,
|
||||
double yCanvas, double scale, int currentDisplay) async {
|
||||
Future<void> savePreference(String id, double xCursor, double yCursor,
|
||||
double xCanvas, double yCanvas, double scale, int currentDisplay) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final p = Map<String, dynamic>();
|
||||
p['xCursor'] = xCursor;
|
||||
|
@ -62,7 +62,7 @@ dependencies:
|
||||
desktop_multi_window:
|
||||
git:
|
||||
url: https://github.com/Kingtous/rustdesk_desktop_multi_window
|
||||
ref: c7d97cb6615f2def34f8bad4def01af9e0077beb
|
||||
ref: 7b72918710921f5fe79eae2dbaa411a66f5dfb45
|
||||
# bitsdojo_window: ^0.1.2
|
||||
freezed_annotation: ^2.0.3
|
||||
tray_manager: 0.1.7
|
||||
|
Loading…
Reference in New Issue
Block a user