Windows: impl WindowsDisplay (#9287)

Tested on my laptop, and I've noticed that when I move the window,
`WindowsPlatform::displays()` is being continuously called. Is this
intended?

Release Notes:

- N/A
This commit is contained in:
张小白 2024-03-14 04:08:11 +08:00 committed by GitHub
parent 36cbfbfb94
commit 3274cc93df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 173 additions and 37 deletions

View file

@ -637,6 +637,7 @@ struct Callbacks {
pub(crate) struct WindowsWindow {
inner: Rc<WindowsWindowInner>,
drag_drop_handler: IDropTarget,
display: Rc<WindowsDisplay>,
}
struct WindowCreateContext {
@ -701,9 +702,12 @@ impl WindowsWindow {
};
drag_drop_handler
};
// todo(windows) move window to target monitor
// options.display_id
let wnd = Self {
inner: context.inner.unwrap(),
drag_drop_handler,
display: Rc::new(WindowsDisplay::primary_monitor().unwrap()),
};
platform_inner
.raw_window_handles
@ -780,9 +784,8 @@ impl PlatformWindow for WindowsWindow {
WindowAppearance::Dark
}
// todo(windows)
fn display(&self) -> Rc<dyn PlatformDisplay> {
Rc::new(WindowsDisplay::new())
self.display.clone()
}
fn mouse_position(&self) -> Point<Pixels> {