From 01f7ef35e7e37cdcf7d8de44666111353e67b9a0 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 12 Apr 2021 19:53:08 +0200 Subject: [PATCH] drm: Make sure we read all pending udev events --- src/plugins/platforms/drm/drm_backend.cpp | 32 +++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/plugins/platforms/drm/drm_backend.cpp b/src/plugins/platforms/drm/drm_backend.cpp index beacb098a7..5622cbdf53 100644 --- a/src/plugins/platforms/drm/drm_backend.cpp +++ b/src/plugins/platforms/drm/drm_backend.cpp @@ -249,24 +249,22 @@ bool DrmBackend::initialize() QSocketNotifier *notifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); connect(notifier, &QSocketNotifier::activated, this, [this] { - auto device = m_udevMonitor->getDevice(); - if (!device) { - return; - } - bool drm = false; - for (auto gpu : m_gpus) { - if (gpu->drmId() == device->sysNum()) { - drm = true; - break; + while (auto device = m_udevMonitor->getDevice()) { + bool drm = false; + for (auto gpu : m_gpus) { + if (gpu->drmId() == device->sysNum()) { + drm = true; + break; + } + } + if (!drm) { + return; + } + if (device->hasProperty("HOTPLUG", "1")) { + qCDebug(KWIN_DRM) << "Received hot plug event for monitored drm device"; + updateOutputs(); + updateCursor(); } - } - if (!drm) { - return; - } - if (device->hasProperty("HOTPLUG", "1")) { - qCDebug(KWIN_DRM) << "Received hot plug event for monitored drm device"; - updateOutputs(); - updateCursor(); } } );