WindowAdaptor: move a few function to the public trait

Note: the addition of MinimalSoftwareWindow::set_size is there because
it would be a breaking change for user who called set_size on the
MinimalSoftwareWindow while also using the WindowAdapter trait.
This was the case of a test.
The same problem theorically exist with set_position and position, but
is unlikely to be a problem because i don't think people would use the
position with a MinimalSoftwareWindow

The renderer() is now public as well. That's because I want to make sure
that the scealed trait don't have non-provided method
This commit is contained in:
Olivier Goffart 2023-06-13 12:20:28 +02:00 committed by Olivier Goffart
parent 401a6dda4d
commit 6341769cbd
7 changed files with 150 additions and 138 deletions

View file

@ -43,13 +43,18 @@ impl WindowAdapter for CppWindowAdapter {
fn window(&self) -> &Window {
&self.window
}
}
impl WindowAdapterSealed for CppWindowAdapter {
fn size(&self) -> PhysicalSize {
let s = unsafe { (self.size)(self.user_data) };
PhysicalSize::new(s.width, s.height)
}
fn renderer(&self) -> &dyn Renderer {
unsafe { core::mem::transmute((self.get_renderer_ref)(self.user_data)) }
}
}
impl WindowAdapterSealed for CppWindowAdapter {
fn show(&self) -> Result<(), PlatformError> {
unsafe { (self.show)(self.user_data) };
Ok(())
@ -62,11 +67,6 @@ impl WindowAdapterSealed for CppWindowAdapter {
fn request_redraw(&self) {
unsafe { (self.request_redraw)(self.user_data) }
}
fn size(&self) -> PhysicalSize {
let s = unsafe { (self.size)(self.user_data) };
PhysicalSize::new(s.width, s.height)
}
}
#[no_mangle]