Commit b0630313 authored by Xaver Hugl's avatar Xaver Hugl
Browse files

backends/drm: block input with the placeholder output

This is to prevent the user from accidentally changing application state
while they don't have an output connected
parent 4326d3f0
Pipeline #140714 passed with stage
in 23 minutes and 2 seconds
......@@ -23,6 +23,7 @@ set(DRM_SOURCES
drm_buffer_gbm.cpp
gbm_surface.cpp
gbm_dmabuf.cpp
placeholderinputeventfilter.cpp
)
add_library(KWinWaylandDrmBackend MODULE ${DRM_SOURCES})
......
......@@ -504,6 +504,7 @@ void DrmBackend::enableOutput(DrmAbstractOutput *output, bool enable)
qCDebug(KWIN_DRM) << "removing placeholder output";
primaryGpu()->removeVirtualOutput(m_placeHolderOutput);
m_placeHolderOutput = nullptr;
m_placeholderFilter.reset();
}
} else {
if (m_enabledOutputs.count() == 1 && m_outputs.count() > 1) {
......@@ -523,6 +524,8 @@ void DrmBackend::enableOutput(DrmAbstractOutput *output, bool enable)
m_placeHolderOutput = primaryGpu()->createVirtualOutput({}, m_enabledOutputs.constFirst()->pixelSize(), 1, DrmGpu::Placeholder);
// placeholder doesn't actually need to render anything
m_placeHolderOutput->renderLoop()->inhibit();
m_placeholderFilter.reset(new PlaceholderInputEventFilter());
input()->prependInputEventFilter(m_placeholderFilter.data());
}
m_enabledOutputs.removeOne(output);
Q_EMIT output->gpu()->outputDisabled(output);
......
......@@ -11,6 +11,7 @@
#include "platform.h"
#include "dpmsinputeventfilter.h"
#include "placeholderinputeventfilter.h"
#include <QPointer>
#include <QSize>
......@@ -103,6 +104,7 @@ private:
const QStringList m_explicitGpus;
QVector<DrmGpu*> m_gpus;
QScopedPointer<DpmsInputEventFilter> m_dpmsFilter;
QScopedPointer<PlaceholderInputEventFilter> m_placeholderFilter;
};
......
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "placeholderinputeventfilter.h"
namespace KWin
{
bool PlaceholderInputEventFilter::pointerEvent(QMouseEvent *event, quint32 nativeButton)
{
Q_UNUSED(event)
Q_UNUSED(nativeButton)
return true;
}
bool PlaceholderInputEventFilter::wheelEvent(QWheelEvent *event)
{
Q_UNUSED(event)
return true;
}
bool PlaceholderInputEventFilter::keyEvent(QKeyEvent *event)
{
Q_UNUSED(event)
return true;
}
bool PlaceholderInputEventFilter::touchDown(qint32 id, const QPointF &pos, quint32 time)
{
Q_UNUSED(id)
Q_UNUSED(pos)
Q_UNUSED(time)
return true;
}
bool PlaceholderInputEventFilter::touchMotion(qint32 id, const QPointF &pos, quint32 time)
{
Q_UNUSED(id)
Q_UNUSED(pos)
Q_UNUSED(time)
return true;
}
bool PlaceholderInputEventFilter::touchUp(qint32 id, quint32 time)
{
Q_UNUSED(id)
Q_UNUSED(time)
return true;
}
}
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include "input.h"
namespace KWin
{
class PlaceholderInputEventFilter : public InputEventFilter
{
public:
bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override;
bool wheelEvent(QWheelEvent *event) override;
bool keyEvent(QKeyEvent *event) override;
bool touchDown(qint32 id, const QPointF &pos, quint32 time) override;
bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override;
bool touchUp(qint32 id, quint32 time) override;
};
}
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