aboutsummaryrefslogtreecommitdiff
path: root/cube/cube.cpp
diff options
context:
space:
mode:
authorXaver Hugl <xaver.hugl@gmail.com>2025-02-17 23:45:24 +0100
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2025-06-30 10:25:22 -0500
commitabc7451921d9a2daeb7d49a6ac17bebb43d94e8a (patch)
tree3343a625965dd9af3ceb018da6a40924d82b78d4 /cube/cube.cpp
parent55f6b39722978d0f46fd0b07d22fa4f3604378eb (diff)
downloadusermoji-abc7451921d9a2daeb7d49a6ac17bebb43d94e8a.tar.xz
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.
Diffstat (limited to 'cube/cube.cpp')
-rw-r--r--cube/cube.cpp36
1 files changed, 18 insertions, 18 deletions
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;
}
}