fix: wayland controlled side, cursor misalignment (#13537)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2025-11-18 00:37:15 +08:00
committed by GitHub
parent a6571e71e4
commit b2dff336ce
22 changed files with 1241 additions and 187 deletions

View File

@@ -159,6 +159,8 @@ class FfiModel with ChangeNotifier {
bool get isPeerAndroid => _pi.platform == kPeerPlatformAndroid;
bool get isPeerMobile => isPeerAndroid;
bool get isPeerLinux => _pi.platform == kPeerPlatformLinux;
bool get viewOnly => _viewOnly;
bool get showMyCursor => _showMyCursor;
@@ -179,6 +181,9 @@ class FfiModel with ChangeNotifier {
if (displays.isEmpty) {
return null;
}
if (isPeerLinux) {
useDisplayScale = true;
}
int scale(int len, double s) {
if (useDisplayScale) {
return len.toDouble() ~/ s;
@@ -1076,18 +1081,17 @@ class FfiModel with ChangeNotifier {
if (displays.length == 1) {
bind.sessionSetSize(
sessionId: sessionId,
display:
pi.currentDisplay == kAllDisplayValue ? 0 : pi.currentDisplay,
width: _rect!.width.toInt(),
height: _rect!.height.toInt(),
display: pi.currentDisplay == kAllDisplayValue ? 0 : pi.currentDisplay,
width: displays[0].width,
height: displays[0].height,
);
} else {
for (int i = 0; i < displays.length; ++i) {
bind.sessionSetSize(
sessionId: sessionId,
display: i,
width: displays[i].width.toInt(),
height: displays[i].height.toInt(),
width: displays[i].width,
height: displays[i].height,
);
}
}
@@ -1436,8 +1440,17 @@ class FfiModel with ChangeNotifier {
d.cursorEmbedded = evt['cursor_embedded'] == 1;
d.originalWidth = evt['original_width'] ?? kInvalidResolutionValue;
d.originalHeight = evt['original_height'] ?? kInvalidResolutionValue;
double v = (evt['scale']?.toDouble() ?? 100.0) / 100;
d._scale = v > 1.0 ? v : 1.0;
d._scale = 1.0;
final scaledWidth = evt['scaled_width'];
if (scaledWidth != null) {
final sw = int.tryParse(scaledWidth.toString());
if (sw != null && sw > 0 && d.width > 0) {
d._scale = max(d.width.toDouble() / sw, 1.0);
} else {
debugPrint(
"Invalid scaled_width ($scaledWidth) or width (${d.width}), using default scale 1.0");
}
}
return d;
}
@@ -2438,11 +2451,6 @@ class CanvasModel with ChangeNotifier {
notifyListeners();
}
set scale(v) {
_scale = v;
notifyListeners();
}
panX(double dx) {
_x += dx;
if (isMobile) {
@@ -2976,9 +2984,10 @@ class CursorModel with ChangeNotifier {
var cx = r.center.dx;
var cy = r.center.dy;
var tryMoveCanvasX = false;
final displayRect = parent.target?.ffiModel.rect;
if (dx > 0) {
final maxCanvasCanMove = _displayOriginX +
(parent.target?.imageModel.image!.width ?? 1280) -
(displayRect?.width ?? 1280) -
r.right.roundToDouble();
tryMoveCanvasX = _x + dx > cx && maxCanvasCanMove > 0;
if (tryMoveCanvasX) {
@@ -3000,7 +3009,7 @@ class CursorModel with ChangeNotifier {
var tryMoveCanvasY = false;
if (dy > 0) {
final mayCanvasCanMove = _displayOriginY +
(parent.target?.imageModel.image!.height ?? 720) -
(displayRect?.height ?? 720) -
r.bottom.roundToDouble();
tryMoveCanvasY = _y + dy > cy && mayCanvasCanMove > 0;
if (tryMoveCanvasY) {