diff --git a/src/backends/x11/windowed/x11_windowed_backend.cpp b/src/backends/x11/windowed/x11_windowed_backend.cpp index e83cbb19c1..18e5e1e7d9 100644 --- a/src/backends/x11/windowed/x11_windowed_backend.cpp +++ b/src/backends/x11/windowed/x11_windowed_backend.cpp @@ -43,6 +43,8 @@ #include #include #include +#include +#include namespace KWin { @@ -166,10 +168,6 @@ X11WindowedBackend::~X11WindowedBackend() m_touchDevice.reset(); m_eglDisplay.reset(); - if (m_gbmDevice) { - gbm_device_destroy(m_gbmDevice); - } - if (m_connection) { if (m_keySymbols) { xcb_key_symbols_free(m_keySymbols); @@ -309,9 +307,8 @@ void X11WindowedBackend::initDri3() UniqueCPtr reply(xcb_dri3_open_reply(m_connection, cookie, nullptr)); if (reply && reply->nfd == 1) { int fd = xcb_dri3_open_reply_fds(m_connection, reply.get())[0]; - fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); - m_drmFileDescriptor = FileDescriptor{fd}; - m_gbmDevice = gbm_create_device(m_drmFileDescriptor.get()); + m_drmDevice = DrmDevice::open(QByteArray(drmGetDeviceNameFromFd2(fd))); + ::close(fd); } } @@ -687,9 +684,9 @@ xcb_window_t X11WindowedBackend::rootWindow() const return m_screen->root; } -gbm_device *X11WindowedBackend::gbmDevice() const +DrmDevice *X11WindowedBackend::drmDevice() const { - return m_gbmDevice; + return m_drmDevice.get(); } X11WindowedInputDevice *X11WindowedBackend::pointerDevice() const @@ -777,7 +774,7 @@ int X11WindowedBackend::driMinorVersion() const QList X11WindowedBackend::supportedCompositors() const { QList ret; - if (m_gbmDevice) { + if (m_drmDevice) { ret.append(OpenGLCompositing); } if (m_hasShm) { diff --git a/src/backends/x11/windowed/x11_windowed_backend.h b/src/backends/x11/windowed/x11_windowed_backend.h index 09e1b30cb5..bc18fbfe63 100644 --- a/src/backends/x11/windowed/x11_windowed_backend.h +++ b/src/backends/x11/windowed/x11_windowed_backend.h @@ -8,6 +8,7 @@ */ #pragma once +#include "core/drmdevice.h" #include "core/inputbackend.h" #include "core/inputdevice.h" #include "core/outputbackend.h" @@ -103,7 +104,7 @@ public: xcb_screen_t *screen() const; int screenNumer() const; xcb_window_t rootWindow() const; - gbm_device *gbmDevice() const; + DrmDevice *drmDevice() const; bool hasXInput() const; @@ -174,8 +175,7 @@ private: int m_driMinorVersion = 0; QHash> m_driFormats; - FileDescriptor m_drmFileDescriptor; - gbm_device *m_gbmDevice = nullptr; + std::unique_ptr m_drmDevice; std::unique_ptr m_eglDisplay; QList m_outputs; diff --git a/src/backends/x11/windowed/x11_windowed_egl_backend.cpp b/src/backends/x11/windowed/x11_windowed_egl_backend.cpp index 37112d97cd..9f38861be7 100644 --- a/src/backends/x11/windowed/x11_windowed_egl_backend.cpp +++ b/src/backends/x11/windowed/x11_windowed_egl_backend.cpp @@ -179,8 +179,7 @@ std::chrono::nanoseconds X11WindowedEglCursorLayer::queryRenderTime() const } X11WindowedEglBackend::X11WindowedEglBackend(X11WindowedBackend *backend) - : m_allocator(std::make_unique(backend->gbmDevice())) - , m_backend(backend) + : m_backend(backend) { } @@ -196,7 +195,7 @@ X11WindowedBackend *X11WindowedEglBackend::backend() const GraphicsBufferAllocator *X11WindowedEglBackend::graphicsBufferAllocator() const { - return m_allocator.get(); + return m_backend->drmDevice()->allocator(); } bool X11WindowedEglBackend::initializeEgl() @@ -211,7 +210,7 @@ bool X11WindowedEglBackend::initializeEgl() } } - m_backend->setEglDisplay(EglDisplay::create(eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, m_backend->gbmDevice(), nullptr))); + m_backend->setEglDisplay(EglDisplay::create(eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, m_backend->drmDevice()->gbmDevice(), nullptr))); } auto display = m_backend->sceneEglDisplayObject(); diff --git a/src/backends/x11/windowed/x11_windowed_egl_backend.h b/src/backends/x11/windowed/x11_windowed_egl_backend.h index f9adf32272..304d24ec0d 100644 --- a/src/backends/x11/windowed/x11_windowed_egl_backend.h +++ b/src/backends/x11/windowed/x11_windowed_egl_backend.h @@ -17,7 +17,6 @@ namespace KWin class EglSwapchainSlot; class EglSwapchain; -class GraphicsBufferAllocator; class X11WindowedBackend; class X11WindowedOutput; class X11WindowedEglBackend; @@ -99,7 +98,6 @@ private: std::unique_ptr cursorLayer; }; - std::unique_ptr m_allocator; std::map m_outputs; X11WindowedBackend *m_backend; };