fix, use RxBool to sync fullscreen state (remote toolbar)
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
parent
f1d3a553d1
commit
f9f463e799
@ -1494,7 +1494,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 ||
|
bool isFullscreen = stateGlobal.fullscreen.isTrue ||
|
||||||
(Platform.isMacOS && stateGlobal.closeOnFullscreen);
|
(Platform.isMacOS && stateGlobal.closeOnFullscreen);
|
||||||
setFrameIfMaximized() {
|
setFrameIfMaximized() {
|
||||||
if (isMaximized) {
|
if (isMaximized) {
|
||||||
@ -2710,7 +2710,7 @@ tryMoveToScreenAndSetFullscreen(Rect? screenRect) async {
|
|||||||
final curFrame = await wc.getFrame();
|
final curFrame = await wc.getFrame();
|
||||||
final frame =
|
final frame =
|
||||||
Rect.fromLTWH(screenRect.left + 30, screenRect.top + 30, 600, 400);
|
Rect.fromLTWH(screenRect.left + 30, screenRect.top + 30, 600, 400);
|
||||||
if (stateGlobal.fullscreen &&
|
if (stateGlobal.fullscreen.isTrue &&
|
||||||
curFrame.left <= frame.left &&
|
curFrame.left <= frame.left &&
|
||||||
curFrame.top <= frame.top &&
|
curFrame.top <= frame.top &&
|
||||||
curFrame.width >= frame.width &&
|
curFrame.width >= frame.width &&
|
||||||
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hbb/common.dart';
|
import 'package:flutter_hbb/common.dart';
|
||||||
import 'package:flutter_hbb/models/state_model.dart';
|
import 'package:flutter_hbb/models/state_model.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
const double kDesktopRemoteTabBarHeight = 28.0;
|
const double kDesktopRemoteTabBarHeight = 28.0;
|
||||||
const int kInvalidWindowId = -1;
|
const int kInvalidWindowId = -1;
|
||||||
@ -88,7 +89,7 @@ const double kDesktopFileTransferHeaderHeight = 25.0;
|
|||||||
|
|
||||||
EdgeInsets get kDragToResizeAreaPadding =>
|
EdgeInsets get kDragToResizeAreaPadding =>
|
||||||
!kUseCompatibleUiMode && Platform.isLinux
|
!kUseCompatibleUiMode && Platform.isLinux
|
||||||
? stateGlobal.fullscreen || stateGlobal.isMaximized.value
|
? stateGlobal.fullscreen.isTrue || stateGlobal.isMaximized.value
|
||||||
? EdgeInsets.zero
|
? EdgeInsets.zero
|
||||||
: EdgeInsets.all(5.0)
|
: EdgeInsets.all(5.0)
|
||||||
: EdgeInsets.zero;
|
: EdgeInsets.zero;
|
||||||
|
@ -351,7 +351,6 @@ class _RemoteToolbarState extends State<RemoteToolbar> {
|
|||||||
|
|
||||||
int get windowId => stateGlobal.windowId;
|
int get windowId => stateGlobal.windowId;
|
||||||
|
|
||||||
bool get isFullscreen => stateGlobal.fullscreen;
|
|
||||||
void _setFullscreen(bool v) {
|
void _setFullscreen(bool v) {
|
||||||
stateGlobal.setFullscreen(v);
|
stateGlobal.setFullscreen(v);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@ -797,7 +796,7 @@ class ScreenAdjustor {
|
|||||||
required this.cbExitFullscreen,
|
required this.cbExitFullscreen,
|
||||||
});
|
});
|
||||||
|
|
||||||
bool get isFullscreen => stateGlobal.fullscreen;
|
bool get isFullscreen => stateGlobal.fullscreen.isTrue;
|
||||||
int get windowId => stateGlobal.windowId;
|
int get windowId => stateGlobal.windowId;
|
||||||
|
|
||||||
adjustWindow(BuildContext context) {
|
adjustWindow(BuildContext context) {
|
||||||
@ -951,7 +950,6 @@ class _DisplayMenuState extends State<_DisplayMenu> {
|
|||||||
cbExitFullscreen: () => widget.setFullscreen(false),
|
cbExitFullscreen: () => widget.setFullscreen(false),
|
||||||
);
|
);
|
||||||
|
|
||||||
bool get isFullscreen => stateGlobal.fullscreen;
|
|
||||||
int get windowId => stateGlobal.windowId;
|
int get windowId => stateGlobal.windowId;
|
||||||
Map<String, bool> get perms => widget.ffi.ffiModel.permissions;
|
Map<String, bool> get perms => widget.ffi.ffiModel.permissions;
|
||||||
PeerInfo get pi => widget.ffi.ffiModel.pi;
|
PeerInfo get pi => widget.ffi.ffiModel.pi;
|
||||||
@ -2060,21 +2058,21 @@ class _DraggableShowHideState extends State<_DraggableShowHide> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
_buildDraggable(context),
|
_buildDraggable(context),
|
||||||
TextButton(
|
Obx(()=>TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
widget.setFullscreen(!isFullscreen);
|
widget.setFullscreen(!isFullscreen.value);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
child: Tooltip(
|
child: Tooltip(
|
||||||
message: translate(isFullscreen ? 'Exit Fullscreen' : 'Fullscreen'),
|
message: translate(isFullscreen.isTrue ? 'Exit Fullscreen' : 'Fullscreen'),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
isFullscreen ? Icons.fullscreen_exit : Icons.fullscreen,
|
isFullscreen.isTrue ? Icons.fullscreen_exit : Icons.fullscreen,
|
||||||
size: iconSize,
|
size: iconSize,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
)),
|
||||||
Offstage(
|
Offstage(
|
||||||
offstage: !isFullscreen,
|
offstage: !isFullscreen.value,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: () => widget.setMinimize(),
|
onPressed: () => widget.setMinimize(),
|
||||||
child: Tooltip(
|
child: Tooltip(
|
||||||
|
@ -11,7 +11,7 @@ enum SvcStatus { notReady, connecting, ready }
|
|||||||
class StateGlobal {
|
class StateGlobal {
|
||||||
int _windowId = -1;
|
int _windowId = -1;
|
||||||
bool grabKeyboard = false;
|
bool grabKeyboard = false;
|
||||||
bool _fullscreen = false;
|
RxBool _fullscreen = false.obs;
|
||||||
bool _isMinimized = false;
|
bool _isMinimized = false;
|
||||||
final RxBool isMaximized = false.obs;
|
final RxBool isMaximized = false.obs;
|
||||||
final RxBool _showTabBar = true.obs;
|
final RxBool _showTabBar = true.obs;
|
||||||
@ -26,9 +26,9 @@ class StateGlobal {
|
|||||||
final Map<String, Map<int, String?>> _lastResolutionGroupValues = {};
|
final Map<String, Map<int, String?>> _lastResolutionGroupValues = {};
|
||||||
|
|
||||||
int get windowId => _windowId;
|
int get windowId => _windowId;
|
||||||
bool get fullscreen => _fullscreen;
|
RxBool get fullscreen => _fullscreen;
|
||||||
bool get isMinimized => _isMinimized;
|
bool get isMinimized => _isMinimized;
|
||||||
double get tabBarHeight => fullscreen ? 0 : kDesktopRemoteTabBarHeight;
|
double get tabBarHeight => fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight;
|
||||||
RxBool get showTabBar => _showTabBar;
|
RxBool get showTabBar => _showTabBar;
|
||||||
RxDouble get resizeEdgeSize => _resizeEdgeSize;
|
RxDouble get resizeEdgeSize => _resizeEdgeSize;
|
||||||
RxDouble get windowBorderWidth => _windowBorderWidth;
|
RxDouble get windowBorderWidth => _windowBorderWidth;
|
||||||
@ -51,7 +51,7 @@ class StateGlobal {
|
|||||||
|
|
||||||
setWindowId(int id) => _windowId = id;
|
setWindowId(int id) => _windowId = id;
|
||||||
setMaximized(bool v) {
|
setMaximized(bool v) {
|
||||||
if (!_fullscreen) {
|
if (!_fullscreen.isTrue) {
|
||||||
if (isMaximized.value != v) {
|
if (isMaximized.value != v) {
|
||||||
isMaximized.value = v;
|
isMaximized.value = v;
|
||||||
_resizeEdgeSize.value =
|
_resizeEdgeSize.value =
|
||||||
@ -66,20 +66,20 @@ class StateGlobal {
|
|||||||
setMinimized(bool v) => _isMinimized = v;
|
setMinimized(bool v) => _isMinimized = v;
|
||||||
|
|
||||||
setFullscreen(bool v, {bool procWnd = true}) {
|
setFullscreen(bool v, {bool procWnd = true}) {
|
||||||
if (_fullscreen != v) {
|
if (_fullscreen.value != v) {
|
||||||
_fullscreen = v;
|
_fullscreen.value = v;
|
||||||
_showTabBar.value = !_fullscreen;
|
_showTabBar.value = !_fullscreen.value;
|
||||||
_resizeEdgeSize.value = fullscreen
|
_resizeEdgeSize.value = fullscreen.isTrue
|
||||||
? kFullScreenEdgeSize
|
? kFullScreenEdgeSize
|
||||||
: isMaximized.isTrue
|
: isMaximized.isTrue
|
||||||
? kMaximizeEdgeSize
|
? kMaximizeEdgeSize
|
||||||
: kWindowEdgeSize;
|
: kWindowEdgeSize;
|
||||||
print(
|
print(
|
||||||
"fullscreen: $fullscreen, resizeEdgeSize: ${_resizeEdgeSize.value}");
|
"fullscreen: $fullscreen, resizeEdgeSize: ${_resizeEdgeSize.value}");
|
||||||
_windowBorderWidth.value = fullscreen ? 0 : kWindowBorderWidth;
|
_windowBorderWidth.value = fullscreen.isTrue ? 0 : kWindowBorderWidth;
|
||||||
if (procWnd) {
|
if (procWnd) {
|
||||||
final wc = WindowController.fromWindowId(windowId);
|
final wc = WindowController.fromWindowId(windowId);
|
||||||
wc.setFullscreen(_fullscreen).then((_) {
|
wc.setFullscreen(_fullscreen.isTrue).then((_) {
|
||||||
// https://github.com/leanflutter/window_manager/issues/131#issuecomment-1111587982
|
// https://github.com/leanflutter/window_manager/issues/131#issuecomment-1111587982
|
||||||
if (Platform.isWindows && !v) {
|
if (Platform.isWindows && !v) {
|
||||||
Future.delayed(Duration.zero, () async {
|
Future.delayed(Duration.zero, () async {
|
||||||
|
Loading…
Reference in New Issue
Block a user