mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Fix window resizing in headed mode (#133)
* Resize the surface_config in reconfigure * Create a resize_configure function for window
This commit is contained in:
parent
172d64f1b3
commit
f0f244ee65
@ -39,6 +39,11 @@ pub struct WindowHead {
|
||||
}
|
||||
|
||||
impl WindowHead {
|
||||
pub fn resize_and_configure(&mut self, width: u32, height: u32, device: &wgpu::Device) {
|
||||
self.surface_config.height = width;
|
||||
self.surface_config.width = height;
|
||||
self.surface.configure(device, &self.surface_config);
|
||||
}
|
||||
pub fn configure(&self, device: &wgpu::Device) {
|
||||
self.surface.configure(device, &self.surface_config);
|
||||
}
|
||||
@ -225,20 +230,13 @@ impl Surface {
|
||||
|
||||
pub fn resize(&mut self, width: u32, height: u32) {
|
||||
self.size = WindowSize::new(width, height).expect("Invalid size for resizing the surface.");
|
||||
match &mut self.head {
|
||||
Head::Headed(window) => {
|
||||
window.surface_config.height = height;
|
||||
window.surface_config.width = width;
|
||||
}
|
||||
Head::Headless(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reconfigure(&mut self, device: &wgpu::Device) {
|
||||
match &mut self.head {
|
||||
Head::Headed(window) => {
|
||||
if window.has_changed(&(self.size.width(), self.size.height())) {
|
||||
window.configure(device);
|
||||
window.resize_and_configure(self.size.height(), self.size.width(), device);
|
||||
}
|
||||
}
|
||||
Head::Headless(_) => {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user