zoom system cursor when view scale is adaptive

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-02-02 12:39:39 +08:00
parent 8881462f74
commit b5fbc23cb9
2 changed files with 32 additions and 26 deletions

View File

@ -362,10 +362,10 @@ class _RemotePageState extends State<RemotePage>
class ImagePaint extends StatefulWidget { class ImagePaint extends StatefulWidget {
final String id; final String id;
final Rx<bool> zoomCursor; final RxBool zoomCursor;
final Rx<bool> cursorOverImage; final RxBool cursorOverImage;
final Rx<bool> keyboardEnabled; final RxBool keyboardEnabled;
final Rx<bool> remoteCursorMoved; final RxBool remoteCursorMoved;
final Widget Function(Widget)? listenerBuilder; final Widget Function(Widget)? listenerBuilder;
ImagePaint( ImagePaint(
@ -388,10 +388,10 @@ class _ImagePaintState extends State<ImagePaint> {
final ScrollController _vertical = ScrollController(); final ScrollController _vertical = ScrollController();
String get id => widget.id; String get id => widget.id;
Rx<bool> get zoomCursor => widget.zoomCursor; RxBool get zoomCursor => widget.zoomCursor;
Rx<bool> get cursorOverImage => widget.cursorOverImage; RxBool get cursorOverImage => widget.cursorOverImage;
Rx<bool> get keyboardEnabled => widget.keyboardEnabled; RxBool get keyboardEnabled => widget.keyboardEnabled;
Rx<bool> get remoteCursorMoved => widget.remoteCursorMoved; RxBool get remoteCursorMoved => widget.remoteCursorMoved;
Widget Function(Widget)? get listenerBuilder => widget.listenerBuilder; Widget Function(Widget)? get listenerBuilder => widget.listenerBuilder;
@override @override
@ -466,7 +466,10 @@ class _ImagePaintState extends State<ImagePaint> {
if (cache == null) { if (cache == null) {
return MouseCursor.defer; return MouseCursor.defer;
} else { } else {
final key = cache.updateGetKey(scale, zoomCursor.value); final isViewAdaptive =
Provider.of<CanvasModel>(context, listen: false).viewStyle.style ==
kRemoteViewStyleAdaptive;
final key = cache.updateGetKey(scale, zoomCursor.value && isViewAdaptive);
if (!cursor.cachedKeys.contains(key)) { if (!cursor.cachedKeys.contains(key)) {
debugPrint("Register custom cursor with key $key"); debugPrint("Register custom cursor with key $key");
// [Safety] // [Safety]

View File

@ -1133,23 +1133,26 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
}()); }());
} }
displayMenu.add(() { /// Show remote cursor scaling with image
final opt = 'zoom-cursor'; if (widget.state.viewStyle.value != kRemoteViewStyleOriginal) {
final state = PeerBoolOption.find(widget.id, opt); displayMenu.add(() {
return MenuEntrySwitch2<String>( final opt = 'zoom-cursor';
switchType: SwitchType.scheckbox, final state = PeerBoolOption.find(widget.id, opt);
text: translate('Zoom cursor'), return MenuEntrySwitch2<String>(
getter: () { switchType: SwitchType.scheckbox,
return state; text: translate('Zoom cursor'),
}, getter: () {
setter: (bool v) async { return state;
state.value = v; },
await bind.sessionToggleOption(id: widget.id, value: opt); setter: (bool v) async {
}, state.value = v;
padding: padding, await bind.sessionToggleOption(id: widget.id, value: opt);
dismissOnClicked: true, },
); padding: padding,
}()); dismissOnClicked: true,
);
}());
}
/// Show quality monitor /// Show quality monitor
displayMenu.add(MenuEntrySwitch<String>( displayMenu.add(MenuEntrySwitch<String>(