mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-09 20:04:25 +00:00
windows: get current display size (#8916)
For the moment the windows port has a single display with hard-coded values. This first PR is just to at least fetch the **actual size of the current display**. The idea is using this code as a first template to start getting familar with the code base and prepare the work for enumerating all displays.
This commit is contained in:
parent
0b87be71e6
commit
74e7611ceb
1 changed files with 15 additions and 3 deletions
|
@ -1,5 +1,9 @@
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
use windows::{
|
||||||
|
core::PCSTR,
|
||||||
|
Win32::Graphics::Gdi::{EnumDisplaySettingsA, DEVMODEA, ENUM_CURRENT_SETTINGS},
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{Bounds, DisplayId, GlobalPixels, PlatformDisplay, Point, Size};
|
use crate::{Bounds, DisplayId, GlobalPixels, PlatformDisplay, Point, Size};
|
||||||
|
|
||||||
|
@ -23,13 +27,21 @@ impl PlatformDisplay for WindowsDisplay {
|
||||||
Err(anyhow!("not implemented yet."))
|
Err(anyhow!("not implemented yet."))
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo!("windows")
|
|
||||||
fn bounds(&self) -> Bounds<GlobalPixels> {
|
fn bounds(&self) -> Bounds<GlobalPixels> {
|
||||||
|
let mut dev = DEVMODEA {
|
||||||
|
dmSize: std::mem::size_of::<DEVMODEA>() as _,
|
||||||
|
..unsafe { std::mem::zeroed() }
|
||||||
|
};
|
||||||
|
unsafe { EnumDisplaySettingsA(PCSTR::null(), ENUM_CURRENT_SETTINGS, &mut dev) };
|
||||||
|
let w = dev.dmPelsWidth;
|
||||||
|
let h = dev.dmPelsHeight;
|
||||||
|
|
||||||
|
log::debug!("Screen size: {w} {h}");
|
||||||
Bounds::new(
|
Bounds::new(
|
||||||
Point::new(0.0.into(), 0.0.into()),
|
Point::new(0.0.into(), 0.0.into()),
|
||||||
Size {
|
Size {
|
||||||
width: 1920.0.into(),
|
width: GlobalPixels(w as f32),
|
||||||
height: 1280.0.into(),
|
height: GlobalPixels(h as f32),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue