mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 19:17:58 +00:00
refactor: use latest custom cursor api
This commit is contained in:
@@ -5,6 +5,8 @@ import 'dart:ui' as ui;
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_custom_cursor/cursor_manager.dart'
|
||||
as custom_cursor_manager;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
@@ -109,17 +111,17 @@ class _RemotePageState extends State<RemotePage>
|
||||
id: widget.id, arg: 'show-remote-cursor');
|
||||
_zoomCursor.value =
|
||||
bind.sessionGetToggleOptionSync(id: widget.id, arg: 'zoom-cursor');
|
||||
if (!_isCustomCursorInited) {
|
||||
customCursorController.registerNeedUpdateCursorCallback(
|
||||
(String? lastKey, String? currentKey) async {
|
||||
if (_firstEnterImage.value) {
|
||||
_firstEnterImage.value = false;
|
||||
return true;
|
||||
}
|
||||
return lastKey == null || lastKey != currentKey;
|
||||
});
|
||||
_isCustomCursorInited = true;
|
||||
}
|
||||
// if (!_isCustomCursorInited) {
|
||||
// customCursorController.registerNeedUpdateCursorCallback(
|
||||
// (String? lastKey, String? currentKey) async {
|
||||
// if (_firstEnterImage.value) {
|
||||
// _firstEnterImage.value = false;
|
||||
// return true;
|
||||
// }
|
||||
// return lastKey == null || lastKey != currentKey;
|
||||
// });
|
||||
// _isCustomCursorInited = true;
|
||||
// }
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -366,15 +368,23 @@ class _ImagePaintState extends State<ImagePaint> {
|
||||
return MouseCursor.defer;
|
||||
} else {
|
||||
final key = cache.updateGetKey(scale, zoomCursor.value);
|
||||
cursor.addKey(key);
|
||||
return FlutterCustomMemoryImageCursor(
|
||||
pixbuf: cache.data,
|
||||
key: key,
|
||||
hotx: cache.hotx,
|
||||
hoty: cache.hoty,
|
||||
imageWidth: (cache.width * cache.scale).toInt(),
|
||||
imageHeight: (cache.height * cache.scale).toInt(),
|
||||
);
|
||||
if (!cursor.cachedKeys.contains(key)) {
|
||||
debugPrint("Register custom cursor with key $key");
|
||||
// [Safety]
|
||||
// It's ok to call async registerCursor in current synchronous context,
|
||||
// because activating the cursor is also an async call and will always
|
||||
// be executed after this.
|
||||
custom_cursor_manager.CursorManager.instance
|
||||
.registerCursor(custom_cursor_manager.CursorData()
|
||||
..buffer = cache.data!
|
||||
..height = (cache.height * cache.scale).toInt()
|
||||
..width = (cache.width * cache.scale).toInt()
|
||||
..hotX = cache.hotx
|
||||
..hotY = cache.hoty
|
||||
..name = key);
|
||||
cursor.addKey(key);
|
||||
}
|
||||
return FlutterCustomMemoryImageCursor(key: key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user