mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-23 19:49:05 +08:00
fix: web fullscreen (#9577)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
560c1effe8
commit
83aba804d0
@ -436,6 +436,7 @@ class _RemoteToolbarState extends State<RemoteToolbar> {
|
||||
shadowColor: MyTheme.color(context).shadow,
|
||||
borderRadius: borderRadius,
|
||||
child: _DraggableShowHide(
|
||||
id: widget.id,
|
||||
sessionId: widget.ffi.sessionId,
|
||||
dragging: _dragging,
|
||||
fractionX: _fractionX,
|
||||
@ -2218,6 +2219,7 @@ class RdoMenuButton<T> extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _DraggableShowHide extends StatefulWidget {
|
||||
final String id;
|
||||
final SessionID sessionId;
|
||||
final RxDouble fractionX;
|
||||
final RxBool dragging;
|
||||
@ -2229,6 +2231,7 @@ class _DraggableShowHide extends StatefulWidget {
|
||||
|
||||
const _DraggableShowHide({
|
||||
Key? key,
|
||||
required this.id,
|
||||
required this.sessionId,
|
||||
required this.fractionX,
|
||||
required this.dragging,
|
||||
@ -2364,6 +2367,24 @@ class _DraggableShowHideState extends State<_DraggableShowHide> {
|
||||
),
|
||||
))),
|
||||
),
|
||||
if (isWebDesktop)
|
||||
Obx(() {
|
||||
if (show.isTrue) {
|
||||
return Offstage();
|
||||
} else {
|
||||
return TextButton(
|
||||
onPressed: () => closeConnection(id: widget.id),
|
||||
child: Tooltip(
|
||||
message: translate('Close'),
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
size: iconSize,
|
||||
color: _ToolbarTheme.redColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
})
|
||||
],
|
||||
);
|
||||
return TextButtonTheme(
|
||||
|
@ -48,6 +48,12 @@ class PlatformFFI {
|
||||
|
||||
static get isMain => instance._appType == kAppTypeMain;
|
||||
|
||||
static String getByName(String name, [String arg = '']) {
|
||||
return '';
|
||||
}
|
||||
|
||||
static void setByName(String name, [String value = '']) {}
|
||||
|
||||
static Future<String> getVersion() async {
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
return packageInfo.version;
|
||||
@ -276,4 +282,6 @@ class PlatformFFI {
|
||||
void syncAndroidServiceAppDirConfigPath() {
|
||||
invokeMethod(AndroidChannel.kSyncAppDirConfigPath, _dir);
|
||||
}
|
||||
|
||||
void setFullscreenCallback(void Function(bool) fun) {}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'native_model.dart' if (dart.library.html) 'web_model.dart';
|
||||
|
||||
import '../consts.dart';
|
||||
import './platform_model.dart';
|
||||
@ -73,27 +74,47 @@ class StateGlobal {
|
||||
if (_fullscreen.value != v) {
|
||||
_fullscreen.value = v;
|
||||
_showTabBar.value = !_fullscreen.value;
|
||||
refreshResizeEdgeSize();
|
||||
print(
|
||||
"fullscreen: $fullscreen, resizeEdgeSize: ${_resizeEdgeSize.value}");
|
||||
_windowBorderWidth.value = fullscreen.isTrue ? 0 : kWindowBorderWidth;
|
||||
if (procWnd) {
|
||||
final wc = WindowController.fromWindowId(windowId);
|
||||
wc.setFullscreen(_fullscreen.isTrue).then((_) {
|
||||
// https://github.com/leanflutter/window_manager/issues/131#issuecomment-1111587982
|
||||
if (isWindows && !v) {
|
||||
Future.delayed(Duration.zero, () async {
|
||||
final frame = await wc.getFrame();
|
||||
final newRect = Rect.fromLTWH(
|
||||
frame.left, frame.top, frame.width + 1, frame.height + 1);
|
||||
await wc.setFrame(newRect);
|
||||
});
|
||||
}
|
||||
});
|
||||
if (isWebDesktop) {
|
||||
procFullscreenWeb();
|
||||
} else {
|
||||
procFullscreenNative(procWnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
procFullscreenWeb() {
|
||||
final isFullscreen = PlatformFFI.getByName('fullscreen') == 'Y';
|
||||
String fullscreenValue = '';
|
||||
if (isFullscreen && _fullscreen.isFalse) {
|
||||
fullscreenValue = 'N';
|
||||
} else if (!isFullscreen && fullscreen.isTrue) {
|
||||
fullscreenValue = 'Y';
|
||||
}
|
||||
if (fullscreenValue.isNotEmpty) {
|
||||
PlatformFFI.setByName('fullscreen', fullscreenValue);
|
||||
}
|
||||
}
|
||||
|
||||
procFullscreenNative(bool procWnd) {
|
||||
refreshResizeEdgeSize();
|
||||
print("fullscreen: $fullscreen, resizeEdgeSize: ${_resizeEdgeSize.value}");
|
||||
_windowBorderWidth.value = fullscreen.isTrue ? 0 : kWindowBorderWidth;
|
||||
if (procWnd) {
|
||||
final wc = WindowController.fromWindowId(windowId);
|
||||
wc.setFullscreen(_fullscreen.isTrue).then((_) {
|
||||
// https://github.com/leanflutter/window_manager/issues/131#issuecomment-1111587982
|
||||
if (isWindows && _fullscreen.isFalse) {
|
||||
Future.delayed(Duration.zero, () async {
|
||||
final frame = await wc.getFrame();
|
||||
final newRect = Rect.fromLTWH(
|
||||
frame.left, frame.top, frame.width + 1, frame.height + 1);
|
||||
await wc.setFrame(newRect);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
refreshResizeEdgeSize() => _resizeEdgeSize.value = fullscreen.isTrue
|
||||
? kFullScreenEdgeSize
|
||||
: isMaximized.isTrue
|
||||
@ -112,7 +133,13 @@ class StateGlobal {
|
||||
_inputSource = bind.mainGetInputSource();
|
||||
}
|
||||
|
||||
StateGlobal._();
|
||||
StateGlobal._() {
|
||||
if (isWebDesktop) {
|
||||
platformFFI.setFullscreenCallback((v) {
|
||||
_fullscreen.value = v;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static final StateGlobal instance = StateGlobal._();
|
||||
}
|
||||
|
@ -166,4 +166,10 @@ class PlatformFFI {
|
||||
|
||||
// just for compilation
|
||||
void syncAndroidServiceAppDirConfigPath() {}
|
||||
|
||||
void setFullscreenCallback(void Function(bool) fun) {
|
||||
context["onFullscreenChanged"] = (bool v) {
|
||||
fun(v);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user