mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-10 06:21:02 +03: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:
@@ -9,7 +9,7 @@ use std::collections::HashMap;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub mod client {
|
pub mod client {
|
||||||
use hbb_common::platform::linux::is_kde;
|
use hbb_common::platform::linux::{DISPLAY_DESKTOP_KDE, XDG_CURRENT_DESKTOP};
|
||||||
|
|
||||||
use super::*;
|
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 {
|
pub struct RdpInputMouse {
|
||||||
conn: Arc<SyncConnection>,
|
conn: Arc<SyncConnection>,
|
||||||
session: Path<'static>,
|
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:
|
// 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).
|
// Logic coordinate from (0,0) to (200x150).
|
||||||
// Or physical coordinate from (0,0) to (400,300).
|
// 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 {
|
if resolution.0 == 0 || stream.get_size().0 == 0 {
|
||||||
Some(1.0f64)
|
Some(1.0f64)
|
||||||
} else {
|
} 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 {
|
impl MouseControllable for RdpInputMouse {
|
||||||
fn as_any(&self) -> &dyn std::any::Any {
|
fn as_any(&self) -> &dyn std::any::Any {
|
||||||
self
|
self
|
||||||
|
|||||||
Reference in New Issue
Block a user