Commit e179fb69 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

platforms/drm: Refactor event dispatching code

There are a couple of reasons not to use the lambda:

* It is unnecessary. The DrmGpu has the DRM file descriptor
* If a crash occurs somewhere in the lambda, the backtrace will be hard
  to read
* Instead of processing events in the destructor of the DrmBackend
  class, we should keep dispatching events without involving
  QCoreApplication::processEvents() until all page flips are completed.
parent d8cb48e6
......@@ -30,8 +30,6 @@
#include <xf86drmMode.h>
#include <libdrm/drm_mode.h>
#define KWIN_DRM_EVENT_CONTEXT_VERSION 2
namespace KWin
{
......@@ -65,18 +63,7 @@ DrmGpu::DrmGpu(DrmBackend *backend, QByteArray devNode, int fd, int drmId) : m_b
m_deleteBufferAfterPageFlip = !m_useEglStreams;
m_socketNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
connect(m_socketNotifier, &QSocketNotifier::activated, this,
[fd] {
if (!LogindIntegration::self()->isActiveSession()) {
return;
}
drmEventContext e;
memset(&e, 0, sizeof e);
e.version = KWIN_DRM_EVENT_CONTEXT_VERSION;
e.page_flip_handler = DrmBackend::pageFlipHandler;
drmHandleEvent(fd, &e);
}
);
connect(m_socketNotifier, &QSocketNotifier::activated, this, &DrmGpu::dispatchEvents);
}
DrmGpu::~DrmGpu()
......@@ -327,4 +314,15 @@ DrmPlane *DrmGpu::getCompatiblePlane(DrmPlane::TypeIndex typeIndex, DrmCrtc *crt
return nullptr;
}
void DrmGpu::dispatchEvents()
{
if (!LogindIntegration::self()->isActiveSession()) {
return;
}
drmEventContext context = {};
context.version = 2;
context.page_flip_handler = DrmBackend::pageFlipHandler;
drmHandleEvent(m_fd, &context);
}
}
......@@ -117,6 +117,7 @@ protected:
bool updateOutputs();
private:
void dispatchEvents();
DrmPlane *getCompatiblePlane(DrmPlane::TypeIndex typeIndex, DrmCrtc *crtc);
DrmOutput *findOutput(quint32 connector);
......
Supports Markdown
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