Skip to content

Commit 6ede3f1

Browse files
committed
refactor(uikit): screen frame
1 parent 589a103 commit 6ede3f1

2 files changed

Lines changed: 9 additions & 24 deletions

File tree

winio-ui-ui-kit/src/ui/monitor.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,15 @@ pub fn monitor_get_all() -> Result<Vec<Monitor>> {
99
let mut res = vec![];
1010
catch(|| {
1111
let app = UIApplication::sharedApplication(mtm);
12-
for session in app.openSessions() {
13-
if let Some(scene) = session.scene()
14-
&& let Ok(scene) = Retained::downcast::<UIWindowScene>(scene)
15-
{
12+
for scene in app.connectedScenes() {
13+
if let Ok(scene) = Retained::downcast::<UIWindowScene>(scene) {
1614
let screen = scene.screen();
1715
let bounds = screen.bounds();
1816
let frame_size = from_cgsize(bounds.size);
1917
let frame = Rect::new(Point::zero(), frame_size);
2018

21-
let dpi = screen
22-
.currentMode()
23-
.map(|mode| from_cgsize(mode.size()))
24-
.unwrap_or(Size::new(1.0, 1.0));
25-
26-
let native_scale = screen.nativeScale();
27-
let dpi = Size::new(dpi.width / native_scale, dpi.height / native_scale);
19+
let scale = screen.scale();
20+
let dpi = Size::new(scale, scale);
2821

2922
res.push(Monitor::new(frame, frame, dpi));
3023
}

winio-ui-ui-kit/src/ui/window.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use winio_handle::{
1212
use winio_primitive::{Point, Size};
1313

1414
use crate::{
15-
Error, RESIZE_SLAB, Result, catch, first_ui_window_scene, from_cgpoint, from_cgrect,
16-
from_cgsize, to_cgpoint, to_cgsize,
15+
Error, RESIZE_SLAB, Result, catch, first_ui_window_scene, from_cgpoint, from_cgsize,
16+
to_cgpoint, to_cgsize,
1717
};
1818

1919
#[derive(Debug)]
@@ -80,19 +80,11 @@ impl Window {
8080
}
8181

8282
pub fn loc(&self) -> Result<Point> {
83-
catch(|| {
84-
let frame = self.wnd.frame();
85-
Ok(from_cgrect(frame).origin)
86-
})
87-
.flatten()
83+
Ok(Point::zero())
8884
}
8985

90-
pub fn set_loc(&mut self, p: Point) -> Result<()> {
91-
catch(|| {
92-
let mut frame = self.wnd.frame();
93-
frame.origin = to_cgpoint(p);
94-
self.wnd.setFrame(frame);
95-
})
86+
pub fn set_loc(&mut self, _p: Point) -> Result<()> {
87+
Ok(())
9688
}
9789

9890
pub fn size(&self) -> Result<Size> {

0 commit comments

Comments
 (0)