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) if(X11_FOUND)
add_definitions(-DHAVE_X11) add_definitions(-DHAVE_X11)
endif() endif()
find_package(Wayland)
if(WAYLAND_FOUND)
add_definitions(-DHAVE_WAYLAND)
endif()
endif() endif()
# Qt # Qt

View file

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

View file

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