mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 02:57:22 +00:00
flutter_desktop: remote rxbool of fullscreen
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -10,6 +10,7 @@ import '../../models/model.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
import '../common.dart';
|
||||
import '../consts.dart';
|
||||
import './state_model.dart';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
/// Mouse button enum.
|
||||
@@ -321,9 +322,7 @@ class InputModel {
|
||||
double x = evt['x'];
|
||||
double y = max(0.0, evt['y']);
|
||||
if (isDesktop) {
|
||||
final RxBool fullscreen = Get.find(tag: 'fullscreen');
|
||||
final tabBarHeight = fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight;
|
||||
y = y - tabBarHeight;
|
||||
y = y - stateGlobal.tabBarHeight;
|
||||
}
|
||||
final canvasModel = parent.target!.canvasModel;
|
||||
final ffiModel = parent.target!.ffiModel;
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:flutter_hbb/models/chat_model.dart';
|
||||
import 'package:flutter_hbb/models/file_model.dart';
|
||||
import 'package:flutter_hbb/models/server_model.dart';
|
||||
import 'package:flutter_hbb/models/user_model.dart';
|
||||
import 'package:flutter_hbb/models/state_model.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
@@ -483,9 +484,9 @@ class CanvasModel with ChangeNotifier {
|
||||
// image scale
|
||||
double _scale = 1.0;
|
||||
// the tabbar over the image
|
||||
double tabBarHeight = 0.0;
|
||||
// double tabBarHeight = 0.0;
|
||||
// the window border's width
|
||||
double windowBorderWidth = 0.0;
|
||||
// double windowBorderWidth = 0.0;
|
||||
// remote id
|
||||
String id = '';
|
||||
// scroll offset x percent
|
||||
@@ -571,6 +572,9 @@ class CanvasModel with ChangeNotifier {
|
||||
return parent.target?.ffiModel.display.height ?? defaultHeight;
|
||||
}
|
||||
|
||||
double get windowBorderWidth => stateGlobal.windowBorderWidth;
|
||||
double get tabBarHeight => stateGlobal.tabBarHeight;
|
||||
|
||||
Size get size {
|
||||
final size = MediaQueryData.fromWindow(ui.window).size;
|
||||
return Size(size.width - windowBorderWidth * 2,
|
||||
|
||||
33
flutter/lib/models/state_model.dart
Normal file
33
flutter/lib/models/state_model.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../consts.dart';
|
||||
|
||||
class StateGlobal {
|
||||
int _windowId = -1;
|
||||
bool _fullscreen = false;
|
||||
final RxBool _showTabBar = true.obs;
|
||||
|
||||
int get windowId => _windowId;
|
||||
bool get fullscreen => _fullscreen;
|
||||
double get tabBarHeight => fullscreen ? 0 : kDesktopRemoteTabBarHeight;
|
||||
double get windowBorderWidth => fullscreen ? 0 : kWindowBorderWidth;
|
||||
RxBool get showTabBar => _showTabBar;
|
||||
double get resizeEdgeSize =>
|
||||
fullscreen ? kFullScreenEdgeSize : kWindowEdgeSize;
|
||||
|
||||
setWindowId(int id) => _windowId = id;
|
||||
setFullscreen(bool v) {
|
||||
if (_fullscreen != v) {
|
||||
_fullscreen = v;
|
||||
_showTabBar.value = !_fullscreen;
|
||||
WindowController.fromWindowId(windowId).setFullscreen(_fullscreen);
|
||||
}
|
||||
}
|
||||
|
||||
StateGlobal._();
|
||||
|
||||
static final StateGlobal instance = StateGlobal._();
|
||||
}
|
||||
|
||||
final stateGlobal = StateGlobal.instance;
|
||||
Reference in New Issue
Block a user