diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 7fd80d863..545b8a238 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -1494,7 +1494,7 @@ Future saveWindowPosition(WindowType type, {int? windowId}) async { late Offset position; late Size sz; late bool isMaximized; - bool isFullscreen = stateGlobal.fullscreen || + bool isFullscreen = stateGlobal.fullscreen.isTrue || (Platform.isMacOS && stateGlobal.closeOnFullscreen); setFrameIfMaximized() { if (isMaximized) { @@ -2710,7 +2710,7 @@ tryMoveToScreenAndSetFullscreen(Rect? screenRect) async { final curFrame = await wc.getFrame(); final frame = Rect.fromLTWH(screenRect.left + 30, screenRect.top + 30, 600, 400); - if (stateGlobal.fullscreen && + if (stateGlobal.fullscreen.isTrue && curFrame.left <= frame.left && curFrame.top <= frame.top && curFrame.width >= frame.width && diff --git a/flutter/lib/consts.dart b/flutter/lib/consts.dart index 9f0a5b56f..e4d777ccb 100644 --- a/flutter/lib/consts.dart +++ b/flutter/lib/consts.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_hbb/common.dart'; import 'package:flutter_hbb/models/state_model.dart'; +import 'package:get/get.dart'; const double kDesktopRemoteTabBarHeight = 28.0; const int kInvalidWindowId = -1; @@ -88,7 +89,7 @@ const double kDesktopFileTransferHeaderHeight = 25.0; EdgeInsets get kDragToResizeAreaPadding => !kUseCompatibleUiMode && Platform.isLinux - ? stateGlobal.fullscreen || stateGlobal.isMaximized.value + ? stateGlobal.fullscreen.isTrue || stateGlobal.isMaximized.value ? EdgeInsets.zero : EdgeInsets.all(5.0) : EdgeInsets.zero; diff --git a/flutter/lib/desktop/widgets/remote_toolbar.dart b/flutter/lib/desktop/widgets/remote_toolbar.dart index 4065ebfb2..7439ed6c8 100644 --- a/flutter/lib/desktop/widgets/remote_toolbar.dart +++ b/flutter/lib/desktop/widgets/remote_toolbar.dart @@ -351,7 +351,6 @@ class _RemoteToolbarState extends State { int get windowId => stateGlobal.windowId; - bool get isFullscreen => stateGlobal.fullscreen; void _setFullscreen(bool v) { stateGlobal.setFullscreen(v); setState(() {}); @@ -797,7 +796,7 @@ class ScreenAdjustor { required this.cbExitFullscreen, }); - bool get isFullscreen => stateGlobal.fullscreen; + bool get isFullscreen => stateGlobal.fullscreen.isTrue; int get windowId => stateGlobal.windowId; adjustWindow(BuildContext context) { @@ -951,7 +950,6 @@ class _DisplayMenuState extends State<_DisplayMenu> { cbExitFullscreen: () => widget.setFullscreen(false), ); - bool get isFullscreen => stateGlobal.fullscreen; int get windowId => stateGlobal.windowId; Map get perms => widget.ffi.ffiModel.permissions; PeerInfo get pi => widget.ffi.ffiModel.pi; @@ -2060,21 +2058,21 @@ class _DraggableShowHideState extends State<_DraggableShowHide> { mainAxisSize: MainAxisSize.min, children: [ _buildDraggable(context), - TextButton( + Obx(()=>TextButton( onPressed: () { - widget.setFullscreen(!isFullscreen); + widget.setFullscreen(!isFullscreen.value); setState(() {}); }, child: Tooltip( - message: translate(isFullscreen ? 'Exit Fullscreen' : 'Fullscreen'), + message: translate(isFullscreen.isTrue ? 'Exit Fullscreen' : 'Fullscreen'), child: Icon( - isFullscreen ? Icons.fullscreen_exit : Icons.fullscreen, + isFullscreen.isTrue ? Icons.fullscreen_exit : Icons.fullscreen, size: iconSize, ), ), - ), + )), Offstage( - offstage: !isFullscreen, + offstage: !isFullscreen.value, child: TextButton( onPressed: () => widget.setMinimize(), child: Tooltip( diff --git a/flutter/lib/models/state_model.dart b/flutter/lib/models/state_model.dart index e6744ff77..82176c1a0 100644 --- a/flutter/lib/models/state_model.dart +++ b/flutter/lib/models/state_model.dart @@ -11,7 +11,7 @@ enum SvcStatus { notReady, connecting, ready } class StateGlobal { int _windowId = -1; bool grabKeyboard = false; - bool _fullscreen = false; + RxBool _fullscreen = false.obs; bool _isMinimized = false; final RxBool isMaximized = false.obs; final RxBool _showTabBar = true.obs; @@ -26,9 +26,9 @@ class StateGlobal { final Map> _lastResolutionGroupValues = {}; int get windowId => _windowId; - bool get fullscreen => _fullscreen; + RxBool get fullscreen => _fullscreen; bool get isMinimized => _isMinimized; - double get tabBarHeight => fullscreen ? 0 : kDesktopRemoteTabBarHeight; + double get tabBarHeight => fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight; RxBool get showTabBar => _showTabBar; RxDouble get resizeEdgeSize => _resizeEdgeSize; RxDouble get windowBorderWidth => _windowBorderWidth; @@ -51,7 +51,7 @@ class StateGlobal { setWindowId(int id) => _windowId = id; setMaximized(bool v) { - if (!_fullscreen) { + if (!_fullscreen.isTrue) { if (isMaximized.value != v) { isMaximized.value = v; _resizeEdgeSize.value = @@ -66,20 +66,20 @@ class StateGlobal { setMinimized(bool v) => _isMinimized = v; setFullscreen(bool v, {bool procWnd = true}) { - if (_fullscreen != v) { - _fullscreen = v; - _showTabBar.value = !_fullscreen; - _resizeEdgeSize.value = fullscreen + if (_fullscreen.value != v) { + _fullscreen.value = v; + _showTabBar.value = !_fullscreen.value; + _resizeEdgeSize.value = fullscreen.isTrue ? kFullScreenEdgeSize : isMaximized.isTrue ? kMaximizeEdgeSize : kWindowEdgeSize; print( "fullscreen: $fullscreen, resizeEdgeSize: ${_resizeEdgeSize.value}"); - _windowBorderWidth.value = fullscreen ? 0 : kWindowBorderWidth; + _windowBorderWidth.value = fullscreen.isTrue ? 0 : kWindowBorderWidth; if (procWnd) { final wc = WindowController.fromWindowId(windowId); - wc.setFullscreen(_fullscreen).then((_) { + wc.setFullscreen(_fullscreen.isTrue).then((_) { // https://github.com/leanflutter/window_manager/issues/131#issuecomment-1111587982 if (Platform.isWindows && !v) { Future.delayed(Duration.zero, () async {