mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-18 02:10:59 +03:00
fix(cursor): align Web hotspots with rounded cursor images
This commit is contained in:
@@ -2920,8 +2920,8 @@ class CursorData {
|
||||
img2.encodePng(
|
||||
img2.copyResize(
|
||||
image,
|
||||
width: (width * scale).toInt(),
|
||||
height: (height * scale).toInt(),
|
||||
width: isWeb ? (width * scale).round() : (width * scale).toInt(),
|
||||
height: isWeb ? (height * scale).round() : (height * scale).toInt(),
|
||||
interpolation: img2.Interpolation.average,
|
||||
),
|
||||
),
|
||||
@@ -2932,6 +2932,11 @@ class CursorData {
|
||||
this.scale = scale;
|
||||
hotx = hotxOrigin * scale;
|
||||
hoty = hotyOrigin * scale;
|
||||
if (isWeb) {
|
||||
// CSS hotspots must follow the actual rounded PNG dimensions.
|
||||
hotx = hotxOrigin * (width * scale).round() / width;
|
||||
hoty = hotyOrigin * (height * scale).round() / height;
|
||||
}
|
||||
return scale;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ class CursorManager {
|
||||
'cursor',
|
||||
jsonEncode({
|
||||
'url': cursorData.url,
|
||||
'hotx': cursorData.hotX.toInt(),
|
||||
'hoty': cursorData.hotY.toInt(),
|
||||
'hotx': cursorData.hotX.round(),
|
||||
'hoty': cursorData.hotY.round(),
|
||||
})
|
||||
]);
|
||||
}
|
||||
@@ -116,8 +116,8 @@ MouseCursor buildCursorOfCache(
|
||||
CursorManager.instance.registerCursor(CursorData(
|
||||
key: key,
|
||||
url: 'data:image/rgba;base64,${base64Encode(data)}',
|
||||
width: (cache.width * cache.scale).toInt(),
|
||||
height: (cache.height * cache.scale).toInt(),
|
||||
width: (cache.width * cache.scale).round(),
|
||||
height: (cache.height * cache.scale).round(),
|
||||
hotX: cache.hotx,
|
||||
hotY: cache.hoty));
|
||||
cursor.addKey(key);
|
||||
|
||||
Reference in New Issue
Block a user