mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-19 02:41:10 +03:00
revert(cursor): return to f5b98b32 before splitting plugin changes
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image/image.dart' as img;
|
||||
|
||||
int cursorVisibleSize(img.Image image) {
|
||||
var left = image.width;
|
||||
var top = image.height;
|
||||
var right = -1;
|
||||
var bottom = -1;
|
||||
for (final pixel in image) {
|
||||
if (pixel.a == 0) continue;
|
||||
if (pixel.x < left) left = pixel.x;
|
||||
if (pixel.x > right) right = pixel.x;
|
||||
if (pixel.y < top) top = pixel.y;
|
||||
if (pixel.y > bottom) bottom = pixel.y;
|
||||
}
|
||||
if (right < left) return 0;
|
||||
final width = right - left + 1;
|
||||
final height = bottom - top + 1;
|
||||
return width > height ? width : height;
|
||||
}
|
||||
|
||||
class LocalCursorSize extends ValueNotifier<double?> {
|
||||
LocalCursorSize() : super(null);
|
||||
|
||||
static const _channel = MethodChannel('org.rustdesk.rustdesk/cursor');
|
||||
double? _devicePixelRatio;
|
||||
int _generation = 0;
|
||||
|
||||
void ensureLoaded(double devicePixelRatio) {
|
||||
if (_devicePixelRatio == devicePixelRatio) return;
|
||||
_devicePixelRatio = devicePixelRatio;
|
||||
refresh();
|
||||
}
|
||||
|
||||
Future<void> refresh() async {
|
||||
final generation = ++_generation;
|
||||
try {
|
||||
final size = await _channel.invokeMethod<double>('getSystemCursorSize');
|
||||
if (size == null || !size.isFinite || size <= 0) {
|
||||
throw const FormatException('Invalid local system cursor size');
|
||||
}
|
||||
if (generation == _generation) value = size;
|
||||
} catch (error, stack) {
|
||||
FlutterError.reportError(FlutterErrorDetails(
|
||||
exception: error, stack: stack, library: 'local cursor size'));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
++_generation;
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@@ -96,14 +96,12 @@ class ImagePainter extends CustomPainter {
|
||||
required this.x,
|
||||
required this.y,
|
||||
required this.scale,
|
||||
this.useIntegerPosition = true,
|
||||
});
|
||||
|
||||
ui.Image? image;
|
||||
double x;
|
||||
double y;
|
||||
double scale;
|
||||
final bool useIntegerPosition;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
@@ -124,10 +122,8 @@ class ImagePainter extends CustomPainter {
|
||||
if (isWeb) {
|
||||
paint.filterQuality = FilterQuality.high;
|
||||
}
|
||||
final position = useIntegerPosition
|
||||
? Offset(x.toInt().toDouble(), y.toInt().toDouble())
|
||||
: Offset(x, y);
|
||||
canvas.drawImage(image!, position, paint);
|
||||
canvas.drawImage(
|
||||
image!, Offset(x.toInt().toDouble(), y.toInt().toDouble()), paint);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user