mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
better support for win7
This commit is contained in:
@@ -62,13 +62,23 @@ pub struct Display(dxgi::Display);
|
||||
|
||||
impl Display {
|
||||
pub fn primary() -> io::Result<Display> {
|
||||
match dxgi::Displays::new()?.next() {
|
||||
Some(inner) => Ok(Display(inner)),
|
||||
None => Err(NotFound.into()),
|
||||
}
|
||||
// not implemented yet
|
||||
Err(NotFound.into())
|
||||
}
|
||||
|
||||
pub fn all() -> io::Result<Vec<Display>> {
|
||||
let tmp = Self::all_().unwrap_or(Default::default());
|
||||
if tmp.is_empty() {
|
||||
println!("Display got from gdi");
|
||||
return Ok(dxgi::Displays::get_from_gdi()
|
||||
.drain(..)
|
||||
.map(Display)
|
||||
.collect::<Vec<_>>());
|
||||
}
|
||||
Ok(tmp)
|
||||
}
|
||||
|
||||
fn all_() -> io::Result<Vec<Display>> {
|
||||
Ok(dxgi::Displays::new()?.map(Display).collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
@@ -92,13 +102,12 @@ impl Display {
|
||||
self.0.is_online()
|
||||
}
|
||||
|
||||
pub fn origin(&self) -> (usize, usize) {
|
||||
let o = self.0.origin();
|
||||
(o.0 as usize, o.1 as usize)
|
||||
pub fn origin(&self) -> (i32, i32) {
|
||||
self.0.origin()
|
||||
}
|
||||
|
||||
// to-do: not found primary display api for dxgi
|
||||
pub fn is_primary(&self) -> bool {
|
||||
self.name() == Self::primary().unwrap().name()
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-devmodea
|
||||
self.origin() == (0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,9 +114,9 @@ impl Display {
|
||||
self.0.is_online()
|
||||
}
|
||||
|
||||
pub fn origin(&self) -> (usize, usize) {
|
||||
pub fn origin(&self) -> (i32, i32) {
|
||||
let o = self.0.bounds().origin;
|
||||
(o.x as usize, o.y as usize)
|
||||
(o.x as _, o.y as _)
|
||||
}
|
||||
|
||||
pub fn is_primary(&self) -> bool {
|
||||
|
||||
@@ -68,7 +68,7 @@ impl Display {
|
||||
self.0.rect().h as usize
|
||||
}
|
||||
|
||||
pub fn origin(&self) -> (usize, usize) {
|
||||
pub fn origin(&self) -> (i32, i32) {
|
||||
let r = self.0.rect();
|
||||
(r.x as _, r.y as _)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user