Commit 0d918505 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii Committed by Aleix Pol Gonzalez
Browse files

platforms/drm: Ignore udev events while session is inactive

While the session is inactive, the drm master permissions are revoked.
Therefore, we cannot perform things such as modesetting, etc. It also
makes no sense to create or destroy DrmOutput objects.

CCBUG: 435941
parent f7526f50
......@@ -158,8 +158,6 @@ void DrmBackend::reactivate()
// only relevant in atomic mode
o->m_modesetRequested = true;
o->m_crtc->blank(o);
o->showCursor();
o->moveCursor();
}
}
......@@ -169,6 +167,11 @@ void DrmBackend::reactivate()
if (Compositor *compositor = Compositor::self()) {
compositor->addRepaintFull();
}
// While the session had been inactive, an output could have been added or
// removed, we need to re-scan outputs.
updateOutputs();
updateCursor();
}
void DrmBackend::deactivate()
......@@ -247,27 +250,7 @@ bool DrmBackend::initialize()
const int fd = m_udevMonitor->fd();
if (fd != -1) {
QSocketNotifier *notifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
connect(notifier, &QSocketNotifier::activated, this,
[this] {
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();
}
}
}
);
connect(notifier, &QSocketNotifier::activated, this, &DrmBackend::handleUdevEvent);
m_udevMonitor->enable();
}
}
......@@ -275,12 +258,33 @@ bool DrmBackend::initialize()
return true;
}
void DrmBackend::addOutput(DrmOutput *o)
void DrmBackend::handleUdevEvent()
{
if (!m_active) {
o->renderLoop()->inhibit();
while (auto device = m_udevMonitor->getDevice()) {
if (!session()->isActive()) {
continue;
}
bool drm = false;
for (auto gpu : m_gpus) {
if (gpu->drmId() == device->sysNum()) {
drm = true;
break;
}
}
if (!drm) {
continue;
}
if (device->hasProperty("HOTPLUG", "1")) {
qCDebug(KWIN_DRM) << "Received hot plug event for monitored drm device";
updateOutputs();
updateCursor();
}
}
}
void DrmBackend::addOutput(DrmOutput *o)
{
m_outputs.append(o);
m_enabledOutputs.append(o);
emit o->gpu()->outputEnabled(o);
......
......@@ -103,6 +103,7 @@ private:
QString generateOutputConfigurationUuid() const;
DrmOutput *findOutput(quint32 connector);
void updateOutputsEnabled();
void handleUdevEvent();
QScopedPointer<Udev> m_udev;
QScopedPointer<UdevMonitor> m_udevMonitor;
Session *m_session = nullptr;
......
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