Commit daf693d3 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez

Restore building the wayland_backend without gbm

Disables the compilation on the few places that use it to allow creating
dmabufs easily.

Patch inspired by David Faure.
parent 237d52be
......@@ -3,11 +3,13 @@ set(WAYLAND_BACKEND_SOURCES
scene_qpainter_wayland_backend.cpp
wayland_backend.cpp
wayland_output.cpp
../drm/gbm_dmabuf.cpp
)
if (HAVE_WAYLAND_EGL)
set(WAYLAND_BACKEND_SOURCES egl_wayland_backend.cpp ${WAYLAND_BACKEND_SOURCES})
if (HAVE_GBM)
list(APPEND WAYLAND_BACKEND_SOURCES ../drm/gbm_dmabuf.cpp)
endif()
endif()
include_directories(${CMAKE_SOURCE_DIR}/platformsupport/scenes/opengl)
......@@ -16,7 +18,10 @@ set_target_properties(KWinWaylandWaylandBackend PROPERTIES LIBRARY_OUTPUT_DIRECT
target_link_libraries(KWinWaylandWaylandBackend kwin KF5::WaylandClient SceneQPainterBackend)
if (HAVE_WAYLAND_EGL)
target_link_libraries(KWinWaylandWaylandBackend SceneOpenGLBackend Wayland::Egl gbm::gbm)
target_link_libraries(KWinWaylandWaylandBackend SceneOpenGLBackend Wayland::Egl)
if (HAVE_GBM)
target_link_libraries(KWinWaylandWaylandBackend gbm::gbm)
endif()
endif()
install(
......
......@@ -9,8 +9,14 @@
*/
#include "wayland_backend.h"
#include <config-kwin.h>
#if HAVE_WAYLAND_EGL
#include "egl_wayland_backend.h"
#if HAVE_GBM
#include "../drm/gbm_dmabuf.h"
#include <gbm.h>
#endif
#endif
#include "logging.h"
#include "scene_qpainter_wayland_backend.h"
......@@ -24,9 +30,6 @@
#include "pointer_input.h"
#include "screens.h"
#include "wayland_server.h"
#include "../drm/gbm_dmabuf.h"
#include <config-kwin.h>
#include <KWayland/Client/buffer.h>
#include <KWayland/Client/compositor.h>
......@@ -54,7 +57,6 @@
#include <linux/input.h>
#include <unistd.h>
#include <gbm.h>
#include <fcntl.h>
namespace KWin
......@@ -447,6 +449,7 @@ WaylandBackend::WaylandBackend(QObject *parent)
connect(this, &WaylandBackend::connectionFailed, this, &WaylandBackend::initFailed);
#if HAVE_GBM && HAVE_WAYLAND_EGL
char const *drm_render_node = "/dev/dri/renderD128";
m_drmFileDescriptor = open(drm_render_node, O_RDWR);
if (m_drmFileDescriptor < 0) {
......@@ -455,6 +458,7 @@ WaylandBackend::WaylandBackend(QObject *parent)
return;
}
m_gbmDevice = gbm_create_device(m_drmFileDescriptor);
#endif
}
WaylandBackend::~WaylandBackend()
......@@ -479,9 +483,10 @@ WaylandBackend::~WaylandBackend()
m_connectionThread->quit();
m_connectionThread->wait();
m_connectionThreadObject->deleteLater();
#if HAVE_GBM && HAVE_WAYLAND_EGL
gbm_device_destroy(m_gbmDevice);
close(m_drmFileDescriptor);
#endif
qCDebug(KWIN_WAYLAND_BACKEND) << "Destroyed Wayland display";
}
......@@ -835,7 +840,11 @@ Outputs WaylandBackend::enabledOutputs() const
DmaBufTexture *WaylandBackend::createDmaBufTexture(const QSize& size)
{
#if HAVE_GBM && HAVE_WAYLAND_EGL
return GbmDmaBuf::createBuffer(size, m_gbmDevice);
#else
return nullptr;
#endif
}
}
......
......@@ -239,8 +239,10 @@ private:
WaylandCursor *m_waylandCursor = nullptr;
bool m_pointerLockRequested = false;
#if HAVE_GBM && HAVE_WAYLAND_EGL
int m_drmFileDescriptor = 0;
gbm_device *m_gbmDevice;
#endif
};
inline
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment