fix: use window inner_size() for resize on Wayland

Wayland surface always reports current_extent as 0xFFFFFFFF (undefined),
meaning the swapchain size is determined by the application, not the
surface. Previous code returned early when this happened, so resize
never worked — cells stretched to fill the window.

Fix: when current_extent is 0xFFFFFFFF, use winit's window.inner_size()
to get the actual pixel dimensions. This works on both X11 and Wayland.

Both renderers (ascii + graphics) updated.
109 tests, 0 failures
This commit is contained in:
Emil
2026-06-21 01:17:32 +03:00
parent 57a88fd41e
commit 2eb9de6502
2 changed files with 16 additions and 4 deletions
+8 -3
View File
@@ -65,7 +65,7 @@ pub struct GraphicsRenderer {
instance_ptr: *mut ColorInstance,
instance_count: usize,
_window: Arc<winit::window::Window>,
window: Arc<winit::window::Window>,
}
impl GraphicsRenderer {
@@ -300,7 +300,7 @@ impl GraphicsRenderer {
image_available, render_finished, in_flight, frame_index: 0,
vertex_buffer, vertex_memory, index_buffer, index_memory,
instance_buffer, instance_memory, instance_ptr, instance_count,
_window: window,
window,
})
}
@@ -451,7 +451,12 @@ impl GraphicsRenderer {
let new_extent = if caps.current_extent.width != u32::MAX {
caps.current_extent
} else {
return;
// Wayland: surface extent is undefined, use window inner size
let inner = self.window.inner_size();
vk::Extent2D {
width: inner.width.max(1),
height: inner.height.max(1),
}
};
if new_extent.width == self.swapchain_extent.width
+8 -1
View File
@@ -85,6 +85,7 @@ pub struct VulkanRenderer {
descriptor_set: vk::DescriptorSet,
descriptor_set_layout: vk::DescriptorSetLayout,
tick_count: u64,
window: Arc<winit::window::Window>,
}
impl VulkanRenderer {
@@ -157,6 +158,7 @@ impl VulkanRenderer {
instance_buffer, instance_memory, instance_ptr, instance_count,
descriptor_pool, descriptor_set, descriptor_set_layout,
tick_count: 0,
window,
})
}
@@ -321,7 +323,12 @@ impl VulkanRenderer {
let new_extent = if caps.current_extent.width != u32::MAX {
caps.current_extent
} else {
return;
// Wayland: surface extent is undefined, use window inner size
let inner = self.window.inner_size();
vk::Extent2D {
width: inner.width.max(1),
height: inner.height.max(1),
}
};
if new_extent.width == self.swapchain_extent.width