From 2eb9de65028dbd4843f1a7fa2e4d314b08cfd65e Mon Sep 17 00:00:00 2001 From: Emil Date: Sun, 21 Jun 2026 01:17:32 +0300 Subject: [PATCH] fix: use window inner_size() for resize on Wayland MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/render/graphics.rs | 11 ++++++++--- src/render/vulkan.rs | 9 ++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/render/graphics.rs b/src/render/graphics.rs index 07914ea..470138a 100644 --- a/src/render/graphics.rs +++ b/src/render/graphics.rs @@ -65,7 +65,7 @@ pub struct GraphicsRenderer { instance_ptr: *mut ColorInstance, instance_count: usize, - _window: Arc, + window: Arc, } 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 diff --git a/src/render/vulkan.rs b/src/render/vulkan.rs index a3f71d9..2f46243 100644 --- a/src/render/vulkan.rs +++ b/src/render/vulkan.rs @@ -85,6 +85,7 @@ pub struct VulkanRenderer { descriptor_set: vk::DescriptorSet, descriptor_set_layout: vk::DescriptorSetLayout, tick_count: u64, + window: Arc, } 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