From abc7451921d9a2daeb7d49a6ac17bebb43d94e8a Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Mon, 17 Feb 2025 23:45:24 +0100 Subject: cube: prefer Wayland over X11 when available In Wayland sessions, X11 is still available through a compatibility layer, but should effectively never be used over a native Wayland connection if the application is capable of that. --- cube/cube.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'cube/cube.cpp') diff --git a/cube/cube.cpp b/cube/cube.cpp index e1d67e85..1522ba0c 100644 --- a/cube/cube.cpp +++ b/cube/cube.cpp @@ -1325,58 +1325,58 @@ const char *Demo::init_wayland_connection() { #endif void Demo::check_and_set_wsi_platform() { -#if defined(VK_USE_PLATFORM_XCB_KHR) - if (wsi_platform == WsiPlatform::xcb || wsi_platform == WsiPlatform::auto_) { +#if defined(VK_USE_PLATFORM_WAYLAND_KHR) + if (wsi_platform == WsiPlatform::wayland || wsi_platform == WsiPlatform::auto_) { auto found = std::find_if(enabled_instance_extensions.begin(), enabled_instance_extensions.end(), - [](const char *str) { return 0 == strcmp(str, VK_KHR_XCB_SURFACE_EXTENSION_NAME); }); + [](const char *str) { return 0 == strcmp(str, VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); }); if (found != enabled_instance_extensions.end()) { - const char *error_msg = init_xcb_connection(); + const char *error_msg = init_wayland_connection(); if (error_msg != NULL) { - if (wsi_platform == WsiPlatform::xcb) { + if (wsi_platform == WsiPlatform::wayland) { fprintf(stderr, "%s\nExiting ...\n", error_msg); fflush(stdout); exit(1); } } else { - wsi_platform = WsiPlatform::xcb; + wsi_platform = WsiPlatform::wayland; return; } } } #endif -#if defined(VK_USE_PLATFORM_XLIB_KHR) - if (wsi_platform == WsiPlatform::xlib || wsi_platform == WsiPlatform::auto_) { +#if defined(VK_USE_PLATFORM_XCB_KHR) + if (wsi_platform == WsiPlatform::xcb || wsi_platform == WsiPlatform::auto_) { auto found = std::find_if(enabled_instance_extensions.begin(), enabled_instance_extensions.end(), - [](const char *str) { return 0 == strcmp(str, VK_KHR_XLIB_SURFACE_EXTENSION_NAME); }); + [](const char *str) { return 0 == strcmp(str, VK_KHR_XCB_SURFACE_EXTENSION_NAME); }); if (found != enabled_instance_extensions.end()) { - const char *error_msg = init_xlib_connection(); + const char *error_msg = init_xcb_connection(); if (error_msg != NULL) { - if (wsi_platform == WsiPlatform::xlib) { + if (wsi_platform == WsiPlatform::xcb) { fprintf(stderr, "%s\nExiting ...\n", error_msg); fflush(stdout); exit(1); } } else { - wsi_platform = WsiPlatform::xlib; + wsi_platform = WsiPlatform::xcb; return; } } } #endif -#if defined(VK_USE_PLATFORM_WAYLAND_KHR) - if (wsi_platform == WsiPlatform::wayland || wsi_platform == WsiPlatform::auto_) { +#if defined(VK_USE_PLATFORM_XLIB_KHR) + if (wsi_platform == WsiPlatform::xlib || wsi_platform == WsiPlatform::auto_) { auto found = std::find_if(enabled_instance_extensions.begin(), enabled_instance_extensions.end(), - [](const char *str) { return 0 == strcmp(str, VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); }); + [](const char *str) { return 0 == strcmp(str, VK_KHR_XLIB_SURFACE_EXTENSION_NAME); }); if (found != enabled_instance_extensions.end()) { - const char *error_msg = init_wayland_connection(); + const char *error_msg = init_xlib_connection(); if (error_msg != NULL) { - if (wsi_platform == WsiPlatform::wayland) { + if (wsi_platform == WsiPlatform::xlib) { fprintf(stderr, "%s\nExiting ...\n", error_msg); fflush(stdout); exit(1); } } else { - wsi_platform = WsiPlatform::wayland; + wsi_platform = WsiPlatform::xlib; return; } } -- cgit v1.2.3