mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-08-23 22:56:41 +00:00
fix(wayland): scale portal pointer coordinates on niri (#15683)
* fix(wayland): scale portal pointer coordinates on niri * perf(wayland): cache portal scaling desktop check
This commit is contained in:
+28
-2
@@ -9,7 +9,7 @@ use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub mod client {
|
||||
use hbb_common::platform::linux::is_kde;
|
||||
use hbb_common::platform::linux::{DISPLAY_DESKTOP_KDE, XDG_CURRENT_DESKTOP};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -302,6 +302,19 @@ pub mod client {
|
||||
}
|
||||
}
|
||||
|
||||
fn desktop_is_niri(desktop: &str) -> bool {
|
||||
desktop
|
||||
.split(':')
|
||||
.any(|name| name.eq_ignore_ascii_case("niri"))
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref SHOULD_SCALE_POINTER_COORDINATES: bool =
|
||||
std::env::var(XDG_CURRENT_DESKTOP)
|
||||
.map(|desktop| desktop == DISPLAY_DESKTOP_KDE || desktop_is_niri(&desktop))
|
||||
.unwrap_or(false);
|
||||
}
|
||||
|
||||
pub struct RdpInputMouse {
|
||||
conn: Arc<SyncConnection>,
|
||||
session: Path<'static>,
|
||||
@@ -327,7 +340,7 @@ pub mod client {
|
||||
// For Ubuntu 24.04(Gnome 46), (x,y) is restricted from (0,0) to (400,300), but the actual range in screen is:
|
||||
// Logic coordinate from (0,0) to (200x150).
|
||||
// Or physical coordinate from (0,0) to (400,300).
|
||||
let scale = if is_kde() {
|
||||
let scale = if *SHOULD_SCALE_POINTER_COORDINATES {
|
||||
if resolution.0 == 0 || stream.get_size().0 == 0 {
|
||||
Some(1.0f64)
|
||||
} else {
|
||||
@@ -348,6 +361,19 @@ pub mod client {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::desktop_is_niri;
|
||||
|
||||
#[test]
|
||||
fn detects_niri_in_desktop_list() {
|
||||
assert!(desktop_is_niri("niri"));
|
||||
assert!(desktop_is_niri("NIRI"));
|
||||
assert!(desktop_is_niri("GNOME:niri"));
|
||||
assert!(!desktop_is_niri("GNOME"));
|
||||
}
|
||||
}
|
||||
|
||||
impl MouseControllable for RdpInputMouse {
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
|
||||
Reference in New Issue
Block a user