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.
This commit is contained in:
parent
d8cb48e6b7
commit
e179fb697d
2 changed files with 13 additions and 14 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue