scale system cursor image

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-02-01 20:58:21 +08:00
parent 06204d446e
commit 8dba394205
3 changed files with 32 additions and 40 deletions

View File

@ -3,7 +3,6 @@ import 'dart:io';
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:desktop_multi_window/desktop_multi_window.dart'; import 'package:desktop_multi_window/desktop_multi_window.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_custom_cursor/cursor_manager.dart' import 'package:flutter_custom_cursor/cursor_manager.dart'

View File

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

View File

@ -778,28 +778,24 @@ class CursorData {
scale = 1.0; scale = 1.0;
} else { } else {
// Update data if scale changed. // Update data if scale changed.
if (Platform.isWindows) { final tgtWidth = (width * scale).toInt();
final tgtWidth = (width * scale).toInt(); final tgtHeight = (width * scale).toInt();
final tgtHeight = (width * scale).toInt(); if (tgtWidth < kMinCursorSize || tgtHeight < kMinCursorSize) {
if (tgtWidth < kMinCursorSize || tgtHeight < kMinCursorSize) { double sw = kMinCursorSize.toDouble() / width;
double sw = kMinCursorSize.toDouble() / width; double sh = kMinCursorSize.toDouble() / height;
double sh = kMinCursorSize.toDouble() / height; scale = sw < sh ? sh : sw;
scale = sw < sh ? sh : sw;
}
} }
} }
if (Platform.isWindows) { if (_doubleToInt(oldScale) != _doubleToInt(scale)) {
if (_doubleToInt(oldScale) != _doubleToInt(scale)) { data = img2
data = img2 .copyResize(
.copyResize( image!,
image!, width: (width * scale).toInt(),
width: (width * scale).toInt(), height: (height * scale).toInt(),
height: (height * scale).toInt(), interpolation: img2.Interpolation.average,
interpolation: img2.Interpolation.average, )
) .getBytes(format: img2.Format.bgra);
.getBytes(format: img2.Format.bgra);
}
} }
this.scale = scale; this.scale = scale;