mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-05-11 18:36:11 +02:00
fix: restore window, on connection (#8129)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
7da09f6296
commit
1efce51222
8 changed files with 16 additions and 46 deletions
|
@ -1567,8 +1567,7 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
|
||||||
late Offset position;
|
late Offset position;
|
||||||
late Size sz;
|
late Size sz;
|
||||||
late bool isMaximized;
|
late bool isMaximized;
|
||||||
bool isFullscreen = stateGlobal.fullscreen.isTrue ||
|
bool isFullscreen = stateGlobal.fullscreen.isTrue;
|
||||||
(isMacOS && stateGlobal.closeOnFullscreen == true);
|
|
||||||
setPreFrame() {
|
setPreFrame() {
|
||||||
final pos = bind.getLocalFlutterOption(k: windowFramePrefix + type.name);
|
final pos = bind.getLocalFlutterOption(k: windowFramePrefix + type.name);
|
||||||
var lpos = LastWindowPosition.loadFromString(pos);
|
var lpos = LastWindowPosition.loadFromString(pos);
|
||||||
|
@ -1890,7 +1889,6 @@ Future<bool> restoreWindowPosition(WindowType type,
|
||||||
}
|
}
|
||||||
if (lpos.isFullscreen == true) {
|
if (lpos.isFullscreen == true) {
|
||||||
if (!isMacOS) {
|
if (!isMacOS) {
|
||||||
stateGlobal.setFullscreen(false);
|
|
||||||
await restoreFrame();
|
await restoreFrame();
|
||||||
}
|
}
|
||||||
// An duration is needed to avoid the window being restored after fullscreen.
|
// An duration is needed to avoid the window being restored after fullscreen.
|
||||||
|
@ -2906,10 +2904,10 @@ openMonitorInNewTabOrWindow(int i, String peerId, PeerInfo pi,
|
||||||
|
|
||||||
setNewConnectWindowFrame(int windowId, String peerId, Rect? screenRect) async {
|
setNewConnectWindowFrame(int windowId, String peerId, Rect? screenRect) async {
|
||||||
if (screenRect == null) {
|
if (screenRect == null) {
|
||||||
restoreWindowPosition(WindowType.RemoteDesktop,
|
await restoreWindowPosition(WindowType.RemoteDesktop,
|
||||||
windowId: windowId, peerId: peerId);
|
windowId: windowId, peerId: peerId);
|
||||||
} else {
|
} else {
|
||||||
tryMoveToScreenAndSetFullscreen(screenRect);
|
await tryMoveToScreenAndSetFullscreen(screenRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -350,15 +350,6 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||||
|
|
||||||
void onRemoveId(String id) async {
|
void onRemoveId(String id) async {
|
||||||
if (tabController.state.value.tabs.isEmpty) {
|
if (tabController.state.value.tabs.isEmpty) {
|
||||||
if (stateGlobal.fullscreen.isTrue) {
|
|
||||||
if (isLinux) {
|
|
||||||
// If the window is left fullscreen and then reuse, the frame state will be incorrect when exit fullscreen the next time.
|
|
||||||
// State `fullscreen -> hide -> show -> exit fullscreen`, then the window will be maximized and overlapped.
|
|
||||||
// No idea how the strange state comes, just a **workaround**.
|
|
||||||
await WindowController.fromWindowId(windowId()).setFullscreen(false);
|
|
||||||
}
|
|
||||||
stateGlobal.setFullscreen(false, procWnd: false);
|
|
||||||
}
|
|
||||||
// Keep calling until the window status is hidden.
|
// Keep calling until the window status is hidden.
|
||||||
//
|
//
|
||||||
// Workaround for Windows:
|
// Workaround for Windows:
|
||||||
|
@ -424,16 +415,16 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||||
final display = args['display'];
|
final display = args['display'];
|
||||||
final displays = args['displays'];
|
final displays = args['displays'];
|
||||||
final screenRect = parseParamScreenRect(args);
|
final screenRect = parseParamScreenRect(args);
|
||||||
windowOnTop(windowId());
|
Future.delayed(Duration.zero, () async {
|
||||||
setNewConnectWindowFrame(windowId(), id!, screenRect);
|
if (stateGlobal.fullscreen.isTrue) {
|
||||||
if (tabController.length == 0) {
|
await WindowController.fromWindowId(windowId()).setFullscreen(false);
|
||||||
// Show the hidden window.
|
stateGlobal.setFullscreen(false, procWnd: false);
|
||||||
if (isMacOS && stateGlobal.closeOnFullscreen == true) {
|
|
||||||
stateGlobal.setFullscreen(true);
|
|
||||||
}
|
}
|
||||||
// Reset the state
|
await setNewConnectWindowFrame(windowId(), id!, screenRect);
|
||||||
stateGlobal.closeOnFullscreen = null;
|
Future.delayed(Duration(milliseconds: isWindows ? 100 : 0), () async {
|
||||||
}
|
await windowOnTop(windowId());
|
||||||
|
});
|
||||||
|
});
|
||||||
ConnectionTypeState.init(id);
|
ConnectionTypeState.init(id);
|
||||||
_toolbarState.setShow(
|
_toolbarState.setShow(
|
||||||
bind.mainGetUserDefaultOption(key: kOptionCollapseToolbar) != 'Y');
|
bind.mainGetUserDefaultOption(key: kOptionCollapseToolbar) != 'Y');
|
||||||
|
|
|
@ -641,14 +641,12 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||||
}
|
}
|
||||||
// macOS specific workaround, the window is not hiding when in fullscreen.
|
// macOS specific workaround, the window is not hiding when in fullscreen.
|
||||||
if (isMacOS && await windowManager.isFullScreen()) {
|
if (isMacOS && await windowManager.isFullScreen()) {
|
||||||
stateGlobal.closeOnFullscreen ??= true;
|
|
||||||
await windowManager.setFullScreen(false);
|
await windowManager.setFullScreen(false);
|
||||||
await macOSWindowClose(
|
await macOSWindowClose(
|
||||||
() async => await windowManager.isFullScreen(),
|
() async => await windowManager.isFullScreen(),
|
||||||
mainWindowClose,
|
mainWindowClose,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
stateGlobal.closeOnFullscreen ??= false;
|
|
||||||
await mainWindowClose();
|
await mainWindowClose();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -660,7 +658,6 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||||
|
|
||||||
if (await widget.onClose?.call() ?? true) {
|
if (await widget.onClose?.call() ?? true) {
|
||||||
if (await controller.isFullScreen()) {
|
if (await controller.isFullScreen()) {
|
||||||
stateGlobal.closeOnFullscreen ??= true;
|
|
||||||
await controller.setFullscreen(false);
|
await controller.setFullscreen(false);
|
||||||
stateGlobal.setFullscreen(false, procWnd: false);
|
stateGlobal.setFullscreen(false, procWnd: false);
|
||||||
await macOSWindowClose(
|
await macOSWindowClose(
|
||||||
|
@ -668,7 +665,6 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||||
() async => await notMainWindowClose(controller),
|
() async => await notMainWindowClose(controller),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
stateGlobal.closeOnFullscreen ??= false;
|
|
||||||
await notMainWindowClose(controller);
|
await notMainWindowClose(controller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ class StateGlobal {
|
||||||
final RxDouble _windowBorderWidth = RxDouble(kWindowBorderWidth);
|
final RxDouble _windowBorderWidth = RxDouble(kWindowBorderWidth);
|
||||||
final RxBool showRemoteToolBar = false.obs;
|
final RxBool showRemoteToolBar = false.obs;
|
||||||
final svcStatus = SvcStatus.notReady.obs;
|
final svcStatus = SvcStatus.notReady.obs;
|
||||||
// Only used for macOS
|
|
||||||
bool? closeOnFullscreen;
|
|
||||||
final RxBool isFocused = false.obs;
|
final RxBool isFocused = false.obs;
|
||||||
|
|
||||||
String _inputSource = '';
|
String _inputSource = '';
|
||||||
|
|
|
@ -174,7 +174,9 @@ class RustDeskMultiWindowManager {
|
||||||
windowId: windowId, peerId: remoteId);
|
windowId: windowId, peerId: remoteId);
|
||||||
}
|
}
|
||||||
await DesktopMultiWindow.invokeMethod(windowId, methodName, msg);
|
await DesktopMultiWindow.invokeMethod(windowId, methodName, msg);
|
||||||
WindowController.fromWindowId(windowId).show();
|
if (methodName != kWindowEventNewRemoteDesktop) {
|
||||||
|
WindowController.fromWindowId(windowId).show();
|
||||||
|
}
|
||||||
registerActiveWindow(windowId);
|
registerActiveWindow(windowId);
|
||||||
return MultiWindowCallResult(windowId, null);
|
return MultiWindowCallResult(windowId, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,12 +203,6 @@ class RustdeskImpl {
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> sessionGetFlutterOptionByPeerId(
|
|
||||||
{required String id, required String k, dynamic hint}) {
|
|
||||||
return Future(
|
|
||||||
() => js.context.callMethod('getByName', ['option:flutter:peer', k]));
|
|
||||||
}
|
|
||||||
|
|
||||||
int getNextTextureKey({dynamic hint}) {
|
int getNextTextureKey({dynamic hint}) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ packages:
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: HEAD
|
ref: HEAD
|
||||||
resolved-ref: ef03db52a20a7899da135d694c071fa3866c8fb1
|
resolved-ref: 965b6ceba095b120c37c368abc2e4dbc8a71e09c
|
||||||
url: "https://github.com/rustdesk-org/rustdesk_desktop_multi_window"
|
url: "https://github.com/rustdesk-org/rustdesk_desktop_multi_window"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0"
|
version: "0.1.0"
|
||||||
|
|
|
@ -278,15 +278,6 @@ pub fn session_set_flutter_option(session_id: SessionID, k: String, v: String) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is only used for the default connection session.
|
|
||||||
pub fn session_get_flutter_option_by_peer_id(id: String, k: String) -> Option<String> {
|
|
||||||
if let Some(session) = sessions::get_session_by_peer_id(id, ConnType::DEFAULT_CONN) {
|
|
||||||
Some(session.get_flutter_option(k))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_next_texture_key() -> SyncReturn<i32> {
|
pub fn get_next_texture_key() -> SyncReturn<i32> {
|
||||||
let k = TEXTURE_RENDER_KEY.fetch_add(1, Ordering::SeqCst) + 1;
|
let k = TEXTURE_RENDER_KEY.fetch_add(1, Ordering::SeqCst) + 1;
|
||||||
SyncReturn(k)
|
SyncReturn(k)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue