diff options
| author | PancakeTAS <pancake@mgnet.work> | 2025-09-20 15:22:07 +0200 |
|---|---|---|
| committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2025-09-22 13:35:50 -0600 |
| commit | e3ecc39da57a5ed15ec8de67f136273ee54b78be (patch) | |
| tree | 6bb94b8855632656c23dbda6d99b6dde76f147ce /cube/cube.cpp | |
| parent | 22fee0e85d0d31af603bf591f70530c1c83ba186 (diff) | |
| download | usermoji-e3ecc39da57a5ed15ec8de67f136273ee54b78be.tar.xz | |
cube: Resize surface after configure
Diffstat (limited to 'cube/cube.cpp')
| -rw-r--r-- | cube/cube.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/cube/cube.cpp b/cube/cube.cpp index 7f4b45d2..04ba3150 100644 --- a/cube/cube.cpp +++ b/cube/cube.cpp @@ -442,6 +442,7 @@ struct Demo { wl_seat *seat = nullptr; wl_pointer *pointer = nullptr; wl_keyboard *keyboard = nullptr; + int pending_width, pending_height; #endif #if defined(VK_USE_PLATFORM_DIRECTFB_EXT) IDirectFB *dfb = nullptr; @@ -2197,6 +2198,12 @@ void Demo::prepare() { void Demo::prepare_swapchain() { vk::SwapchainKHR oldSwapchain = swapchain; +#if defined(VK_USE_PLATFORM_WAYLAND_KHR) + if (wsi_platform == WsiPlatform::wayland && !xdg_surface_has_been_configured) { + return; + } +#endif + // Check the surface capabilities and formats auto surface_capabilities_return = gpu.getSurfaceCapabilitiesKHR(surface); VERIFY(surface_capabilities_return.result == vk::Result::eSuccess); @@ -3419,10 +3426,14 @@ void Demo::run<WsiPlatform::wayland>() { static void handle_surface_configure(void *data, xdg_surface *xdg_surface, uint32_t serial) { Demo &demo = *static_cast<Demo *>(data); xdg_surface_ack_configure(xdg_surface, serial); - if (demo.xdg_surface_has_been_configured) { - demo.resize(); - } demo.xdg_surface_has_been_configured = true; + if (demo.pending_width > 0) { + demo.width = demo.pending_width; + } + if (demo.pending_height > 0) { + demo.height = demo.pending_height; + } + demo.resize(); } static const xdg_surface_listener surface_listener = {handle_surface_configure}; @@ -3433,10 +3444,10 @@ static void handle_toplevel_configure(void *data, xdg_toplevel *xdg_toplevel, in /* zero values imply the program may choose its own size, so in that case * stay with the existing value (which on startup is the default) */ if (width > 0) { - demo.width = static_cast<uint32_t>(width); + demo.pending_width = static_cast<uint32_t>(width); } if (height > 0) { - demo.height = static_cast<uint32_t>(height); + demo.pending_height = static_cast<uint32_t>(height); } // This will be followed by a surface configure } |
