flutter_desktop: debug win cursor 2
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
2c34112492
commit
b321dff158
@ -284,7 +284,7 @@ class ImagePaint extends StatelessWidget {
|
|||||||
? keyboardEnabled.isTrue
|
? keyboardEnabled.isTrue
|
||||||
? (remoteCursorMoved.isTrue
|
? (remoteCursorMoved.isTrue
|
||||||
? SystemMouseCursors.none
|
? SystemMouseCursors.none
|
||||||
: _buildCustomCursorLinux(context, s))
|
: _buildCustomCursor(context, s))
|
||||||
: _buildDisabledCursor(context, s)
|
: _buildDisabledCursor(context, s)
|
||||||
: MouseCursor.defer,
|
: MouseCursor.defer,
|
||||||
onHover: (evt) {},
|
onHover: (evt) {},
|
||||||
@ -333,31 +333,31 @@ class ImagePaint extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseCursor _buildCustomCursorLinux(BuildContext context, double scale) {
|
MouseCursor _buildCustomCursor(BuildContext context, double scale) {
|
||||||
final cursor = Provider.of<CursorModel>(context);
|
final cursor = Provider.of<CursorModel>(context);
|
||||||
final cacheLinux = cursor.cacheLinux;
|
final cache = cursor.cache ?? cursor.defaultCache;
|
||||||
if (cacheLinux == null) {
|
if (cache == null) {
|
||||||
return MouseCursor.defer;
|
return MouseCursor.defer;
|
||||||
} else {
|
} else {
|
||||||
final key = cacheLinux.updateGetKey(scale);
|
final key = cache.updateGetKey(scale);
|
||||||
cursor.addKey(key);
|
cursor.addKey(key);
|
||||||
return FlutterCustomMemoryImageCursor(
|
return FlutterCustomMemoryImageCursor(
|
||||||
pixbuf: cacheLinux.data,
|
pixbuf: cache.data,
|
||||||
key: key,
|
key: key,
|
||||||
// hotx: cacheLinux.hotx,
|
// hotx: cache.hotx,
|
||||||
// hoty: cacheLinux.hoty,
|
// hoty: cache.hoty,
|
||||||
hotx: 0,
|
hotx: 0,
|
||||||
hoty: 0,
|
hoty: 0,
|
||||||
imageWidth: (cacheLinux.width * cacheLinux.scale).toInt(),
|
imageWidth: (cache.width * cache.scale).toInt(),
|
||||||
imageHeight: (cacheLinux.height * cacheLinux.scale).toInt(),
|
imageHeight: (cache.height * cache.scale).toInt(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseCursor _buildDisabledCursor(BuildContext context, double scale) {
|
MouseCursor _buildDisabledCursor(BuildContext context, double scale) {
|
||||||
final cursor = Provider.of<CursorModel>(context);
|
final cursor = Provider.of<CursorModel>(context);
|
||||||
final cacheLinux = cursor.cacheLinux;
|
final cache = cursor.cache;
|
||||||
if (cacheLinux == null) {
|
if (cache == null) {
|
||||||
return MouseCursor.defer;
|
return MouseCursor.defer;
|
||||||
} else {
|
} else {
|
||||||
if (cursor.cachedForbidmemoryCursorData == null) {
|
if (cursor.cachedForbidmemoryCursorData == null) {
|
||||||
@ -368,8 +368,8 @@ class ImagePaint extends StatelessWidget {
|
|||||||
return FlutterCustomMemoryImageCursor(
|
return FlutterCustomMemoryImageCursor(
|
||||||
pixbuf: cursor.cachedForbidmemoryCursorData,
|
pixbuf: cursor.cachedForbidmemoryCursorData,
|
||||||
key: key,
|
key: key,
|
||||||
hotx: cacheLinux.hotx,
|
hotx: 0,
|
||||||
hoty: cacheLinux.hoty,
|
hoty: 0,
|
||||||
imageWidth: 32,
|
imageWidth: 32,
|
||||||
imageHeight: 32,
|
imageHeight: 32,
|
||||||
);
|
);
|
||||||
|
@ -724,6 +724,8 @@ class CursorModel with ChangeNotifier {
|
|||||||
ui.Image? _image;
|
ui.Image? _image;
|
||||||
final _images = <int, Tuple3<ui.Image, double, double>>{};
|
final _images = <int, Tuple3<ui.Image, double, double>>{};
|
||||||
CursorData? _cache;
|
CursorData? _cache;
|
||||||
|
final _defaultCacheId = -1;
|
||||||
|
CursorData? _defaultCache;
|
||||||
final _cacheMap = <int, CursorData>{};
|
final _cacheMap = <int, CursorData>{};
|
||||||
final _cacheKeys = <String>{};
|
final _cacheKeys = <String>{};
|
||||||
double _x = -10000;
|
double _x = -10000;
|
||||||
@ -736,7 +738,8 @@ class CursorModel with ChangeNotifier {
|
|||||||
WeakReference<FFI> parent;
|
WeakReference<FFI> parent;
|
||||||
|
|
||||||
ui.Image? get image => _image;
|
ui.Image? get image => _image;
|
||||||
CursorData? get cacheLinux => _cache;
|
CursorData? get cache => _cache;
|
||||||
|
CursorData? get defaultCache => _getDefaultCache();
|
||||||
|
|
||||||
double get x => _x - _displayOriginX;
|
double get x => _x - _displayOriginX;
|
||||||
|
|
||||||
@ -753,6 +756,29 @@ class CursorModel with ChangeNotifier {
|
|||||||
Set<String> get cachedKeys => _cacheKeys;
|
Set<String> get cachedKeys => _cacheKeys;
|
||||||
addKey(String key) => _cacheKeys.add(key);
|
addKey(String key) => _cacheKeys.add(key);
|
||||||
|
|
||||||
|
CursorData? _getDefaultCache() {
|
||||||
|
if (_defaultCache == null) {
|
||||||
|
if (Platform.isWindows) {
|
||||||
|
Uint8List data = defaultCursorImage!.getBytes(format: img2.Format.bgra);
|
||||||
|
_hotx = defaultCursorImage!.width / 2;
|
||||||
|
_hoty = defaultCursorImage!.height / 2;
|
||||||
|
|
||||||
|
_defaultCache = CursorData(
|
||||||
|
peerId: id,
|
||||||
|
id: _defaultCacheId,
|
||||||
|
image: defaultCursorImage?.clone(),
|
||||||
|
scale: 1.0,
|
||||||
|
data: data,
|
||||||
|
hotx: _hotx,
|
||||||
|
hoty: _hoty,
|
||||||
|
width: defaultCursorImage!.width,
|
||||||
|
height: defaultCursorImage!.height,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _defaultCache;
|
||||||
|
}
|
||||||
|
|
||||||
// remote physical display coordinate
|
// remote physical display coordinate
|
||||||
Rect getVisibleRect() {
|
Rect getVisibleRect() {
|
||||||
final size = MediaQueryData.fromWindow(ui.window).size;
|
final size = MediaQueryData.fromWindow(ui.window).size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user