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
This commit is contained in:
parent
4326d3f029
commit
b063031313
5 changed files with 90 additions and 0 deletions
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
|
57
src/backends/drm/placeholderinputeventfilter.cpp
Normal file
57
src/backends/drm/placeholderinputeventfilter.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
27
src/backends/drm/placeholderinputeventfilter.h
Normal file
27
src/backends/drm/placeholderinputeventfilter.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue