diff --git a/src/wayland/linuxdmabufv1clientbuffer.cpp b/src/wayland/linuxdmabufv1clientbuffer.cpp index 006f3c66ce..29cee42e81 100644 --- a/src/wayland/linuxdmabufv1clientbuffer.cpp +++ b/src/wayland/linuxdmabufv1clientbuffer.cpp @@ -15,7 +15,6 @@ #include "surface_interface_p.h" #include "utils/common.h" -#include #include #include #include @@ -440,7 +439,7 @@ LinuxDmaBufV1FeedbackPrivate::LinuxDmaBufV1FeedbackPrivate(LinuxDmaBufV1ClientBu void LinuxDmaBufV1FeedbackPrivate::send(Resource *resource) { - send_format_table(resource->handle, m_bufferintegration->table->fd.get(), m_bufferintegration->table->size); + send_format_table(resource->handle, m_bufferintegration->table->file.fd(), m_bufferintegration->table->file.size()); QByteArray bytes; bytes.append(reinterpret_cast(&m_bufferintegration->mainDevice), sizeof(dev_t)); send_main_device(resource->handle, bytes); @@ -500,28 +499,13 @@ LinuxDmaBufV1FormatTable::LinuxDmaBufV1FormatTable(const QHash tmp(new QTemporaryFile()); - if (!tmp->open()) { - qCWarning(KWIN_CORE) << "Failed to create keymap file:" << tmp->errorString(); + + const auto size = data.size() * sizeof(linux_dmabuf_feedback_v1_table_entry); + file = KWin::RamFile("kwin-dmabuf-feedback-table", data.constData(), size, KWin::RamFile::Flag::SealWrite); + if (!file.isValid()) { + qCCritical(KWIN_CORE) << "Failed to create RamFile for LinuxDmaBufV1FormatTable"; return; } - fd = KWin::FileDescriptor(open(tmp->fileName().toUtf8().constData(), O_RDONLY | O_CLOEXEC)); - if (!fd.isValid()) { - qCWarning(KWIN_CORE) << "Could not create readonly shm fd!" << strerror(errno); - return; - } - unlink(tmp->fileName().toUtf8().constData()); - if (!tmp->resize(size)) { - qCWarning(KWIN_CORE) << "Failed to resize keymap file:" << tmp->errorString(); - return; - } - uchar *address = tmp->map(0, size); - if (!address) { - qCWarning(KWIN_CORE) << "Failed to map keymap file:" << tmp->errorString(); - return; - } - memcpy(address, data.data(), size); } } // namespace KWaylandServer diff --git a/src/wayland/linuxdmabufv1clientbuffer_p.h b/src/wayland/linuxdmabufv1clientbuffer_p.h index 8511a7ca71..3dab47e86c 100644 --- a/src/wayland/linuxdmabufv1clientbuffer_p.h +++ b/src/wayland/linuxdmabufv1clientbuffer_p.h @@ -14,6 +14,7 @@ #include "display.h" #include "display_p.h" #include "linuxdmabufv1clientbuffer.h" +#include "utils/ramfile.h" #include "qwayland-server-linux-dmabuf-unstable-v1.h" #include "qwayland-server-wayland.h" @@ -91,8 +92,7 @@ class LinuxDmaBufV1FormatTable public: LinuxDmaBufV1FormatTable(const QHash> &supportedModifiers); - KWin::FileDescriptor fd; - int size; + KWin::RamFile file; QMap, uint16_t> indices; };