@@ -413,7 +413,7 @@ bool Anvil::RenderingSurface::init()
413413 VkXcbSurfaceCreateInfoKHR surface_create_info;
414414
415415 surface_create_info.flags = 0 ;
416- surface_create_info.window = window_ptr-> get_handle () ;
416+ surface_create_info.window = generic_ptr-> get_generic_handle (). xcbWindow ;
417417 surface_create_info.connection = static_cast <xcb_connection_t *>(window_ptr->get_connection ());
418418 surface_create_info.pNext = nullptr ;
419419 surface_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
@@ -422,13 +422,15 @@ bool Anvil::RenderingSurface::init()
422422 &m_surface);
423423 }
424424 else if (type == Anvil::WindowGeneric::Type::Wayland) {
425+ auto vkInstance = instance_ptr->get_instance_vk ();
426+ auto &entrypoints = instance_ptr->get_extension_khr_wayland_surface_entrypoints ();
425427 VkWaylandSurfaceCreateInfoKHR surface_create_info;
426428 surface_create_info.flags = 0 ;
427429 surface_create_info.display = reinterpret_cast <wl_display *>(window_ptr->get_connection ());
428- surface_create_info.surface = reinterpret_cast <wl_surface *>(window_ptr-> get_handle () );
430+ surface_create_info.surface = reinterpret_cast <wl_surface *>(generic_ptr-> get_generic_handle (). waylandWindow );
429431 surface_create_info.pNext = nullptr ;
430432 surface_create_info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
431- result = instance_ptr-> get_extension_khr_wayland_surface_entrypoints () .vkCreateWaylandSurfaceKHR (instance_ptr-> get_instance_vk () , &surface_create_info, nullptr , /* pAllocator */
433+ result = entrypoints .vkCreateWaylandSurfaceKHR (vkInstance , &surface_create_info, nullptr , /* pAllocator */
432434 &m_surface);
433435 }
434436 else
@@ -736,6 +738,28 @@ void Anvil::RenderingSurface::update_surface_extents() const
736738 {
737739 m_height = surface_caps.current_extent .height ;
738740 m_width = surface_caps.current_extent .width ;
741+
742+ if (m_width == m_height && m_width == std::numeric_limits<uint32_t >::max ())
743+ {
744+ // The surface is not limited to a specific size, so we'll just use the window framebuffer size
745+ auto *generic_ptr = dynamic_cast <const Anvil::WindowGeneric *>(window_ptr);
746+ if (generic_ptr != nullptr )
747+ {
748+ m_height = generic_ptr->get_framebuffer_height ();
749+ m_width = generic_ptr->get_framebuffer_width ();
750+
751+ // Clamp to max extents
752+ if (m_height > surface_caps.max_image_extent .height )
753+ m_height = surface_caps.max_image_extent .height ;
754+ if (m_width > surface_caps.max_image_extent .width )
755+ m_width = surface_caps.max_image_extent .width ;
756+ }
757+ else
758+ {
759+ m_height = surface_caps.min_image_extent .height ;
760+ m_width = surface_caps.min_image_extent .width ;
761+ }
762+ }
739763 }
740764 else
741765 {
0 commit comments