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

@@ -609,7 +609,22 @@ impl FlutterHandler {
h.insert("original_width", original_resolution.width);
h.insert("original_height", original_resolution.height);
}
h.insert("scale", (d.scale * 100.0f64) as i32);
// Don't convert scale (x 100) to i32 directly.
// (d.scale * 100.0f64) as i32 may produces inaccuracies.
//
// Example: GNOME Wayland with Fractional Scaling enabled:
// - Physical resolution: 2560x1600
// - Logical resolution: 1074x1065
// - Scale factor: 150%
// Passing physical dimensions and scale factor prevents accurate logical resolution calculation
// since 2560/1.5 = 1706.666... (rounded to 1706.67) and 1600/1.5 = 1066.666... (rounded to 1066.67)
// h.insert("scale", (d.scale * 100.0f64) as i32);
// Send scaled_width for accurate logical scale calculation.
if d.scale > 0.0 {
let scaled_width = (d.width as f64 / d.scale).round() as i32;
h.insert("scaled_width", scaled_width);
}
msg_vec.push(h);
}
serde_json::ser::to_string(&msg_vec).unwrap_or("".to_owned())
@@ -679,7 +694,7 @@ impl InvokeUiSession for FlutterHandler {
}
/// unused in flutter, use switch_display or set_peer_info
fn set_display(&self, _x: i32, _y: i32, _w: i32, _h: i32, _cursor_embedded: bool) {}
fn set_display(&self, _x: i32, _y: i32, _w: i32, _h: i32, _cursor_embedded: bool, _scale: f64) {}
fn update_privacy_mode(&self) {
self.push_event::<&str>("update_privacy_mode", &[], &[]);