backends: move dpms input filter handling to Workspace
This commit is contained in:
parent
66cef35c64
commit
99244efa3b
12 changed files with 49 additions and 88 deletions
|
@ -71,7 +71,6 @@ DrmBackend::DrmBackend(Session *session, QObject *parent)
|
||||||
, m_udevMonitor(m_udev->monitor())
|
, m_udevMonitor(m_udev->monitor())
|
||||||
, m_session(session)
|
, m_session(session)
|
||||||
, m_explicitGpus(splitPathList(qEnvironmentVariable("KWIN_DRM_DEVICES"), ':'))
|
, m_explicitGpus(splitPathList(qEnvironmentVariable("KWIN_DRM_DEVICES"), ':'))
|
||||||
, m_dpmsFilter()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,42 +86,6 @@ Outputs DrmBackend::outputs() const
|
||||||
return m_outputs;
|
return m_outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmBackend::createDpmsFilter()
|
|
||||||
{
|
|
||||||
if (m_dpmsFilter) {
|
|
||||||
// already another output is off
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_dpmsFilter = std::make_unique<DpmsInputEventFilter>();
|
|
||||||
input()->prependInputEventFilter(m_dpmsFilter.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrmBackend::turnOutputsOn()
|
|
||||||
{
|
|
||||||
m_dpmsFilter.reset();
|
|
||||||
for (Output *output : std::as_const(m_outputs)) {
|
|
||||||
if (output->isEnabled()) {
|
|
||||||
output->setDpmsMode(Output::DpmsMode::On);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrmBackend::checkOutputsAreOn()
|
|
||||||
{
|
|
||||||
if (!m_dpmsFilter) {
|
|
||||||
// already disabled, all outputs are on
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (Output *output : std::as_const(m_outputs)) {
|
|
||||||
if (output->isEnabled() && output->dpmsMode() != Output::DpmsMode::On) {
|
|
||||||
// dpms still disabled, need to keep the filter
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// all outputs are on, disable the filter
|
|
||||||
m_dpmsFilter.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DrmBackend::initialize()
|
bool DrmBackend::initialize()
|
||||||
{
|
{
|
||||||
connect(m_session, &Session::devicePaused, this, [this](dev_t deviceId) {
|
connect(m_session, &Session::devicePaused, this, [this](dev_t deviceId) {
|
||||||
|
@ -135,7 +98,6 @@ bool DrmBackend::initialize()
|
||||||
gpu->setActive(true);
|
gpu->setActive(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(m_session, &Session::awoke, this, &DrmBackend::turnOutputsOn);
|
|
||||||
|
|
||||||
if (!m_explicitGpus.isEmpty()) {
|
if (!m_explicitGpus.isEmpty()) {
|
||||||
for (const QString &fileName : m_explicitGpus) {
|
for (const QString &fileName : m_explicitGpus) {
|
||||||
|
|
|
@ -9,17 +9,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "core/outputbackend.h"
|
#include "core/outputbackend.h"
|
||||||
|
|
||||||
#include "dpmsinputeventfilter.h"
|
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QSocketNotifier>
|
#include <QSocketNotifier>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
// system
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
@ -43,8 +39,6 @@ public:
|
||||||
explicit DrmBackend(Session *session, QObject *parent = nullptr);
|
explicit DrmBackend(Session *session, QObject *parent = nullptr);
|
||||||
~DrmBackend() override;
|
~DrmBackend() override;
|
||||||
|
|
||||||
Session *session() const;
|
|
||||||
|
|
||||||
std::unique_ptr<InputBackend> createInputBackend() override;
|
std::unique_ptr<InputBackend> createInputBackend() override;
|
||||||
std::unique_ptr<QPainterBackend> createQPainterBackend() override;
|
std::unique_ptr<QPainterBackend> createQPainterBackend() override;
|
||||||
std::unique_ptr<OpenGLBackend> createOpenGLBackend() override;
|
std::unique_ptr<OpenGLBackend> createOpenGLBackend() override;
|
||||||
|
@ -53,9 +47,7 @@ public:
|
||||||
bool initialize() override;
|
bool initialize() override;
|
||||||
|
|
||||||
Outputs outputs() const override;
|
Outputs outputs() const override;
|
||||||
|
Session *session() const override;
|
||||||
void createDpmsFilter();
|
|
||||||
void checkOutputsAreOn();
|
|
||||||
|
|
||||||
QVector<CompositingType> supportedCompositors() const override;
|
QVector<CompositingType> supportedCompositors() const override;
|
||||||
|
|
||||||
|
@ -76,7 +68,6 @@ public:
|
||||||
const std::vector<std::unique_ptr<DrmGpu>> &gpus() const;
|
const std::vector<std::unique_ptr<DrmGpu>> &gpus() const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void turnOutputsOn();
|
|
||||||
void sceneInitialized() override;
|
void sceneInitialized() override;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
@ -102,7 +93,6 @@ private:
|
||||||
|
|
||||||
const QStringList m_explicitGpus;
|
const QStringList m_explicitGpus;
|
||||||
std::vector<std::unique_ptr<DrmGpu>> m_gpus;
|
std::vector<std::unique_ptr<DrmGpu>> m_gpus;
|
||||||
std::unique_ptr<DpmsInputEventFilter> m_dpmsFilter;
|
|
||||||
DrmRenderBackend *m_renderBackend = nullptr;
|
DrmRenderBackend *m_renderBackend = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -156,11 +156,7 @@ void DrmOutput::setDpmsMode(DpmsMode mode)
|
||||||
Q_EMIT aboutToTurnOff(std::chrono::milliseconds(m_turnOffTimer.interval()));
|
Q_EMIT aboutToTurnOff(std::chrono::milliseconds(m_turnOffTimer.interval()));
|
||||||
m_turnOffTimer.start();
|
m_turnOffTimer.start();
|
||||||
}
|
}
|
||||||
if (isEnabled()) {
|
|
||||||
m_gpu->platform()->createDpmsFilter();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
m_gpu->platform()->checkOutputsAreOn();
|
|
||||||
if (m_turnOffTimer.isActive() || (mode != dpmsMode() && setDrmDpmsMode(mode))) {
|
if (m_turnOffTimer.isActive() || (mode != dpmsMode() && setDrmDpmsMode(mode))) {
|
||||||
Q_EMIT wakeUp();
|
Q_EMIT wakeUp();
|
||||||
}
|
}
|
||||||
|
@ -187,20 +183,15 @@ bool DrmOutput::setDrmDpmsMode(DpmsMode mode)
|
||||||
m_pipeline->applyPendingChanges();
|
m_pipeline->applyPendingChanges();
|
||||||
updateDpmsMode(mode);
|
updateDpmsMode(mode);
|
||||||
if (active) {
|
if (active) {
|
||||||
m_gpu->platform()->checkOutputsAreOn();
|
|
||||||
m_renderLoop->uninhibit();
|
m_renderLoop->uninhibit();
|
||||||
m_renderLoop->scheduleRepaint();
|
m_renderLoop->scheduleRepaint();
|
||||||
} else {
|
} else {
|
||||||
m_renderLoop->inhibit();
|
m_renderLoop->inhibit();
|
||||||
m_gpu->platform()->createDpmsFilter();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
qCWarning(KWIN_DRM) << "Setting dpms mode failed!";
|
qCWarning(KWIN_DRM) << "Setting dpms mode failed!";
|
||||||
m_pipeline->revertPendingChanges();
|
m_pipeline->revertPendingChanges();
|
||||||
if (isEnabled() && isActive && !active) {
|
|
||||||
m_gpu->platform()->checkOutputsAreOn();
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,10 +350,6 @@ void DrmOutput::applyQueuedChanges(const std::shared_ptr<OutputChangeSet> &props
|
||||||
m_renderLoop->scheduleRepaint();
|
m_renderLoop->scheduleRepaint();
|
||||||
|
|
||||||
Q_EMIT changed();
|
Q_EMIT changed();
|
||||||
|
|
||||||
if (isEnabled() && dpmsMode() == DpmsMode::On) {
|
|
||||||
m_gpu->platform()->turnOutputsOn();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmOutput::revertQueuedChanges()
|
void DrmOutput::revertQueuedChanges()
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
#include "wayland_backend.h"
|
#include "wayland_backend.h"
|
||||||
#include "dpmsinputeventfilter.h"
|
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "wayland_display.h"
|
#include "wayland_display.h"
|
||||||
#include "wayland_egl_backend.h"
|
#include "wayland_egl_backend.h"
|
||||||
|
@ -578,21 +577,6 @@ Outputs WaylandBackend::outputs() const
|
||||||
return m_outputs;
|
return m_outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaylandBackend::createDpmsFilter()
|
|
||||||
{
|
|
||||||
if (m_dpmsFilter) {
|
|
||||||
// already another output is off
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_dpmsFilter = std::make_unique<DpmsInputEventFilter>();
|
|
||||||
input()->prependInputEventFilter(m_dpmsFilter.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaylandBackend::clearDpmsFilter()
|
|
||||||
{
|
|
||||||
m_dpmsFilter.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
Output *WaylandBackend::createVirtualOutput(const QString &name, const QSize &size, double scale)
|
Output *WaylandBackend::createVirtualOutput(const QString &name, const QSize &size, double scale)
|
||||||
{
|
{
|
||||||
return createOutput(name, size * scale, scale);
|
return createOutput(name, size * scale, scale);
|
||||||
|
|
|
@ -44,7 +44,6 @@ class Touch;
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
class DpmsInputEventFilter;
|
|
||||||
class GraphicsBuffer;
|
class GraphicsBuffer;
|
||||||
|
|
||||||
namespace Wayland
|
namespace Wayland
|
||||||
|
@ -236,8 +235,6 @@ public:
|
||||||
{
|
{
|
||||||
return m_outputs;
|
return m_outputs;
|
||||||
}
|
}
|
||||||
void createDpmsFilter();
|
|
||||||
void clearDpmsFilter();
|
|
||||||
|
|
||||||
Output *createVirtualOutput(const QString &name, const QSize &size, double scale) override;
|
Output *createVirtualOutput(const QString &name, const QSize &size, double scale) override;
|
||||||
void removeVirtualOutput(Output *output) override;
|
void removeVirtualOutput(Output *output) override;
|
||||||
|
@ -269,7 +266,6 @@ private:
|
||||||
std::unique_ptr<WaylandSeat> m_seat;
|
std::unique_ptr<WaylandSeat> m_seat;
|
||||||
WaylandEglBackend *m_eglBackend = nullptr;
|
WaylandEglBackend *m_eglBackend = nullptr;
|
||||||
QVector<WaylandOutput *> m_outputs;
|
QVector<WaylandOutput *> m_outputs;
|
||||||
std::unique_ptr<DpmsInputEventFilter> m_dpmsFilter;
|
|
||||||
bool m_pointerLockRequested = false;
|
bool m_pointerLockRequested = false;
|
||||||
FileDescriptor m_drmFileDescriptor;
|
FileDescriptor m_drmFileDescriptor;
|
||||||
gbm_device *m_gbmDevice = nullptr;
|
gbm_device *m_gbmDevice = nullptr;
|
||||||
|
|
|
@ -211,11 +211,8 @@ void WaylandOutput::setDpmsMode(DpmsMode mode)
|
||||||
Q_EMIT aboutToTurnOff(std::chrono::milliseconds(m_turnOffTimer.interval()));
|
Q_EMIT aboutToTurnOff(std::chrono::milliseconds(m_turnOffTimer.interval()));
|
||||||
m_turnOffTimer.start();
|
m_turnOffTimer.start();
|
||||||
}
|
}
|
||||||
m_backend->createDpmsFilter();
|
|
||||||
} else {
|
} else {
|
||||||
m_turnOffTimer.stop();
|
m_turnOffTimer.stop();
|
||||||
m_backend->clearDpmsFilter();
|
|
||||||
|
|
||||||
if (mode != dpmsMode()) {
|
if (mode != dpmsMode()) {
|
||||||
updateDpmsMode(mode);
|
updateDpmsMode(mode);
|
||||||
Q_EMIT wakeUp();
|
Q_EMIT wakeUp();
|
||||||
|
|
|
@ -102,6 +102,11 @@ void OutputBackend::setSceneEglGlobalShareContext(::EGLContext context)
|
||||||
m_globalShareContext = context;
|
m_globalShareContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Session *OutputBackend::session() const
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace KWin
|
} // namespace KWin
|
||||||
|
|
||||||
#include "moc_outputbackend.cpp"
|
#include "moc_outputbackend.cpp"
|
||||||
|
|
|
@ -27,6 +27,7 @@ class OpenGLBackend;
|
||||||
class QPainterBackend;
|
class QPainterBackend;
|
||||||
class OutputConfiguration;
|
class OutputConfiguration;
|
||||||
class EglDisplay;
|
class EglDisplay;
|
||||||
|
class Session;
|
||||||
|
|
||||||
class KWIN_EXPORT Outputs : public QVector<Output *>
|
class KWIN_EXPORT Outputs : public QVector<Output *>
|
||||||
{
|
{
|
||||||
|
@ -93,6 +94,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool applyOutputChanges(const OutputConfiguration &config);
|
virtual bool applyOutputChanges(const OutputConfiguration &config);
|
||||||
|
|
||||||
|
virtual Session *session() const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
virtual void sceneInitialized(){};
|
virtual void sceneInitialized(){};
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
*/
|
*/
|
||||||
#include "dpmsinputeventfilter.h"
|
#include "dpmsinputeventfilter.h"
|
||||||
#include "core/output.h"
|
#include "core/output.h"
|
||||||
|
#include "core/outputbackend.h"
|
||||||
|
#include "core/session.h"
|
||||||
#include "input_event.h"
|
#include "input_event.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "wayland/seat.h"
|
#include "wayland/seat.h"
|
||||||
|
@ -25,9 +27,15 @@ DpmsInputEventFilter::DpmsInputEventFilter()
|
||||||
{
|
{
|
||||||
KSharedConfig::Ptr kwinSettings = kwinApp()->config();
|
KSharedConfig::Ptr kwinSettings = kwinApp()->config();
|
||||||
m_enableDoubleTap = kwinSettings->group("Wayland").readEntry<bool>("DoubleTapWakeup", true);
|
m_enableDoubleTap = kwinSettings->group("Wayland").readEntry<bool>("DoubleTapWakeup", true);
|
||||||
|
if (Session *session = kwinApp()->outputBackend()->session()) {
|
||||||
|
connect(session, &Session::awoke, this, &DpmsInputEventFilter::notify);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DpmsInputEventFilter::~DpmsInputEventFilter() = default;
|
DpmsInputEventFilter::~DpmsInputEventFilter()
|
||||||
|
{
|
||||||
|
notify();
|
||||||
|
}
|
||||||
|
|
||||||
bool DpmsInputEventFilter::pointerEvent(MouseEvent *event, quint32 nativeButton)
|
bool DpmsInputEventFilter::pointerEvent(MouseEvent *event, quint32 nativeButton)
|
||||||
{
|
{
|
||||||
|
@ -105,3 +113,4 @@ void DpmsInputEventFilter::notify()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#include "moc_dpmsinputeventfilter.cpp"
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
#include <kwin_export.h>
|
#include <kwin_export.h>
|
||||||
|
|
||||||
|
@ -18,8 +19,9 @@ namespace KWin
|
||||||
|
|
||||||
class DrmBackend;
|
class DrmBackend;
|
||||||
|
|
||||||
class KWIN_EXPORT DpmsInputEventFilter : public InputEventFilter
|
class KWIN_EXPORT DpmsInputEventFilter : public QObject, public InputEventFilter
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DpmsInputEventFilter();
|
DpmsInputEventFilter();
|
||||||
~DpmsInputEventFilter() override;
|
~DpmsInputEventFilter() override;
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "tabbox/tabbox.h"
|
#include "tabbox/tabbox.h"
|
||||||
#endif
|
#endif
|
||||||
#include "decorations/decorationbridge.h"
|
#include "decorations/decorationbridge.h"
|
||||||
|
#include "dpmsinputeventfilter.h"
|
||||||
#include "lidswitchtracker.h"
|
#include "lidswitchtracker.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "outputconfigurationstore.h"
|
#include "outputconfigurationstore.h"
|
||||||
|
@ -1289,8 +1290,11 @@ void Workspace::updateOutputs(const QVector<Output *> &outputOrder)
|
||||||
for (Output *output : added) {
|
for (Output *output : added) {
|
||||||
output->ref();
|
output->ref();
|
||||||
m_tileManagers[output] = std::make_unique<TileManager>(output);
|
m_tileManagers[output] = std::make_unique<TileManager>(output);
|
||||||
|
connect(output, &Output::aboutToTurnOff, this, &Workspace::createDpmsFilter);
|
||||||
|
connect(output, &Output::dpmsModeChanged, this, &Workspace::maybeDestroyDpmsFilter);
|
||||||
Q_EMIT outputAdded(output);
|
Q_EMIT outputAdded(output);
|
||||||
}
|
}
|
||||||
|
maybeDestroyDpmsFilter();
|
||||||
|
|
||||||
const auto removed = oldOutputsSet - outputsSet;
|
const auto removed = oldOutputsSet - outputsSet;
|
||||||
for (Output *output : removed) {
|
for (Output *output : removed) {
|
||||||
|
@ -1343,6 +1347,24 @@ void Workspace::updateOutputs(const QVector<Output *> &outputOrder)
|
||||||
Q_EMIT outputsChanged();
|
Q_EMIT outputsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Workspace::createDpmsFilter()
|
||||||
|
{
|
||||||
|
if (!m_dpmsFilter) {
|
||||||
|
m_dpmsFilter = std::make_unique<DpmsInputEventFilter>();
|
||||||
|
input()->prependInputEventFilter(m_dpmsFilter.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Workspace::maybeDestroyDpmsFilter()
|
||||||
|
{
|
||||||
|
const bool allOn = std::all_of(m_outputs.begin(), m_outputs.end(), [](Output *output) {
|
||||||
|
return output->dpmsMode() == Output::DpmsMode::On;
|
||||||
|
});
|
||||||
|
if (allOn) {
|
||||||
|
m_dpmsFilter.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Workspace::slotDesktopAdded(VirtualDesktop *desktop)
|
void Workspace::slotDesktopAdded(VirtualDesktop *desktop)
|
||||||
{
|
{
|
||||||
m_focusChain->addDesktop(desktop);
|
m_focusChain->addDesktop(desktop);
|
||||||
|
|
|
@ -78,6 +78,7 @@ class OutputConfiguration;
|
||||||
class TileManager;
|
class TileManager;
|
||||||
class OutputConfigurationStore;
|
class OutputConfigurationStore;
|
||||||
class LidSwitchTracker;
|
class LidSwitchTracker;
|
||||||
|
class DpmsInputEventFilter;
|
||||||
|
|
||||||
class KWIN_EXPORT Workspace : public QObject
|
class KWIN_EXPORT Workspace : public QObject
|
||||||
{
|
{
|
||||||
|
@ -607,6 +608,8 @@ private:
|
||||||
|
|
||||||
void updateOutputConfiguration();
|
void updateOutputConfiguration();
|
||||||
void updateOutputs(const QVector<Output *> &outputOrder = {});
|
void updateOutputs(const QVector<Output *> &outputOrder = {});
|
||||||
|
void createDpmsFilter();
|
||||||
|
void maybeDestroyDpmsFilter();
|
||||||
|
|
||||||
struct Constraint
|
struct Constraint
|
||||||
{
|
{
|
||||||
|
@ -722,6 +725,7 @@ private:
|
||||||
std::map<Output *, std::unique_ptr<TileManager>> m_tileManagers;
|
std::map<Output *, std::unique_ptr<TileManager>> m_tileManagers;
|
||||||
std::unique_ptr<OutputConfigurationStore> m_outputConfigStore;
|
std::unique_ptr<OutputConfigurationStore> m_outputConfigStore;
|
||||||
std::unique_ptr<LidSwitchTracker> m_lidSwitchTracker;
|
std::unique_ptr<LidSwitchTracker> m_lidSwitchTracker;
|
||||||
|
std::unique_ptr<DpmsInputEventFilter> m_dpmsFilter;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend bool performTransiencyCheck();
|
friend bool performTransiencyCheck();
|
||||||
|
|
Loading…
Reference in a new issue