Fix issues where screen and window sizes contained Pixels, but were declared as DevicePixels (#12991)

On most platforms, things were working correctly, but had the wrong
type. On X11, there were some problems with window and display size
calculations.

Release Notes:

- Fixed issues with window positioning on X11

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Max Brunsfeld
2024-06-13 10:48:37 -07:00
committed by GitHub
co-authored by Conrad Irwin Mikayla
parent 22dc88ed3d
commit da281d6d8f
25 changed files with 331 additions and 367 deletions
+4 -7
View File
@@ -1,4 +1,4 @@
use crate::{point, size, Bounds, DevicePixels, DisplayId, PlatformDisplay};
use crate::{px, size, Bounds, DisplayId, Pixels, PlatformDisplay};
use anyhow::Result;
use cocoa::{
appkit::NSScreen,
@@ -102,18 +102,15 @@ impl PlatformDisplay for MacDisplay {
]))
}
fn bounds(&self) -> Bounds<DevicePixels> {
fn bounds(&self) -> Bounds<Pixels> {
unsafe {
// CGDisplayBounds is in "global display" coordinates, where 0 is
// the top left of the primary display.
let bounds = CGDisplayBounds(self.0);
Bounds {
origin: point(DevicePixels(0), DevicePixels(0)),
size: size(
DevicePixels(bounds.size.width as i32),
DevicePixels(bounds.size.height as i32),
),
origin: Default::default(),
size: size(px(bounds.size.width as f32), px(bounds.size.height as f32)),
}
}
}