Improved wayland support

This commit is contained in:
kd-11 2024-08-03 15:58:44 +03:00 committed by kd-11
parent 0be1c41e63
commit f6b5511546
3 changed files with 9 additions and 7 deletions

View File

@ -27,6 +27,10 @@ if(UNIX AND NOT APPLE)
if(X11_FOUND)
add_definitions(-DHAVE_X11)
endif()
find_package(Wayland)
if(WAYLAND_FOUND)
add_definitions(-DHAVE_WAYLAND)
endif()
endif()
# Qt

View File

@ -328,7 +328,7 @@ namespace vk
}
else
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
#ifdef HAVE_WAYLAND
if constexpr (std::is_same_v<T, std::pair<wl_display*, wl_surface*>>)
{
VkWaylandSurfaceCreateInfoKHR createInfo = {};

View File

@ -35,7 +35,7 @@
#elif defined(__APPLE__)
//nothing
#else
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
#ifdef HAVE_WAYLAND
#include <QGuiApplication>
#include <qpa/qplatformnativeinterface.h>
#endif
@ -712,7 +712,7 @@ display_handle_t gs_frame::handle() const
#elif defined(__APPLE__)
return reinterpret_cast<void*>(this->winId()); //NSView
#else
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
#ifdef HAVE_WAYLAND
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
struct wl_display *wl_dpy = static_cast<struct wl_display *>(
native->nativeResourceForWindow("display", NULL));
@ -723,16 +723,14 @@ display_handle_t gs_frame::handle() const
return std::make_pair(wl_dpy, wl_surf);
}
else
{
#endif
#ifdef HAVE_X11
{
return std::make_pair(XOpenDisplay(0), static_cast<ulong>(this->winId()));
}
#else
fmt::throw_exception("Vulkan X11 support disabled at compile-time.");
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
}
#endif
#endif
}