mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-25 05:09:04 +08:00
flutter_desktop: remote page scroll whell on track
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
048fc40882
commit
91da949482
@ -9,15 +9,17 @@ import 'package:get/get.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:wakelock/wakelock.dart';
|
import 'package:wakelock/wakelock.dart';
|
||||||
import 'package:flutter_custom_cursor/flutter_custom_cursor.dart';
|
import 'package:flutter_custom_cursor/flutter_custom_cursor.dart';
|
||||||
|
import 'package:flutter_improved_scrolling/flutter_improved_scrolling.dart';
|
||||||
|
|
||||||
|
import '../../consts.dart';
|
||||||
import '../../common/widgets/overlay.dart';
|
import '../../common/widgets/overlay.dart';
|
||||||
import '../../common/widgets/remote_input.dart';
|
import '../../common/widgets/remote_input.dart';
|
||||||
import '../widgets/remote_menubar.dart';
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
import '../../mobile/widgets/dialog.dart';
|
import '../../mobile/widgets/dialog.dart';
|
||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
import '../../models/platform_model.dart';
|
import '../../models/platform_model.dart';
|
||||||
import '../../common/shared_state.dart';
|
import '../../common/shared_state.dart';
|
||||||
|
import '../widgets/remote_menubar.dart';
|
||||||
|
|
||||||
bool _isCustomCursorInited = false;
|
bool _isCustomCursorInited = false;
|
||||||
final SimpleWrapper<bool> _firstEnterImage = SimpleWrapper(false);
|
final SimpleWrapper<bool> _firstEnterImage = SimpleWrapper(false);
|
||||||
@ -89,7 +91,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
|
|
||||||
_updateTabBarHeight();
|
_updateTabBarHeight();
|
||||||
Get.put(_ffi, tag: widget.id);
|
Get.put(_ffi, tag: widget.id);
|
||||||
_ffi.start(widget.id, tabBarHeight: super.widget.tabBarHeight);
|
_ffi.start(widget.id);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||||
_ffi.dialogManager
|
_ffi.dialogManager
|
||||||
@ -341,11 +343,21 @@ class ImagePaint extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildCrossScrollbar(Widget child) {
|
Widget _buildCrossScrollbar(Widget child) {
|
||||||
final physicsVertical =
|
final scrollConfig = CustomMouseWheelScrollConfig(
|
||||||
cursorOverImage.value ? const NeverScrollableScrollPhysics() : null;
|
scrollDuration: kDefaultScrollDuration,
|
||||||
final physicsHorizontal =
|
scrollCurve: Curves.linearToEaseOut,
|
||||||
cursorOverImage.value ? const NeverScrollableScrollPhysics() : null;
|
mouseWheelTurnsThrottleTimeMs:
|
||||||
return Scrollbar(
|
kDefaultMouseWheelThrottleDuration.inMilliseconds,
|
||||||
|
scrollAmountMultiplier: kDefaultScrollAmountMultiplier);
|
||||||
|
return Obx(() => ImprovedScrolling(
|
||||||
|
scrollController: _vertical,
|
||||||
|
enableCustomMouseWheelScrolling: cursorOverImage.isFalse,
|
||||||
|
customMouseWheelScrollConfig: scrollConfig,
|
||||||
|
child: ImprovedScrolling(
|
||||||
|
scrollController: _horizontal,
|
||||||
|
enableCustomMouseWheelScrolling: cursorOverImage.isFalse,
|
||||||
|
customMouseWheelScrollConfig: scrollConfig,
|
||||||
|
child: Scrollbar(
|
||||||
controller: _vertical,
|
controller: _vertical,
|
||||||
thumbVisibility: false,
|
thumbVisibility: false,
|
||||||
trackVisibility: false,
|
trackVisibility: false,
|
||||||
@ -356,15 +368,18 @@ class ImagePaint extends StatelessWidget {
|
|||||||
notificationPredicate: (notif) => notif.depth == 1,
|
notificationPredicate: (notif) => notif.depth == 1,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
controller: _vertical,
|
controller: _vertical,
|
||||||
physics: physicsVertical,
|
physics: cursorOverImage.isTrue
|
||||||
|
? const NeverScrollableScrollPhysics()
|
||||||
|
: null,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
controller: _horizontal,
|
controller: _horizontal,
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
physics: physicsHorizontal,
|
physics: cursorOverImage.isTrue
|
||||||
|
? const NeverScrollableScrollPhysics()
|
||||||
|
: null,
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
),
|
))))));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildListener(Widget child) {
|
Widget _buildListener(Widget child) {
|
||||||
|
@ -341,7 +341,7 @@ class ImageModel with ChangeNotifier {
|
|||||||
|
|
||||||
ImageModel(this.parent);
|
ImageModel(this.parent);
|
||||||
|
|
||||||
onRgba(Uint8List rgba, double tabBarHeight) {
|
onRgba(Uint8List rgba) {
|
||||||
if (_waitForImage) {
|
if (_waitForImage) {
|
||||||
_waitForImage = false;
|
_waitForImage = false;
|
||||||
parent.target?.dialogManager.dismissAll();
|
parent.target?.dialogManager.dismissAll();
|
||||||
@ -355,14 +355,14 @@ class ImageModel with ChangeNotifier {
|
|||||||
if (parent.target?.id != pid) return;
|
if (parent.target?.id != pid) return;
|
||||||
try {
|
try {
|
||||||
// my throw exception, because the listener maybe already dispose
|
// my throw exception, because the listener maybe already dispose
|
||||||
update(image, tabBarHeight);
|
update(image);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('update image: $e');
|
debugPrint('update image: $e');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
update(ui.Image? image, double tabBarHeight) async {
|
update(ui.Image? image) async {
|
||||||
if (_image == null && image != null) {
|
if (_image == null && image != null) {
|
||||||
if (isWebDesktop || isDesktop) {
|
if (isWebDesktop || isDesktop) {
|
||||||
await parent.target?.canvasModel.updateViewStyle();
|
await parent.target?.canvasModel.updateViewStyle();
|
||||||
@ -370,7 +370,7 @@ class ImageModel with ChangeNotifier {
|
|||||||
} else {
|
} else {
|
||||||
final size = MediaQueryData.fromWindow(ui.window).size;
|
final size = MediaQueryData.fromWindow(ui.window).size;
|
||||||
final canvasWidth = size.width;
|
final canvasWidth = size.width;
|
||||||
final canvasHeight = size.height - tabBarHeight;
|
final canvasHeight = size.height;
|
||||||
final xscale = canvasWidth / image.width;
|
final xscale = canvasWidth / image.width;
|
||||||
final yscale = canvasHeight / image.height;
|
final yscale = canvasHeight / image.height;
|
||||||
parent.target?.canvasModel.scale = min(xscale, yscale);
|
parent.target?.canvasModel.scale = min(xscale, yscale);
|
||||||
@ -1052,9 +1052,7 @@ class FFI {
|
|||||||
|
|
||||||
/// Start with the given [id]. Only transfer file if [isFileTransfer], only port forward if [isPortForward].
|
/// Start with the given [id]. Only transfer file if [isFileTransfer], only port forward if [isPortForward].
|
||||||
void start(String id,
|
void start(String id,
|
||||||
{bool isFileTransfer = false,
|
{bool isFileTransfer = false, bool isPortForward = false}) {
|
||||||
bool isPortForward = false,
|
|
||||||
double tabBarHeight = 0.0}) {
|
|
||||||
assert(!(isFileTransfer && isPortForward), 'more than one connect type');
|
assert(!(isFileTransfer && isPortForward), 'more than one connect type');
|
||||||
if (isFileTransfer) {
|
if (isFileTransfer) {
|
||||||
connType = ConnType.fileTransfer;
|
connType = ConnType.fileTransfer;
|
||||||
@ -1083,7 +1081,7 @@ class FFI {
|
|||||||
debugPrint('json.decode fail1(): $e, ${message.field0}');
|
debugPrint('json.decode fail1(): $e, ${message.field0}');
|
||||||
}
|
}
|
||||||
} else if (message is Rgba) {
|
} else if (message is Rgba) {
|
||||||
imageModel.onRgba(message.field0, tabBarHeight);
|
imageModel.onRgba(message.field0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
@ -1108,7 +1106,7 @@ class FFI {
|
|||||||
}
|
}
|
||||||
bind.sessionClose(id: id);
|
bind.sessionClose(id: id);
|
||||||
id = '';
|
id = '';
|
||||||
imageModel.update(null, 0.0);
|
imageModel.update(null);
|
||||||
cursorModel.clear();
|
cursorModel.clear();
|
||||||
ffiModel.clear();
|
ffiModel.clear();
|
||||||
canvasModel.clear();
|
canvasModel.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user