Merge pull request #5331 from dignow/fix/save_peer_window_pos

fix saving peer window pos
This commit is contained in:
RustDesk
2023-08-11 08:04:57 +08:00
committed by GitHub
11 changed files with 61 additions and 51 deletions

View File

@@ -1422,7 +1422,7 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
debugPrint(
"Saving frame: $windowId: ${pos.width}/${pos.height}, offset:${pos.offsetWidth}/${pos.offsetHeight}");
await bind.setLocalFlutterConfig(
await bind.setLocalFlutterOption(
k: kWindowPrefix + type.name, v: pos.toString());
if (type == WindowType.RemoteDesktop && windowId != null) {
@@ -1436,7 +1436,7 @@ Future _saveSessionWindowPosition(
windowId, kWindowEventGetRemoteList, null);
if (remoteList != null) {
for (final peerId in remoteList.split(',')) {
bind.sessionSetFlutterConfigByPeerId(
bind.mainSetPeerFlutterOptionSync(
id: peerId, k: kWindowPrefix + windowType.name, v: pos.toString());
}
}
@@ -1551,15 +1551,15 @@ Future<bool> restoreWindowPosition(WindowType type,
// then we may need to get the position by reading the peer config.
// Because the session may not be read at this time.
if (desktopType == DesktopType.main) {
pos = bind.mainGetPeerFlutterConfigSync(
pos = bind.mainGetPeerFlutterOptionSync(
id: peerId, k: kWindowPrefix + type.name);
} else {
pos = await bind.sessionGetFlutterConfigByPeerId(
pos = await bind.sessionGetFlutterOptionByPeerId(
id: peerId, k: kWindowPrefix + type.name);
}
isRemotePeerPos = pos != null;
}
pos ??= bind.getLocalFlutterConfig(k: kWindowPrefix + type.name);
pos ??= bind.getLocalFlutterOption(k: kWindowPrefix + type.name);
var lpos = LastWindowPosition.loadFromString(pos);
if (lpos == null) {

View File

@@ -64,7 +64,7 @@ class _PeerTabPageState extends State<PeerTabPage>
@override
void initState() {
final uiType = bind.getLocalFlutterConfig(k: 'peer-card-ui-type');
final uiType = bind.getLocalFlutterOption(k: 'peer-card-ui-type');
if (uiType != '') {
peerCardUiType.value = int.parse(uiType) == PeerUiType.list.index
? PeerUiType.list
@@ -174,7 +174,7 @@ class _PeerTabPageState extends State<PeerTabPage>
).paddingSymmetric(horizontal: 4),
onTap: () async {
await handleTabSelection(t);
await bind.setLocalFlutterConfig(
await bind.setLocalFlutterOption(
k: 'peer-tab-index', v: t.toString());
},
onHover: (value) => hover.value = value,
@@ -244,7 +244,7 @@ class _PeerTabPageState extends State<PeerTabPage>
onTap: () async {
final type = types.elementAt(
peerCardUiType.value == types.elementAt(0) ? 1 : 0);
await bind.setLocalFlutterConfig(
await bind.setLocalFlutterOption(
k: 'peer-card-ui-type', v: type.index.toString());
peerCardUiType.value = type;
},
@@ -562,7 +562,7 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
void initState() {
if (!PeerSortType.values.contains(peerSort.value)) {
peerSort.value = PeerSortType.remoteId;
bind.setLocalFlutterConfig(
bind.setLocalFlutterOption(
k: "peer-sorting",
v: peerSort.value,
);
@@ -592,7 +592,7 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
dense: true, (String? v) async {
if (v != null) {
peerSort.value = v;
await bind.setLocalFlutterConfig(
await bind.setLocalFlutterOption(
k: "peer-sorting",
v: peerSort.value,
);

View File

@@ -41,7 +41,7 @@ class LoadEvent {
final peerSearchText = "".obs;
/// for peer sort, global obs value
final peerSort = bind.getLocalFlutterConfig(k: 'peer-sorting').obs;
final peerSort = bind.getLocalFlutterOption(k: 'peer-sorting').obs;
// list for listener
final obslist = [peerSearchText, peerSort].obs;
@@ -264,7 +264,7 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
// fallback to id sorting
if (!PeerSortType.values.contains(sortedBy)) {
sortedBy = PeerSortType.remoteId;
bind.setLocalFlutterConfig(
bind.setLocalFlutterOption(
k: "peer-sorting",
v: sortedBy,
);

View File

@@ -36,7 +36,7 @@ class ToolbarState {
late RxBool _pin;
ToolbarState() {
final s = bind.getLocalFlutterConfig(k: kStoreKey);
final s = bind.getLocalFlutterOption(k: kStoreKey);
if (s.isEmpty) {
_initSet(false, false);
return;
@@ -89,7 +89,7 @@ class ToolbarState {
}
_savePin() async {
bind.setLocalFlutterConfig(
bind.setLocalFlutterOption(
k: kStoreKey, v: jsonEncode({'pin': _pin.value}));
}

View File

@@ -1863,14 +1863,14 @@ Future<void> setCanvasConfig(
p['yCanvas'] = yCanvas;
p['scale'] = scale;
p['currentDisplay'] = currentDisplay;
await bind.sessionSetFlutterConfig(
await bind.sessionSetFlutterOption(
sessionId: sessionId, k: canvasKey, v: jsonEncode(p));
}
Future<Map<String, dynamic>?> getCanvasConfig(SessionID sessionId) async {
if (!isWebDesktop) return null;
var p =
await bind.sessionGetFlutterConfig(sessionId: sessionId, k: canvasKey);
await bind.sessionGetFlutterOption(sessionId: sessionId, k: canvasKey);
if (p == null || p.isEmpty) return null;
try {
Map<String, dynamic> m = json.decode(p);

View File

@@ -51,7 +51,7 @@ class PeerTabModel with ChangeNotifier {
PeerTabModel(this.parent) {
// init currentTab
_currentTab =
int.tryParse(bind.getLocalFlutterConfig(k: 'peer-tab-index')) ?? 0;
int.tryParse(bind.getLocalFlutterOption(k: 'peer-tab-index')) ?? 0;
if (_currentTab < 0 || _currentTab >= tabNames.length) {
_currentTab = 0;
}