mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-18 10:21:03 +03:00
fix(cursor): address sizing and capture review findings
This commit is contained in:
@@ -1121,21 +1121,23 @@ class _ImagePaintState extends State<ImagePaint> {
|
||||
// changes, so read it live to follow the window across monitors.
|
||||
final dpr = MediaQuery.devicePixelRatioOf(context);
|
||||
|
||||
bool isViewAdaptive() => c.viewStyle.style == kRemoteViewStyleAdaptive;
|
||||
bool isViewScaled() =>
|
||||
c.viewStyle.style == kRemoteViewStyleAdaptive ||
|
||||
c.viewStyle.style == kRemoteViewStyleCustom;
|
||||
bool isViewOriginal() => c.viewStyle.style == kRemoteViewStyleOriginal;
|
||||
|
||||
mouseRegion({child}) => Obx(() {
|
||||
final useLocalSize = !isWeb &&
|
||||
(isLinux || isMacOS || isWindows) &&
|
||||
!zoomCursor.value &&
|
||||
isViewAdaptive();
|
||||
isViewScaled();
|
||||
if (useLocalSize) _localCursorSize.ensureLoaded(dpr);
|
||||
double getCursorScale() {
|
||||
var c = Provider.of<CanvasModel>(context);
|
||||
var cursorScale = 1.0;
|
||||
if (isWindows) {
|
||||
// debug win10
|
||||
if (zoomCursor.value && isViewAdaptive()) {
|
||||
if (zoomCursor.value && isViewScaled()) {
|
||||
cursorScale = s * c.devicePixelRatio;
|
||||
}
|
||||
} else {
|
||||
@@ -1296,7 +1298,6 @@ class _ImagePaintState extends State<ImagePaint> {
|
||||
{bool useLocalSize = false}) {
|
||||
final cursor = Provider.of<CursorModel>(context);
|
||||
final cache = cursor.cache ?? preDefaultCursor.cache;
|
||||
if (useLocalSize && _localCursorSize.value == null) return MouseCursor.defer;
|
||||
cache?.localSize = useLocalSize ? _localCursorSize.value : null;
|
||||
return buildCursorOfCache(cursor, scale, cache);
|
||||
}
|
||||
@@ -1305,7 +1306,6 @@ class _ImagePaintState extends State<ImagePaint> {
|
||||
{bool useLocalSize = false}) {
|
||||
final cursor = Provider.of<CursorModel>(context);
|
||||
final cache = preForbiddenCursor.cache;
|
||||
if (useLocalSize && _localCursorSize.value == null) return MouseCursor.defer;
|
||||
cache?.localSize = useLocalSize ? _localCursorSize.value : null;
|
||||
return buildCursorOfCache(cursor, scale, cache);
|
||||
}
|
||||
|
||||
@@ -2900,6 +2900,15 @@ class CursorData {
|
||||
scale = _visibleSize == 0
|
||||
? 1.0
|
||||
: max(localSize!, kMinCursorSize) / _visibleSize;
|
||||
// Sparse peer artwork must not amplify the native bitmap allocation.
|
||||
const maxNativeCursorBitmapSize = 512;
|
||||
final maxScale = maxNativeCursorBitmapSize / max(width, height);
|
||||
if (scale > maxScale) {
|
||||
if (oldScale != maxScale) {
|
||||
debugPrint('Cursor $id exceeds the native bitmap limit; reducing scale');
|
||||
}
|
||||
scale = maxScale;
|
||||
}
|
||||
} else if (scale != 1.0) {
|
||||
// Update data if scale changed.
|
||||
final tgtWidth = (width * scale).toInt();
|
||||
@@ -3461,6 +3470,8 @@ class CursorModel with ChangeNotifier {
|
||||
if (await _updateCache(rgba, image, id, hotx, hoty, width, height)) {
|
||||
_images[id]?.item1.dispose();
|
||||
_images[id] = Tuple3(image, hotx, hoty);
|
||||
} else {
|
||||
image.dispose();
|
||||
}
|
||||
|
||||
// Update last cursor data.
|
||||
@@ -3484,7 +3495,8 @@ class CursorModel with ChangeNotifier {
|
||||
final pixels =
|
||||
await image.toByteData(format: ui.ImageByteFormat.rawStraightRgba);
|
||||
if (pixels == null) {
|
||||
throw StateError('Could not read straight-alpha cursor pixels');
|
||||
debugPrint('Could not read straight-alpha cursor pixels: $id');
|
||||
return false;
|
||||
}
|
||||
imgOrigin = img2.Image.fromBytes(
|
||||
width: w, height: h, bytes: pixels.buffer, order: img2.ChannelOrder.rgba);
|
||||
@@ -3493,13 +3505,18 @@ class CursorModel with ChangeNotifier {
|
||||
ByteData? imgBytes =
|
||||
await image.toByteData(format: ui.ImageByteFormat.png);
|
||||
if (imgBytes == null) {
|
||||
debugPrint('Could not encode cursor PNG: $id');
|
||||
return false;
|
||||
}
|
||||
data = imgBytes.buffer.asUint8List();
|
||||
if (isLinux || isMacOS) {
|
||||
// Preserve the PNG's straight-alpha colors when resizing native cursors.
|
||||
imgOrigin = img2.decodePng(data) ??
|
||||
(throw const FormatException('Invalid native cursor PNG'));
|
||||
final decoded = img2.decodePng(data);
|
||||
if (decoded == null) {
|
||||
debugPrint('Invalid native cursor PNG: $id');
|
||||
return false;
|
||||
}
|
||||
imgOrigin = decoded;
|
||||
}
|
||||
}
|
||||
final cache = CursorData(
|
||||
|
||||
@@ -98,7 +98,10 @@ inline void Register(FlView* view) {
|
||||
}
|
||||
if (error) g_warning("Cursor size response failed: %s", error->message);
|
||||
}, view, nullptr);
|
||||
g_object_set_data_full(G_OBJECT(view), "cursor-size-channel", channel, g_object_unref);
|
||||
g_object_set_data_full(G_OBJECT(view), "cursor-size-channel", channel, [](gpointer data) {
|
||||
fl_method_channel_set_method_call_handler(FL_METHOD_CHANNEL(data), nullptr, nullptr, nullptr);
|
||||
g_object_unref(data);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace cursor_size
|
||||
|
||||
@@ -25,15 +25,17 @@ class _Image extends ChangeNotifier implements ImageModel {
|
||||
}
|
||||
|
||||
class _Canvas extends ChangeNotifier implements CanvasModel {
|
||||
_Canvas(this.devicePixelRatio);
|
||||
_Canvas(this.devicePixelRatio, {required this.style, required this.scale});
|
||||
|
||||
final String style;
|
||||
|
||||
@override
|
||||
final double devicePixelRatio;
|
||||
@override
|
||||
final imageOverflow = false.obs;
|
||||
@override
|
||||
final viewStyle = ViewStyle(
|
||||
style: kRemoteViewStyleAdaptive,
|
||||
late final viewStyle = ViewStyle(
|
||||
style: style,
|
||||
width: _viewport.width,
|
||||
height: _viewport.height,
|
||||
displayWidth: 400,
|
||||
@@ -44,7 +46,7 @@ class _Canvas extends ChangeNotifier implements CanvasModel {
|
||||
@override
|
||||
Size get size => _viewport;
|
||||
@override
|
||||
double get scale => 0.5;
|
||||
final double scale;
|
||||
@override
|
||||
double get x => 0;
|
||||
@override
|
||||
@@ -200,8 +202,15 @@ void main() {
|
||||
if (Platform.isWindows) expect(cursor.data!.length, 25 * 34 * 4);
|
||||
});
|
||||
|
||||
for (final dpr in [1.0, 2.0, 3.0]) {
|
||||
testWidgets('Zoom off at local DPR $dpr ignores remote raster density',
|
||||
for (final (dpr, style, scale) in [
|
||||
for (final dpr in [1.0, 2.0, 3.0])
|
||||
for (final (style, scale) in [
|
||||
(kRemoteViewStyleAdaptive, 0.5),
|
||||
(kRemoteViewStyleCustom, 0.25),
|
||||
(kRemoteViewStyleCustom, 2.0),
|
||||
]) (dpr, style, scale),
|
||||
]) {
|
||||
testWidgets('$style scale=$scale DPR=$dpr preserves local size and hotspot',
|
||||
(tester) async {
|
||||
final channel = Platform.isWindows
|
||||
? SystemChannels.mouseCursor
|
||||
@@ -227,18 +236,20 @@ void main() {
|
||||
addTearDown(() => tester.binding.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(sizeChannel, null));
|
||||
final cursor = _Cursor(_arrow(1));
|
||||
final zoom = false.obs;
|
||||
await tester.pumpWidget(MediaQuery(
|
||||
data: MediaQueryData(devicePixelRatio: dpr),
|
||||
child: MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<ImageModel>(create: (_) => _Image()),
|
||||
ChangeNotifierProvider<CanvasModel>(create: (_) => _Canvas(dpr)),
|
||||
ChangeNotifierProvider<CanvasModel>(
|
||||
create: (_) => _Canvas(dpr, style: style, scale: scale)),
|
||||
ChangeNotifierProvider<CursorModel>.value(value: cursor),
|
||||
],
|
||||
child: ImagePaint(
|
||||
ffi: _FFI(),
|
||||
id: 'local-size-test',
|
||||
zoomCursor: false.obs,
|
||||
zoomCursor: zoom,
|
||||
cursorOverImage: true.obs,
|
||||
keyboardEnabled: true.obs,
|
||||
remoteCursorMoved: false.obs,
|
||||
@@ -246,12 +257,14 @@ void main() {
|
||||
),
|
||||
));
|
||||
await tester.pump();
|
||||
expect(registered, hasLength(1));
|
||||
final original = registered.single;
|
||||
expect(registered, isNotEmpty);
|
||||
expect(cursor.cache.localSize, Platform.isWindows ? 23.0 * dpr : 23.0);
|
||||
final original = registered.last;
|
||||
final beforeDensityChange = registered.length;
|
||||
cursor.cache = _arrow(2);
|
||||
cursor.notifyListeners();
|
||||
await tester.pump();
|
||||
expect(registered, hasLength(2));
|
||||
expect(registered, hasLength(beforeDensityChange + 1));
|
||||
final retina = registered.last;
|
||||
expect(
|
||||
[retina['width'], retina['height'], retina['hotX'], retina['hotY']],
|
||||
@@ -264,6 +277,14 @@ void main() {
|
||||
reason: 'Only the remote raster density changed; the local cursor must '
|
||||
'retain its size and hotspot.',
|
||||
);
|
||||
zoom.value = true;
|
||||
await tester.pump();
|
||||
expect(cursor.cache.localSize, isNull);
|
||||
final zoomScale = scale * (Platform.isWindows ? dpr : 1);
|
||||
expect(cursor.cache.scale,
|
||||
zoomScale < kMinCursorSize / 34 ? kMinCursorSize / 34 : zoomScale);
|
||||
expect(cursor.cache.hotx / cursor.cache.scaledWidth, closeTo(4 / 17, 1e-9));
|
||||
expect(cursor.cache.hoty / cursor.cache.scaledHeight, closeTo(4 / 23, 1e-9));
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
cursor.dispose();
|
||||
});
|
||||
|
||||
181
flutter/test/cursor_measurement_failure_test.dart
Normal file
181
flutter/test/cursor_measurement_failure_test.dart
Normal file
@@ -0,0 +1,181 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/remote_page.dart';
|
||||
import 'package:flutter_hbb/models/input_model.dart';
|
||||
import 'package:flutter_hbb/models/model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:image/image.dart' as img;
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
const _viewport = Size(200, 160);
|
||||
|
||||
class _Image extends ChangeNotifier implements ImageModel {
|
||||
@override
|
||||
bool get useTextureRender => false;
|
||||
@override
|
||||
ui.Image? get image => null;
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
class _Canvas extends ChangeNotifier implements CanvasModel {
|
||||
_Canvas(this.devicePixelRatio, {required this.style, required this.scale});
|
||||
|
||||
final String style;
|
||||
|
||||
@override
|
||||
final double devicePixelRatio;
|
||||
@override
|
||||
final imageOverflow = false.obs;
|
||||
@override
|
||||
late final viewStyle = ViewStyle(
|
||||
style: style,
|
||||
width: _viewport.width,
|
||||
height: _viewport.height,
|
||||
displayWidth: 400,
|
||||
displayHeight: 320,
|
||||
);
|
||||
@override
|
||||
bool get cursorEmbedded => false;
|
||||
@override
|
||||
Size get size => _viewport;
|
||||
@override
|
||||
final double scale;
|
||||
@override
|
||||
double get x => 0;
|
||||
@override
|
||||
double get y => 0;
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
class _Cursor extends ChangeNotifier implements CursorModel {
|
||||
_Cursor(this.cache);
|
||||
|
||||
@override
|
||||
CursorData cache;
|
||||
@override
|
||||
ui.Image? get image => null;
|
||||
@override
|
||||
double get hotx => cache.hotxOrigin;
|
||||
@override
|
||||
double get hoty => cache.hotyOrigin;
|
||||
@override
|
||||
final Set<String> cachedKeys = {};
|
||||
@override
|
||||
void addKey(String key) => cachedKeys.add(key);
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
class _Input extends Fake implements InputModel {
|
||||
@override
|
||||
final relativeMouseMode = false.obs;
|
||||
}
|
||||
|
||||
class _Peer extends Fake implements FfiModel {
|
||||
@override
|
||||
final pi = PeerInfo();
|
||||
@override
|
||||
bool get isPeerLinux => false;
|
||||
}
|
||||
|
||||
class _FFI extends Fake implements FFI {
|
||||
@override
|
||||
final inputModel = _Input();
|
||||
@override
|
||||
final ffiModel = _Peer();
|
||||
}
|
||||
|
||||
CursorData _cursor(img.Image image,
|
||||
{String id = 'sprite', double hotspot = 0}) {
|
||||
return CursorData(
|
||||
peerId: 'local-size-test',
|
||||
id: id,
|
||||
image: image,
|
||||
scale: 1,
|
||||
data: Platform.isWindows
|
||||
? image.getBytes(order: img.ChannelOrder.bgra)
|
||||
: Uint8List.fromList(img.encodePng(image)),
|
||||
hotxOrigin: hotspot,
|
||||
hotyOrigin: hotspot,
|
||||
width: image.width,
|
||||
height: image.height,
|
||||
);
|
||||
}
|
||||
|
||||
CursorData _arrow(int density) {
|
||||
final image =
|
||||
img.Image(width: 17 * density, height: 23 * density, numChannels: 4);
|
||||
img.fill(image, color: img.ColorRgba8(255, 255, 255, 255));
|
||||
return _cursor(image, id: 'arrow-$density', hotspot: 4.0 * density);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('pending or failed size measurement preserves the remote cursor',
|
||||
(tester) async {
|
||||
final channel = Platform.isWindows
|
||||
? SystemChannels.mouseCursor
|
||||
: const MethodChannel('flutter_custom_cursor');
|
||||
final registered = <Map<dynamic, dynamic>>[];
|
||||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(channel,
|
||||
(call) async {
|
||||
if (call.method.startsWith('createCustomCursor')) {
|
||||
final arguments = call.arguments as Map<dynamic, dynamic>;
|
||||
registered.add(arguments);
|
||||
return arguments['name'];
|
||||
}
|
||||
return null;
|
||||
});
|
||||
addTearDown(() => tester.binding.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(channel, null));
|
||||
const sizeChannel = MethodChannel('org.rustdesk.rustdesk/cursor');
|
||||
final measurement = Completer<double>();
|
||||
tester.binding.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(sizeChannel, (_) => measurement.future);
|
||||
addTearDown(() => tester.binding.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(sizeChannel, null));
|
||||
final cursor = _Cursor(_arrow(2));
|
||||
await tester.pumpWidget(_view(cursor));
|
||||
expect(registered, isNotEmpty);
|
||||
measurement.completeError(PlatformException(code: 'cursor_size'));
|
||||
await tester.pump();
|
||||
expect(tester.takeException(), isA<PlatformException>());
|
||||
expect(cursor.cache.localSize, isNull);
|
||||
final scale = Platform.isWindows ? 1.0 : 0.5;
|
||||
expect(cursor.cache.scaledWidth, 34 * scale);
|
||||
expect(cursor.cache.scaledHeight, 46 * scale);
|
||||
expect(cursor.cache.hotx, 8 * scale);
|
||||
expect(cursor.cache.hoty, 8 * scale);
|
||||
expect(registered.last['hotX'], 8 * scale);
|
||||
expect(registered.last['hotY'], 8 * scale);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
cursor.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
Widget _view(_Cursor cursor) => MediaQuery(
|
||||
data: const MediaQueryData(devicePixelRatio: 2),
|
||||
child: MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<ImageModel>(create: (_) => _Image()),
|
||||
ChangeNotifierProvider<CanvasModel>(create: (_) => _Canvas(2,
|
||||
style: kRemoteViewStyleAdaptive, scale: 0.25)),
|
||||
ChangeNotifierProvider<CursorModel>.value(value: cursor),
|
||||
],
|
||||
child: ImagePaint(
|
||||
ffi: _FFI(),
|
||||
id: 'measurement-failure-test',
|
||||
zoomCursor: false.obs,
|
||||
cursorOverImage: true.obs,
|
||||
keyboardEnabled: true.obs,
|
||||
remoteCursorMoved: false.obs,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -107,6 +107,10 @@ void main() {
|
||||
(kRemoteViewStyleAdaptive, true, 3.0, (48, 64), 0.375, 0.375, true),
|
||||
(kRemoteViewStyleOriginal, false, 2.0, (48, 64), 0.5, 0.5, true),
|
||||
(kRemoteViewStyleOriginal, true, 2.0, (48, 64), 0.5, 0.5, true),
|
||||
for (final zoom in [false, true])
|
||||
for (final scale in [0.25, 2.0])
|
||||
for (final texture in [false, true])
|
||||
(kRemoteViewStyleCustom, zoom, 2.0, (48, 64), scale, scale, texture),
|
||||
(
|
||||
kRemoteViewStyleAdaptive,
|
||||
false,
|
||||
|
||||
43
flutter/test/cursor_resize_limit_test.dart
Normal file
43
flutter/test/cursor_resize_limit_test.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_hbb/models/model.dart';
|
||||
import 'package:image/image.dart' as img;
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
test('sparse remote artwork cannot amplify the native bitmap without limit',
|
||||
() {
|
||||
const sourceSize = 64;
|
||||
const bitmapLimit = 512;
|
||||
final image = img.Image(width: sourceSize, height: sourceSize, numChannels: 4)
|
||||
..setPixelRgba(0, 0, 255, 255, 255, 255);
|
||||
final cache = CursorData(
|
||||
peerId: 'sparse-cursor',
|
||||
id: '1',
|
||||
image: image,
|
||||
scale: 1,
|
||||
data: Uint8List.fromList(img.encodePng(image)),
|
||||
hotxOrigin: 32,
|
||||
hotyOrigin: 48,
|
||||
width: sourceSize,
|
||||
height: sourceSize,
|
||||
)..localSize = sourceSize.toDouble();
|
||||
final messages = <String>[];
|
||||
final previous = debugPrint;
|
||||
debugPrint = (String? message, {int? wrapWidth}) {
|
||||
messages.add(message ?? '');
|
||||
};
|
||||
addTearDown(() => debugPrint = previous);
|
||||
|
||||
cache.updateGetKey(1);
|
||||
|
||||
expect(max(cache.scaledWidth, cache.scaledHeight), bitmapLimit);
|
||||
expect(cache.hotx, 32 * cache.scaledWidth / sourceSize);
|
||||
expect(cache.hoty, 48 * cache.scaledHeight / sourceSize);
|
||||
expect(messages.single, contains('bitmap limit'));
|
||||
});
|
||||
}
|
||||
@@ -71,7 +71,30 @@ inline void IncludeVisiblePixels(const Surface& surface, uint32_t background,
|
||||
}
|
||||
}
|
||||
|
||||
inline double SystemSize() {
|
||||
inline double WindowScale(HWND window) {
|
||||
const auto user32 = GetModuleHandleW(L"user32.dll");
|
||||
const auto window_dpi = reinterpret_cast<UINT(WINAPI*)(HWND)>(
|
||||
GetProcAddress(user32, "GetDpiForWindow"));
|
||||
const auto system_dpi = reinterpret_cast<UINT(WINAPI*)()>(
|
||||
GetProcAddress(user32, "GetDpiForSystem"));
|
||||
const auto metrics = reinterpret_cast<int(WINAPI*)(int, UINT)>(
|
||||
GetProcAddress(user32, "GetSystemMetricsForDpi"));
|
||||
// Preserve the system-DPI path on Windows versions without per-window metrics.
|
||||
if (!window_dpi || !system_dpi || !metrics) return 1.0;
|
||||
const UINT target_dpi = window_dpi(window);
|
||||
const UINT source_dpi = system_dpi();
|
||||
if (!target_dpi || !source_dpi) {
|
||||
throw std::runtime_error("Could not read the cursor window DPI");
|
||||
}
|
||||
const int target_size = metrics(SM_CXCURSOR, target_dpi);
|
||||
const int source_size = metrics(SM_CXCURSOR, source_dpi);
|
||||
if (target_size <= 0 || source_size <= 0) {
|
||||
throw std::runtime_error("Could not read the DPI-specific cursor metrics");
|
||||
}
|
||||
return static_cast<double>(target_size) / source_size;
|
||||
}
|
||||
|
||||
inline double SystemSize(HWND window) {
|
||||
HCURSOR cursor = LoadCursorW(nullptr, IDC_ARROW);
|
||||
IconBitmaps bitmaps;
|
||||
if (!cursor || !GetIconInfo(cursor, &bitmaps.info)) {
|
||||
@@ -97,20 +120,21 @@ inline double SystemSize() {
|
||||
if (bounds.right <= bounds.left) {
|
||||
throw std::runtime_error("System cursor has no visible pixels");
|
||||
}
|
||||
return (std::max)(bounds.right - bounds.left, bounds.bottom - bounds.top);
|
||||
return (std::max)(bounds.right - bounds.left, bounds.bottom - bounds.top) *
|
||||
WindowScale(window);
|
||||
}
|
||||
|
||||
inline void Register(flutter::BinaryMessenger* messenger) {
|
||||
inline void Register(flutter::BinaryMessenger* messenger, HWND window) {
|
||||
flutter::MethodChannel<> channel(messenger, "org.rustdesk.rustdesk/cursor",
|
||||
&flutter::StandardMethodCodec::GetInstance());
|
||||
channel.SetMethodCallHandler([](const flutter::MethodCall<>& call,
|
||||
channel.SetMethodCallHandler([window](const flutter::MethodCall<>& call,
|
||||
std::unique_ptr<flutter::MethodResult<>> result) {
|
||||
if (call.method_name() != "getSystemCursorSize") {
|
||||
result->NotImplemented();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
result->Success(flutter::EncodableValue(SystemSize()));
|
||||
result->Success(flutter::EncodableValue(SystemSize(window)));
|
||||
} catch (const std::exception& error) {
|
||||
result->Error("cursor_size", error.what());
|
||||
}
|
||||
|
||||
@@ -101,7 +101,8 @@ bool FlutterWindow::OnCreate() {
|
||||
return false;
|
||||
}
|
||||
RegisterPlugins(flutter_controller_->engine());
|
||||
cursor_size::Register(flutter_controller_->engine()->messenger());
|
||||
cursor_size::Register(flutter_controller_->engine()->messenger(),
|
||||
flutter_controller_->view()->GetNativeWindow());
|
||||
|
||||
flutter::MethodChannel<> channel(
|
||||
flutter_controller_->engine()->messenger(),
|
||||
@@ -148,7 +149,8 @@ bool FlutterWindow::OnCreate() {
|
||||
auto *flutter_view_controller =
|
||||
reinterpret_cast<flutter::FlutterViewController *>(controller);
|
||||
auto *registry = flutter_view_controller->engine();
|
||||
cursor_size::Register(registry->messenger());
|
||||
cursor_size::Register(registry->messenger(),
|
||||
flutter_view_controller->view()->GetNativeWindow());
|
||||
TextureRgbaRendererPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("TextureRgbaRendererPlugin"));
|
||||
FlutterGpuTextureRendererPluginCApiRegisterWithRegistrar(
|
||||
|
||||
Reference in New Issue
Block a user