opt: move the resize area out of the flutter view

This commit is contained in:
Kingtous 2023-02-27 12:01:22 +08:00
parent 6048efe02b
commit b6c3c74286
7 changed files with 41 additions and 7 deletions

View File

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/models/state_model.dart';
const double kDesktopRemoteTabBarHeight = 28.0;
const int kMainWindowId = 0;
@ -58,6 +59,11 @@ const double kDesktopFileTransferMaximumWidth = 300;
const double kDesktopFileTransferRowHeight = 30.0;
const double kDesktopFileTransferHeaderHeight = 25.0;
EdgeInsets get kDragToResizeAreaPadding => Platform.isLinux
? stateGlobal.fullscreen || stateGlobal.maximize
? EdgeInsets.zero
: EdgeInsets.all(4.0)
: EdgeInsets.zero;
// https://en.wikipedia.org/wiki/Non-breaking_space
const int $nbsp = 0x00A0;
@ -79,6 +85,7 @@ const kDefaultScrollAmountMultiplier = 5.0;
const kDefaultScrollDuration = Duration(milliseconds: 50);
const kDefaultMouseWheelThrottleDuration = Duration(milliseconds: 50);
const kFullScreenEdgeSize = 0.0;
const kMaximizeEdgeSize = 0.0;
var kWindowEdgeSize = Platform.isWindows ? 1.0 : 5.0;
const kWindowBorderWidth = 1.0;
const kDesktopMenuPadding = EdgeInsets.only(left: 12.0, right: 3.0);

View File

@ -109,10 +109,12 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
);
return Platform.isMacOS
? tabWidget
: SubWindowDragToResizeArea(
: Obx(
() => SubWindowDragToResizeArea(
child: tabWidget,
resizeEdgeSize: stateGlobal.resizeEdgeSize.value,
windowId: stateGlobal.windowId,
),
);
}

View File

@ -210,6 +210,8 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
: Obx(() => SubWindowDragToResizeArea(
key: contentKey,
child: tabWidget,
// Specially configured for a better resize area and remote control.
childPadding: kDragToResizeAreaPadding,
resizeEdgeSize: stateGlobal.resizeEdgeSize.value,
windowId: stateGlobal.windowId,
));

View File

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/desktop/pages/remote_tab_page.dart';
@ -26,6 +28,9 @@ class DesktopRemoteScreen extends StatelessWidget {
ChangeNotifierProvider.value(value: gFFI.canvasModel),
],
child: Scaffold(
// Set transparent background for padding the resize area out of the flutter view.
// This allows the wallpaper goes through our resize area. (Linux only now).
backgroundColor: Platform.isLinux ? Colors.transparent : null,
body: ConnectionTabPage(
params: params,
),

View File

@ -523,12 +523,18 @@ class WindowActionPanelState extends State<WindowActionPanel>
super.dispose();
}
void _setMaximize(bool maximize) {
stateGlobal.setMaximize(maximize);
setState(() {});
}
@override
void onWindowMaximize() {
// catch maximize from system
if (!widget.isMaximized.value) {
widget.isMaximized.value = true;
}
_setMaximize(true);
super.onWindowMaximize();
}
@ -538,6 +544,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
if (widget.isMaximized.value) {
widget.isMaximized.value = false;
}
_setMaximize(false);
super.onWindowUnmaximize();
}

View File

@ -9,8 +9,10 @@ import '../consts.dart';
class StateGlobal {
int _windowId = -1;
bool _fullscreen = false;
bool _maximize = false;
bool grabKeyboard = false;
final RxBool _showTabBar = true.obs;
final RxBool _showResizeEdge = true.obs;
final RxDouble _resizeEdgeSize = RxDouble(kWindowEdgeSize);
final RxDouble _windowBorderWidth = RxDouble(kWindowBorderWidth);
final RxBool showRemoteMenuBar = false.obs;
@ -18,12 +20,21 @@ class StateGlobal {
int get windowId => _windowId;
bool get fullscreen => _fullscreen;
bool get maximize => _maximize;
double get tabBarHeight => fullscreen ? 0 : kDesktopRemoteTabBarHeight;
RxBool get showTabBar => _showTabBar;
RxDouble get resizeEdgeSize => _resizeEdgeSize;
RxDouble get windowBorderWidth => _windowBorderWidth;
setWindowId(int id) => _windowId = id;
setMaximize(bool v) {
if (_maximize != v) {
print("set maximize");
_maximize = v;
_resizeEdgeSize.value =
_maximize ? kMaximizeEdgeSize : kWindowEdgeSize;
}
}
setFullscreen(bool v) {
if (_fullscreen != v) {
_fullscreen = v;

View File

@ -59,7 +59,7 @@ dependencies:
desktop_multi_window:
git:
url: https://github.com/Kingtous/rustdesk_desktop_multi_window
ref: f37357ed98a10717576eb9ed8413e92b2ec5d13a
ref: c717159ea8fc0b9c6b4ac50110efc1dfd3c1ba7a
freezed_annotation: ^2.0.3
flutter_custom_cursor: ^0.0.4
window_size:
@ -76,7 +76,7 @@ dependencies:
file_picker: ^5.1.0
flutter_svg: ^1.1.5
flutter_improved_scrolling:
# currently, we use flutter 3.0.5 for windows build, latest for other builds.
# currently, we use flutter 3.7.0+.
#
# for flutter 3.0.5, please use official version(just comment code below).
# if build rustdesk by flutter >=3.3, please use our custom pub below (uncomment code below).