mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-19 10:51:01 +03:00
fix(flutter): correct cursor scaling and Linux cursor clipping
Keep Linux/macOS bitmap sizing and painted cursor DPI conversion consistent, and derive hotspots from the actual scaled bitmap. Pad tall Linux native cursor buffers with transparency to preserve the lower half in the hardware cursor plane. Cover bitmap sizing, hotspots, artwork preservation, and painting with focused regression tests.
This commit is contained in:
@@ -2879,9 +2879,21 @@ class CursorData {
|
||||
|
||||
int _doubleToInt(double v) => (v * 10e6).round().toInt();
|
||||
|
||||
bool get _usesLogicalCursorPixels => isLinux || isMacOS;
|
||||
int get scaledWidth => _scaledDimension(width, scale);
|
||||
int get scaledHeight => _scaledDimension(height, scale);
|
||||
|
||||
int _scaledDimension(int dimension, double scale) {
|
||||
const minBitmapSize = 1;
|
||||
final pixels = dimension * scale;
|
||||
return _usesLogicalCursorPixels
|
||||
? max(minBitmapSize, pixels.round())
|
||||
: pixels.toInt();
|
||||
}
|
||||
|
||||
double _checkUpdateScale(double scale) {
|
||||
double oldScale = this.scale;
|
||||
if (scale != 1.0) {
|
||||
if (!_usesLogicalCursorPixels && scale != 1.0) {
|
||||
// Update data if scale changed.
|
||||
final tgtWidth = (width * scale).toInt();
|
||||
final tgtHeight = (height * scale).toInt();
|
||||
@@ -2907,8 +2919,8 @@ class CursorData {
|
||||
img2.encodePng(
|
||||
img2.copyResize(
|
||||
image,
|
||||
width: (width * scale).toInt(),
|
||||
height: (height * scale).toInt(),
|
||||
width: _scaledDimension(width, scale),
|
||||
height: _scaledDimension(height, scale),
|
||||
interpolation: img2.Interpolation.average,
|
||||
),
|
||||
),
|
||||
@@ -2917,8 +2929,8 @@ class CursorData {
|
||||
}
|
||||
|
||||
this.scale = scale;
|
||||
hotx = hotxOrigin * scale;
|
||||
hoty = hotyOrigin * scale;
|
||||
hotx = hotxOrigin * (_usesLogicalCursorPixels ? scaledWidth / width : scale);
|
||||
hoty = hotyOrigin * (_usesLogicalCursorPixels ? scaledHeight / height : scale);
|
||||
return scale;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user