Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions cube/cube.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ struct demo {
struct wl_seat *seat;
struct wl_pointer *pointer;
struct wl_keyboard *keyboard;
int pending_width, pending_height;
#endif
#if defined(VK_USE_PLATFORM_DIRECTFB_EXT)
IDirectFB *dfb;
Expand Down Expand Up @@ -1372,6 +1373,12 @@ static void demo_prepare_swapchain(struct demo *demo) {
VkResult U_ASSERT_ONLY err;
VkSwapchainKHR oldSwapchain = demo->swapchain;

#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
if (demo->wsi_platform == WSI_PLATFORM_WAYLAND && !demo->xdg_surface_has_been_configured) {
return;
}
#endif

// Check the surface capabilities and formats
VkSurfaceCapabilitiesKHR surfCapabilities;
err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(demo->gpu, demo->surface, &surfCapabilities);
Expand Down Expand Up @@ -3054,10 +3061,14 @@ static void demo_run(struct demo *demo) {
static void handle_surface_configure(void *data, struct xdg_surface *xdg_surface, uint32_t serial) {
struct demo *demo = (struct demo *)data;
xdg_surface_ack_configure(xdg_surface, serial);
if (demo->xdg_surface_has_been_configured) {
demo_resize(demo);
}
demo->xdg_surface_has_been_configured = 1;
if (demo->pending_width > 0) {
demo->width = demo->pending_width;
}
if (demo->pending_height > 0) {
demo->height = demo->pending_height;
}
demo_resize(demo);
}

static const struct xdg_surface_listener xdg_surface_listener = {handle_surface_configure};
Expand All @@ -3068,10 +3079,10 @@ static void handle_toplevel_configure(void *data, struct xdg_toplevel *xdg_tople
/* 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 = width;
demo->pending_width = width;
}
if (height > 0) {
demo->height = height;
demo->pending_height = height;
}
/* This should be followed by a surface configure */
}
Expand Down
21 changes: 16 additions & 5 deletions cube/cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -3418,10 +3425,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};
Expand All @@ -3432,10 +3443,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
}
Expand Down
Loading