flutter_desktop: fix canvas size in normal and fullscreen
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
589d366327
commit
126d92bf67
@ -31,6 +31,7 @@ const kDefaultScrollDuration = Duration(milliseconds: 50);
|
||||
const kDefaultMouseWheelThrottleDuration = Duration(milliseconds: 50);
|
||||
const kFullScreenEdgeSize = 0.0;
|
||||
var kWindowEdgeSize = Platform.isWindows ? 1.0 : 5.0;
|
||||
const kWindowBorderWidth = 1.0;
|
||||
|
||||
const kInvalidValueStr = "InvalidValueStr";
|
||||
|
||||
|
@ -27,10 +27,12 @@ class RemotePage extends StatefulWidget {
|
||||
Key? key,
|
||||
required this.id,
|
||||
required this.tabBarHeight,
|
||||
required this.windowBorderWidth,
|
||||
}) : super(key: key);
|
||||
|
||||
final String id;
|
||||
final double tabBarHeight;
|
||||
final double windowBorderWidth;
|
||||
|
||||
@override
|
||||
State<RemotePage> createState() => _RemotePageState();
|
||||
@ -54,6 +56,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
|
||||
void _updateTabBarHeight() {
|
||||
_ffi.canvasModel.tabBarHeight = widget.tabBarHeight;
|
||||
_ffi.canvasModel.windowBorderWidth = widget.windowBorderWidth;
|
||||
}
|
||||
|
||||
void _initStates(String id) {
|
||||
|
@ -42,11 +42,13 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
onTabCloseButton: () => handleTabCloseButton(peerId),
|
||||
page: RemotePage(
|
||||
key: ValueKey(peerId),
|
||||
id: peerId,
|
||||
tabBarHeight: fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight,
|
||||
)));
|
||||
page: Obx(() => RemotePage(
|
||||
key: ValueKey(peerId),
|
||||
id: peerId,
|
||||
tabBarHeight:
|
||||
fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight,
|
||||
windowBorderWidth: fullscreen.isTrue ? 0 : kWindowBorderWidth,
|
||||
))));
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,11 +76,13 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
onTabCloseButton: () => handleTabCloseButton(id),
|
||||
page: RemotePage(
|
||||
key: ValueKey(id),
|
||||
id: id,
|
||||
tabBarHeight: fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight,
|
||||
)));
|
||||
page: Obx(() => RemotePage(
|
||||
key: ValueKey(id),
|
||||
id: id,
|
||||
tabBarHeight:
|
||||
fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight,
|
||||
windowBorderWidth: fullscreen.isTrue ? 0 : kWindowBorderWidth,
|
||||
))));
|
||||
} else if (call.method == "onDestroy") {
|
||||
tabController.clear();
|
||||
}
|
||||
@ -90,7 +94,9 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
final RxBool fullscreen = Get.find(tag: 'fullscreen');
|
||||
final tabWidget = Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: MyTheme.color(context).border!)),
|
||||
border: Border.all(
|
||||
color: MyTheme.color(context).border!,
|
||||
width: kWindowBorderWidth)),
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme.of(context).backgroundColor,
|
||||
body: Obx(() => DesktopTab(
|
||||
|
@ -298,7 +298,7 @@ class FfiModel with ChangeNotifier {
|
||||
if (_pi.currentDisplay < _pi.displays.length) {
|
||||
_display = _pi.displays[_pi.currentDisplay];
|
||||
}
|
||||
if (displays.length > 0) {
|
||||
if (displays.isNotEmpty) {
|
||||
parent.target?.dialogManager.showLoading(
|
||||
translate('Connected, waiting for image...'),
|
||||
onCancel: closeConnection);
|
||||
@ -472,6 +472,8 @@ class CanvasModel with ChangeNotifier {
|
||||
double _scale = 1.0;
|
||||
// the tabbar over the image
|
||||
double tabBarHeight = 0.0;
|
||||
// the window border's width
|
||||
double windowBorderWidth = 0.0;
|
||||
// remote id
|
||||
String id = '';
|
||||
// scroll offset x percent
|
||||
@ -559,7 +561,8 @@ class CanvasModel with ChangeNotifier {
|
||||
|
||||
Size get size {
|
||||
final size = MediaQueryData.fromWindow(ui.window).size;
|
||||
return Size(size.width, size.height - tabBarHeight);
|
||||
return Size(size.width - windowBorderWidth * 2,
|
||||
size.height - tabBarHeight - windowBorderWidth * 2);
|
||||
}
|
||||
|
||||
moveDesktopMouse(double x, double y) {
|
||||
|
Loading…
Reference in New Issue
Block a user