fix(flutter): preserve cursor minimum sizes and native hotspots

This commit is contained in:
fufesou
2026-09-11 13:51:24 +08:00
parent d202a2fba4
commit 7bb3fe6b5a
3 changed files with 65 additions and 26 deletions

View File

@@ -2893,7 +2893,7 @@ class CursorData {
double _checkUpdateScale(double scale) {
double oldScale = this.scale;
if (!_usesLogicalCursorPixels && scale != 1.0) {
if (scale != 1.0) {
// Update data if scale changed.
final tgtWidth = (width * scale).toInt();
final tgtHeight = (height * scale).toInt();
@@ -2929,8 +2929,8 @@ class CursorData {
}
this.scale = scale;
hotx = hotxOrigin * (_usesLogicalCursorPixels ? scaledWidth / width : scale);
hoty = hotyOrigin * (_usesLogicalCursorPixels ? scaledHeight / height : scale);
hotx = hotxOrigin * scaledWidth / width;
hoty = hotyOrigin * scaledHeight / height;
return scale;
}

View File

@@ -16,8 +16,8 @@ deleteCustomCursor(String key) =>
resetSystemCursor() {}
double _nativeHotspot(double hotspot, int bitmapSize) {
if (!isLinux) return hotspot;
// GDK takes integer hotspots inside the bitmap; avoid truncating toward zero.
if (!isLinux && !isWindows) return hotspot;
// GDK and Win32 take integer hotspots inside the bitmap; use the nearest pixel.
return min(hotspot.round(), bitmapSize - 1).toDouble();
}