From d43dac8f8d7119fdfa16540bb6d0a39fdb7895b2 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 14 Apr 2022 11:32:51 +0300 Subject: [PATCH] Merge AbstractWaylandOutput with AbstractOutput --- autotests/integration/outputchanges_test.cpp | 8 +- .../integration/xdgshellclient_rules_test.cpp | 2 +- autotests/integration/xdgshellclient_test.cpp | 2 +- src/CMakeLists.txt | 1 - src/abstract_client.cpp | 1 - src/abstract_output.cpp | 369 ++++++++++++++++-- src/abstract_output.h | 193 +++++++-- src/abstract_wayland_output.cpp | 366 ----------------- src/abstract_wayland_output.h | 224 ----------- src/backends/drm/drm_abstract_output.cpp | 4 +- src/backends/drm/drm_abstract_output.h | 4 +- src/backends/drm/drm_backend.cpp | 8 +- src/backends/drm/drm_object_connector.cpp | 18 +- src/backends/drm/drm_object_connector.h | 6 +- src/backends/drm/drm_output.cpp | 2 +- src/backends/drm/drm_output.h | 3 +- src/backends/drm/drm_pipeline.h | 4 +- src/backends/drm/drm_virtual_output.cpp | 2 +- src/backends/libinput/connection.cpp | 24 +- src/backends/libinput/device.cpp | 4 + src/backends/virtual/virtual_output.cpp | 2 +- src/backends/virtual/virtual_output.h | 4 +- src/backends/wayland/egl_wayland_backend.cpp | 2 +- src/backends/wayland/wayland_output.cpp | 4 +- src/backends/wayland/wayland_output.h | 7 +- src/backends/x11/standalone/x11_output.cpp | 55 +-- src/backends/x11/standalone/x11_output.h | 17 +- src/backends/x11/standalone/x11_platform.cpp | 4 +- .../x11/standalone/x11placeholderoutput.cpp | 44 +-- .../x11/standalone/x11placeholderoutput.h | 4 - .../x11/windowed/x11windowed_output.cpp | 2 +- .../x11/windowed/x11windowed_output.h | 4 +- src/dpmsinputeventfilter.cpp | 7 +- src/inputpanelv1client.cpp | 6 +- src/inputpanelv1client.h | 4 +- src/layershellv1integration.cpp | 2 +- src/platform.cpp | 19 +- .../scenes/opengl/abstract_egl_backend.cpp | 3 +- .../screencast/regionscreencastsource.cpp | 9 +- .../screencast/regionscreencastsource.h | 4 +- src/plugins/screencast/screencastmanager.cpp | 19 +- src/plugins/screencast/screencastmanager.h | 4 +- src/wayland_server.cpp | 24 +- src/wayland_server.h | 7 +- src/waylandoutput.cpp | 66 ++-- src/waylandoutput.h | 8 +- src/waylandoutputconfig.cpp | 4 +- src/waylandoutputconfig.h | 12 +- src/waylandoutputdevicev2.cpp | 44 +-- src/waylandoutputdevicev2.h | 8 +- src/workspace.cpp | 31 +- src/xdgshellclient.cpp | 2 +- 52 files changed, 735 insertions(+), 942 deletions(-) delete mode 100644 src/abstract_wayland_output.cpp delete mode 100644 src/abstract_wayland_output.h diff --git a/autotests/integration/outputchanges_test.cpp b/autotests/integration/outputchanges_test.cpp index 1a6c40b768..2ddb0415eb 100644 --- a/autotests/integration/outputchanges_test.cpp +++ b/autotests/integration/outputchanges_test.cpp @@ -85,7 +85,7 @@ void OutputChangesTest::testWindowSticksToOutputAfterOutputIsDisabled() // Disable the output where the window is on. WaylandOutputConfig config; { - auto changeSet = config.changeSet(static_cast(outputs[0])); + auto changeSet = config.changeSet(outputs[0]); changeSet->enabled = false; } kwinApp()->platform()->applyOutputChanges(config); @@ -111,11 +111,11 @@ void OutputChangesTest::testWindowSticksToOutputAfterAnotherOutputIsDisabled() // Disable the first output. WaylandOutputConfig config; { - auto changeSet = config.changeSet(static_cast(outputs[0])); + auto changeSet = config.changeSet(outputs[0]); changeSet->enabled = false; } { - auto changeSet = config.changeSet(static_cast(outputs[1])); + auto changeSet = config.changeSet(outputs[1]); changeSet->pos = QPoint(0, 0); } kwinApp()->platform()->applyOutputChanges(config); @@ -141,7 +141,7 @@ void OutputChangesTest::testWindowSticksToOutputAfterOutputIsMoved() // Disable the first output. WaylandOutputConfig config; { - auto changeSet = config.changeSet(static_cast(outputs[0])); + auto changeSet = config.changeSet(outputs[0]); changeSet->pos = QPoint(-10, 20); } kwinApp()->platform()->applyOutputChanges(config); diff --git a/autotests/integration/xdgshellclient_rules_test.cpp b/autotests/integration/xdgshellclient_rules_test.cpp index c2ef07e51e..274f35e4da 100644 --- a/autotests/integration/xdgshellclient_rules_test.cpp +++ b/autotests/integration/xdgshellclient_rules_test.cpp @@ -2909,7 +2909,7 @@ void TestXdgShellClientRules::testScreenForce() // Disable the output where the window is on, so the client is moved the other screen WaylandOutputConfig config; - auto changeSet = config.changeSet(static_cast(outputs.at(1))); + auto changeSet = config.changeSet(outputs.at(1)); changeSet->enabled = false; kwinApp()->platform()->applyOutputChanges(config); diff --git a/autotests/integration/xdgshellclient_test.cpp b/autotests/integration/xdgshellclient_test.cpp index 1b701fe1ef..4cd549a5ba 100644 --- a/autotests/integration/xdgshellclient_test.cpp +++ b/autotests/integration/xdgshellclient_test.cpp @@ -10,7 +10,7 @@ #include "kwin_wayland_test.h" #include "abstract_client.h" -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include "cursor.h" #include "decorations/decorationbridge.h" #include "decorations/settings.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7178c226e0..dd5e67420e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,7 +29,6 @@ target_sources(kwin PRIVATE 3rdparty/xcursor.c abstract_client.cpp abstract_output.cpp - abstract_wayland_output.cpp activation.cpp appmenu.cpp atoms.cpp diff --git a/src/abstract_client.cpp b/src/abstract_client.cpp index 39f655e270..74a84a1c8d 100644 --- a/src/abstract_client.cpp +++ b/src/abstract_client.cpp @@ -10,7 +10,6 @@ #include "abstract_client.h" #include "abstract_output.h" -#include "abstract_wayland_output.h" #if KWIN_BUILD_ACTIVITIES #include "activities.h" #endif diff --git a/src/abstract_output.cpp b/src/abstract_output.cpp index 9ac27409e4..8e714f08da 100644 --- a/src/abstract_output.cpp +++ b/src/abstract_output.cpp @@ -8,8 +8,10 @@ */ #include "abstract_output.h" -#include "outputlayer.h" +#include "waylandoutputconfig.h" + #include +#include #include namespace KWin @@ -86,34 +88,44 @@ AbstractOutput::~AbstractOutput() { } +QString AbstractOutput::name() const +{ + return m_name; +} + QUuid AbstractOutput::uuid() const { - return QUuid(); + return m_uuid; } -bool AbstractOutput::isEnabled() const +AbstractOutput::Transform AbstractOutput::transform() const { - return true; + return m_transform; } -void AbstractOutput::setEnabled(bool enable) +QString AbstractOutput::eisaId() const { - Q_UNUSED(enable) + return m_eisaId; +} + +QString AbstractOutput::manufacturer() const +{ + return m_manufacturer; +} + +QString AbstractOutput::model() const +{ + return m_model; +} + +QString AbstractOutput::serialNumber() const +{ + return m_serialNumber; } bool AbstractOutput::isInternal() const { - return false; -} - -qreal AbstractOutput::scale() const -{ - return 1; -} - -QSize AbstractOutput::physicalSize() const -{ - return QSize(); + return m_internal; } int AbstractOutput::gammaRampSize() const @@ -127,25 +139,11 @@ bool AbstractOutput::setGammaRamp(const GammaRamp &gamma) return false; } -QString AbstractOutput::manufacturer() const -{ - return QString(); -} - -QString AbstractOutput::model() const -{ - return QString(); -} - -QString AbstractOutput::serialNumber() const -{ - return QString(); -} - void AbstractOutput::inhibitDirectScanout() { m_directScanoutCount++; } + void AbstractOutput::uninhibitDirectScanout() { m_directScanoutCount--; @@ -172,4 +170,311 @@ QRect AbstractOutput::mapFromGlobal(const QRect &rect) const return rect.translated(-geometry().topLeft()); } +AbstractOutput::Capabilities AbstractOutput::capabilities() const +{ + return m_capabilities; +} + +void AbstractOutput::setCapabilityInternal(Capability capability, bool on) +{ + if (static_cast(m_capabilities & capability) != on) { + m_capabilities.setFlag(capability, on); + Q_EMIT capabilitiesChanged(); + } +} + +qreal AbstractOutput::scale() const +{ + return m_scale; +} + +void AbstractOutput::setScale(qreal scale) +{ + if (m_scale != scale) { + m_scale = scale; + Q_EMIT scaleChanged(); + Q_EMIT geometryChanged(); + } +} + +QRect AbstractOutput::geometry() const +{ + return QRect(m_position, pixelSize() / scale()); +} + +QSize AbstractOutput::physicalSize() const +{ + return orientateSize(m_physicalSize); +} + +int AbstractOutput::refreshRate() const +{ + return m_refreshRate; +} + +void AbstractOutput::moveTo(const QPoint &pos) +{ + if (m_position != pos) { + m_position = pos; + Q_EMIT geometryChanged(); + } +} + +QSize AbstractOutput::modeSize() const +{ + return m_modeSize; +} + +QSize AbstractOutput::pixelSize() const +{ + return orientateSize(m_modeSize); +} + +QByteArray AbstractOutput::edid() const +{ + return m_edid; +} + +bool AbstractOutput::Mode::operator==(const Mode &other) const +{ + return id == other.id && other.flags == flags && size == other.size && refreshRate == other.refreshRate; +} + +QVector AbstractOutput::modes() const +{ + return m_modes; +} + +void AbstractOutput::setModes(const QVector &modes) +{ + if (m_modes != modes) { + m_modes = modes; + Q_EMIT modesChanged(); + } +} + +AbstractOutput::SubPixel AbstractOutput::subPixel() const +{ + return m_subPixel; +} + +void AbstractOutput::setSubPixelInternal(SubPixel subPixel) +{ + m_subPixel = subPixel; +} + +void AbstractOutput::applyChanges(const WaylandOutputConfig &config) +{ + auto props = config.constChangeSet(this); + Q_EMIT aboutToChange(); + + setEnabled(props->enabled); + updateTransform(props->transform); + moveTo(props->pos); + setScale(props->scale); + setVrrPolicy(props->vrrPolicy); + setRgbRangeInternal(props->rgbRange); + + Q_EMIT changed(); +} + +bool AbstractOutput::isEnabled() const +{ + return m_isEnabled; +} + +void AbstractOutput::setEnabled(bool enable) +{ + if (m_isEnabled != enable) { + m_isEnabled = enable; + updateEnablement(enable); + Q_EMIT enabledChanged(); + } +} + +QString AbstractOutput::description() const +{ + return m_manufacturer + ' ' + m_model; +} + +void AbstractOutput::setCurrentModeInternal(const QSize &size, int refreshRate) +{ + const bool sizeChanged = m_modeSize != size; + if (sizeChanged || m_refreshRate != refreshRate) { + m_modeSize = size; + m_refreshRate = refreshRate; + + Q_EMIT currentModeChanged(); + if (sizeChanged) { + Q_EMIT geometryChanged(); + } + } +} + +static QUuid generateOutputId(const QString &eisaId, const QString &model, + const QString &serialNumber, const QString &name) +{ + static const QUuid urlNs = QUuid("6ba7b811-9dad-11d1-80b4-00c04fd430c8"); // NameSpace_URL + static const QUuid kwinNs = QUuid::createUuidV5(urlNs, QStringLiteral("https://kwin.kde.org/o/")); + + const QString payload = QStringList{name, eisaId, model, serialNumber}.join(':'); + return QUuid::createUuidV5(kwinNs, payload); +} + +void AbstractOutput::initialize(const QString &model, const QString &manufacturer, + const QString &eisaId, const QString &serialNumber, + const QSize &physicalSize, + const QVector &modes, const QByteArray &edid) +{ + m_serialNumber = serialNumber; + m_eisaId = eisaId; + m_manufacturer = manufacturer.isEmpty() ? i18n("unknown") : manufacturer; + m_model = model; + m_physicalSize = physicalSize; + m_edid = edid; + m_modes = modes; + m_uuid = generateOutputId(m_eisaId, m_model, m_serialNumber, m_name); + + for (const Mode &mode : modes) { + if (mode.flags & ModeFlag::Current) { + m_modeSize = mode.size; + m_refreshRate = mode.refreshRate; + break; + } + } +} + +QSize AbstractOutput::orientateSize(const QSize &size) const +{ + if (m_transform == Transform::Rotated90 || m_transform == Transform::Rotated270 || m_transform == Transform::Flipped90 || m_transform == Transform::Flipped270) { + return size.transposed(); + } + return size; +} + +void AbstractOutput::setTransformInternal(Transform transform) +{ + if (m_transform != transform) { + m_transform = transform; + Q_EMIT transformChanged(); + Q_EMIT currentModeChanged(); + Q_EMIT geometryChanged(); + } +} + +void AbstractOutput::setDpmsModeInternal(DpmsMode dpmsMode) +{ + if (m_dpmsMode != dpmsMode) { + m_dpmsMode = dpmsMode; + Q_EMIT dpmsModeChanged(); + } +} + +void AbstractOutput::setDpmsMode(DpmsMode mode) +{ + Q_UNUSED(mode) +} + +AbstractOutput::DpmsMode AbstractOutput::dpmsMode() const +{ + return m_dpmsMode; +} + +QMatrix4x4 AbstractOutput::logicalToNativeMatrix(const QRect &rect, qreal scale, Transform transform) +{ + QMatrix4x4 matrix; + matrix.scale(scale); + + switch (transform) { + case Transform::Normal: + case Transform::Flipped: + break; + case Transform::Rotated90: + case Transform::Flipped90: + matrix.translate(0, rect.width()); + matrix.rotate(-90, 0, 0, 1); + break; + case Transform::Rotated180: + case Transform::Flipped180: + matrix.translate(rect.width(), rect.height()); + matrix.rotate(-180, 0, 0, 1); + break; + case Transform::Rotated270: + case Transform::Flipped270: + matrix.translate(rect.height(), 0); + matrix.rotate(-270, 0, 0, 1); + break; + } + + switch (transform) { + case Transform::Flipped: + case Transform::Flipped90: + case Transform::Flipped180: + case Transform::Flipped270: + matrix.translate(rect.width(), 0); + matrix.scale(-1, 1); + break; + default: + break; + } + + matrix.translate(-rect.x(), -rect.y()); + + return matrix; +} + +void AbstractOutput::setOverscanInternal(uint32_t overscan) +{ + if (m_overscan != overscan) { + m_overscan = overscan; + Q_EMIT overscanChanged(); + } +} + +uint32_t AbstractOutput::overscan() const +{ + return m_overscan; +} + +void AbstractOutput::setVrrPolicy(RenderLoop::VrrPolicy policy) +{ + if (renderLoop()->vrrPolicy() != policy && (m_capabilities & Capability::Vrr)) { + renderLoop()->setVrrPolicy(policy); + Q_EMIT vrrPolicyChanged(); + } +} + +RenderLoop::VrrPolicy AbstractOutput::vrrPolicy() const +{ + return renderLoop()->vrrPolicy(); +} + +bool AbstractOutput::isPlaceholder() const +{ + return m_isPlaceholder; +} + +void AbstractOutput::setPlaceholder(bool isPlaceholder) +{ + m_isPlaceholder = isPlaceholder; +} + +AbstractOutput::RgbRange AbstractOutput::rgbRange() const +{ + return m_rgbRange; +} + +void AbstractOutput::setRgbRangeInternal(RgbRange range) +{ + if (m_rgbRange != range) { + m_rgbRange = range; + Q_EMIT rgbRangeChanged(); + } +} + +void AbstractOutput::setPhysicalSizeInternal(const QSize &size) +{ + m_physicalSize = size; +} + } // namespace KWin diff --git a/src/abstract_output.h b/src/abstract_output.h index 4bf09f1594..5699b465ec 100644 --- a/src/abstract_output.h +++ b/src/abstract_output.h @@ -11,22 +11,22 @@ #include +#include "renderloop.h" + #include +#include #include #include #include #include #include -namespace KWaylandServer -{ -class OutputChangeSetV2; -} - namespace KWin { + class EffectScreenImpl; class RenderLoop; +class WaylandOutputConfig; class KWIN_EXPORT GammaRamp { @@ -90,6 +90,56 @@ class KWIN_EXPORT AbstractOutput : public QObject Q_OBJECT public: + enum class ModeFlag : uint { + Current = 0x1, + Preferred = 0x2, + }; + Q_DECLARE_FLAGS(ModeFlags, ModeFlag) + Q_ENUM(ModeFlag) + + struct Mode + { + QSize size; + int refreshRate; + ModeFlags flags; + int id; + + inline bool operator==(const Mode &other) const; + }; + + enum class DpmsMode { + On, + Standby, + Suspend, + Off, + }; + Q_ENUM(DpmsMode) + + enum class Capability : uint { + Dpms = 0x1, + Overscan = 0x2, + Vrr = 0x4, + RgbRange = 0x8, + }; + Q_DECLARE_FLAGS(Capabilities, Capability) + + enum class SubPixel { + Unknown, + None, + Horizontal_RGB, + Horizontal_BGR, + Vertical_RGB, + Vertical_BGR, + }; + Q_ENUM(SubPixel) + + enum class RgbRange { + Automatic = 0, + Full = 1, + Limited = 2, + }; + Q_ENUM(RgbRange) + explicit AbstractOutput(QObject *parent = nullptr); ~AbstractOutput() override; @@ -101,31 +151,31 @@ public: /** * Returns a short identifiable name of this output. */ - virtual QString name() const = 0; + QString name() const; /** * Returns the identifying uuid of this output. * * Default implementation returns an empty byte array. */ - virtual QUuid uuid() const; + QUuid uuid() const; /** * Returns @c true if the output is enabled; otherwise returns @c false. */ - virtual bool isEnabled() const; + bool isEnabled() const; /** * Enable or disable the output. * * Default implementation does nothing */ - virtual void setEnabled(bool enable); + void setEnabled(bool enable); /** * Returns geometry of this output in device independent pixels. */ - virtual QRect geometry() const = 0; + QRect geometry() const; /** * Equivalent to `QRect(QPoint(0, 0), geometry().size())` @@ -135,29 +185,27 @@ public: /** * Returns the approximate vertical refresh rate of this output, in mHz. */ - virtual int refreshRate() const = 0; + int refreshRate() const; /** * Returns whether this output is connected through an internal connector, * e.g. LVDS, or eDP. - * - * Default implementation returns @c false. */ - virtual bool isInternal() const; + bool isInternal() const; /** * Returns the ratio between physical pixels and logical pixels. * * Default implementation returns 1. */ - virtual qreal scale() const; + qreal scale() const; /** * Returns the physical size of this output, in millimeters. * * Default implementation returns an invalid QSize. */ - virtual QSize physicalSize() const; + QSize physicalSize() const; /** * Returns the size of the gamma lookup table. @@ -174,20 +222,23 @@ public: virtual bool setGammaRamp(const GammaRamp &gamma); /** Returns the resolution of the output. */ - virtual QSize pixelSize() const = 0; + QSize pixelSize() const; + QSize modeSize() const; + + QString eisaId() const; /** * Returns the manufacturer of the screen. */ - virtual QString manufacturer() const; + QString manufacturer() const; /** * Returns the model of the screen. */ - virtual QString model() const; + QString model() const; /** * Returns the serial number of the screen. */ - virtual QString serialNumber() const; + QString serialNumber() const; /** * Returns the RenderLoop for this output. If the platform does not support per screen @@ -221,13 +272,37 @@ public: Flipped270 }; Q_ENUM(Transform) - virtual Transform transform() const - { - return Transform::Normal; - } + Transform transform() const; virtual bool usesSoftwareCursor() const; + void moveTo(const QPoint &pos); + void setScale(qreal scale); + + void applyChanges(const WaylandOutputConfig &config); + + SubPixel subPixel() const; + QString description() const; + Capabilities capabilities() const; + QByteArray edid() const; + QVector modes() const; + void setModes(const QVector &modes); + DpmsMode dpmsMode() const; + virtual void setDpmsMode(DpmsMode mode); + + uint32_t overscan() const; + + /** + * Returns a matrix that can translate into the display's coordinates system + */ + static QMatrix4x4 logicalToNativeMatrix(const QRect &rect, qreal scale, Transform transform); + + void setVrrPolicy(RenderLoop::VrrPolicy policy); + RenderLoop::VrrPolicy vrrPolicy() const; + RgbRange rgbRange() const; + + bool isPlaceholder() const; + Q_SIGNALS: /** * This signal is emitted when the geometry of this output has changed. @@ -272,10 +347,78 @@ Q_SIGNALS: */ void changed(); + void currentModeChanged(); + void modesChanged(); + void outputChange(const QRegion &damagedRegion); + void transformChanged(); + void dpmsModeChanged(); + void capabilitiesChanged(); + void overscanChanged(); + void vrrPolicyChanged(); + void rgbRangeChanged(); + +protected: + void initialize(const QString &model, const QString &manufacturer, + const QString &eisaId, const QString &serialNumber, + const QSize &physicalSize, + const QVector &modes, const QByteArray &edid); + + void setName(const QString &name) + { + m_name = name; + } + void setInternal(bool set) + { + m_internal = set; + } + + virtual void updateEnablement(bool enable) + { + Q_UNUSED(enable); + } + virtual void updateTransform(Transform transform) + { + Q_UNUSED(transform); + } + + void setCurrentModeInternal(const QSize &size, int refreshRate); + void setTransformInternal(Transform transform); + void setDpmsModeInternal(DpmsMode dpmsMode); + void setCapabilityInternal(Capability capability, bool on = true); + void setSubPixelInternal(SubPixel subPixel); + void setOverscanInternal(uint32_t overscan); + void setPlaceholder(bool isPlaceholder); + void setRgbRangeInternal(RgbRange range); + void setPhysicalSizeInternal(const QSize &size); + + QSize orientateSize(const QSize &size) const; + private: Q_DISABLE_COPY(AbstractOutput) EffectScreenImpl *m_effectScreen = nullptr; int m_directScanoutCount = 0; + QString m_name; + QString m_eisaId; + QString m_manufacturer; + QString m_model; + QString m_serialNumber; + QUuid m_uuid; + QSize m_modeSize; + QSize m_physicalSize; + QPoint m_position; + qreal m_scale = 1; + Capabilities m_capabilities; + Transform m_transform = Transform::Normal; + QByteArray m_edid; + QVector m_modes; + DpmsMode m_dpmsMode = DpmsMode::On; + SubPixel m_subPixel = SubPixel::Unknown; + int m_refreshRate = -1; + bool m_isEnabled = true; + bool m_internal = false; + bool m_isPlaceholder = false; + uint32_t m_overscan = 0; + RgbRange m_rgbRange = RgbRange::Automatic; friend class EffectScreenImpl; // to access m_effectScreen }; @@ -288,4 +431,6 @@ KWIN_EXPORT QDebug operator<<(QDebug debug, const AbstractOutput *output); } // namespace KWin +Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::AbstractOutput::Capabilities) + #endif diff --git a/src/abstract_wayland_output.cpp b/src/abstract_wayland_output.cpp deleted file mode 100644 index de8f8fcf32..0000000000 --- a/src/abstract_wayland_output.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2019 Roman Gilg - SPDX-FileCopyrightText: 2020 David Edmundson - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#include "abstract_wayland_output.h" -#include "screens.h" -#include "waylandoutputconfig.h" - -// KWayland -#include -// KF5 -#include - -#include - -namespace KWin -{ - -AbstractWaylandOutput::AbstractWaylandOutput(QObject *parent) - : AbstractOutput(parent) -{ -} - -AbstractWaylandOutput::Capabilities AbstractWaylandOutput::capabilities() const -{ - return m_capabilities; -} - -void AbstractWaylandOutput::setCapabilityInternal(Capability capability, bool on) -{ - if (static_cast(m_capabilities & capability) != on) { - m_capabilities.setFlag(capability, on); - Q_EMIT capabilitiesChanged(); - } -} - -QString AbstractWaylandOutput::name() const -{ - return m_name; -} - -QUuid AbstractWaylandOutput::uuid() const -{ - return m_uuid; -} - -QRect AbstractWaylandOutput::geometry() const -{ - return QRect(m_position, pixelSize() / scale()); -} - -QSize AbstractWaylandOutput::physicalSize() const -{ - return orientateSize(m_physicalSize); -} - -int AbstractWaylandOutput::refreshRate() const -{ - return m_refreshRate; -} - -void AbstractWaylandOutput::moveTo(const QPoint &pos) -{ - if (m_position != pos) { - m_position = pos; - Q_EMIT geometryChanged(); - } -} - -QString AbstractWaylandOutput::eisaId() const -{ - return m_eisaId; -} - -QString AbstractWaylandOutput::manufacturer() const -{ - return m_manufacturer; -} - -QString AbstractWaylandOutput::model() const -{ - return m_model; -} - -QString AbstractWaylandOutput::serialNumber() const -{ - return m_serialNumber; -} - -QSize AbstractWaylandOutput::modeSize() const -{ - return m_modeSize; -} - -QSize AbstractWaylandOutput::pixelSize() const -{ - return orientateSize(m_modeSize); -} - -QByteArray AbstractWaylandOutput::edid() const -{ - return m_edid; -} - -bool AbstractWaylandOutput::Mode::operator==(const Mode &other) const -{ - return id == other.id && other.flags == flags && size == other.size && refreshRate == other.refreshRate; -} - -QVector AbstractWaylandOutput::modes() const -{ - return m_modes; -} - -void AbstractWaylandOutput::setModes(const QVector &modes) -{ - if (m_modes != modes) { - m_modes = modes; - Q_EMIT modesChanged(); - } -} - -qreal AbstractWaylandOutput::scale() const -{ - return m_scale; -} - -void AbstractWaylandOutput::setScale(qreal scale) -{ - if (m_scale != scale) { - m_scale = scale; - Q_EMIT scaleChanged(); - Q_EMIT geometryChanged(); - } -} - -AbstractWaylandOutput::SubPixel AbstractWaylandOutput::subPixel() const -{ - return m_subPixel; -} - -void AbstractWaylandOutput::setSubPixelInternal(SubPixel subPixel) -{ - m_subPixel = subPixel; -} - -void AbstractWaylandOutput::applyChanges(const WaylandOutputConfig &config) -{ - auto props = config.constChangeSet(this); - Q_EMIT aboutToChange(); - - setEnabled(props->enabled); - updateTransform(props->transform); - moveTo(props->pos); - setScale(props->scale); - setVrrPolicy(props->vrrPolicy); - setRgbRangeInternal(props->rgbRange); - - Q_EMIT changed(); -} - -bool AbstractWaylandOutput::isEnabled() const -{ - return m_isEnabled; -} - -void AbstractWaylandOutput::setEnabled(bool enable) -{ - if (m_isEnabled != enable) { - m_isEnabled = enable; - updateEnablement(enable); - Q_EMIT enabledChanged(); - } -} - -QString AbstractWaylandOutput::description() const -{ - return m_manufacturer + ' ' + m_model; -} - -void AbstractWaylandOutput::setCurrentModeInternal(const QSize &size, int refreshRate) -{ - const bool sizeChanged = m_modeSize != size; - if (sizeChanged || m_refreshRate != refreshRate) { - m_modeSize = size; - m_refreshRate = refreshRate; - - Q_EMIT currentModeChanged(); - if (sizeChanged) { - Q_EMIT geometryChanged(); - } - } -} - -static QUuid generateOutputId(const QString &eisaId, const QString &model, - const QString &serialNumber, const QString &name) -{ - static const QUuid urlNs = QUuid("6ba7b811-9dad-11d1-80b4-00c04fd430c8"); // NameSpace_URL - static const QUuid kwinNs = QUuid::createUuidV5(urlNs, QStringLiteral("https://kwin.kde.org/o/")); - - const QString payload = QStringList{name, eisaId, model, serialNumber}.join(':'); - return QUuid::createUuidV5(kwinNs, payload); -} - -void AbstractWaylandOutput::initialize(const QString &model, const QString &manufacturer, - const QString &eisaId, const QString &serialNumber, - const QSize &physicalSize, - const QVector &modes, const QByteArray &edid) -{ - m_serialNumber = serialNumber; - m_eisaId = eisaId; - m_manufacturer = manufacturer.isEmpty() ? i18n("unknown") : manufacturer; - m_model = model; - m_physicalSize = physicalSize; - m_edid = edid; - m_modes = modes; - m_uuid = generateOutputId(m_eisaId, m_model, m_serialNumber, m_name); - - for (const Mode &mode : modes) { - if (mode.flags & ModeFlag::Current) { - m_modeSize = mode.size; - m_refreshRate = mode.refreshRate; - break; - } - } -} - -QSize AbstractWaylandOutput::orientateSize(const QSize &size) const -{ - if (m_transform == Transform::Rotated90 || m_transform == Transform::Rotated270 || m_transform == Transform::Flipped90 || m_transform == Transform::Flipped270) { - return size.transposed(); - } - return size; -} - -void AbstractWaylandOutput::setTransformInternal(Transform transform) -{ - if (m_transform != transform) { - m_transform = transform; - Q_EMIT transformChanged(); - Q_EMIT currentModeChanged(); - Q_EMIT geometryChanged(); - } -} - -AbstractWaylandOutput::Transform AbstractWaylandOutput::transform() const -{ - return m_transform; -} - -void AbstractWaylandOutput::setDpmsModeInternal(DpmsMode dpmsMode) -{ - if (m_dpmsMode != dpmsMode) { - m_dpmsMode = dpmsMode; - Q_EMIT dpmsModeChanged(); - } -} - -void AbstractWaylandOutput::setDpmsMode(DpmsMode mode) -{ - Q_UNUSED(mode) -} - -AbstractWaylandOutput::DpmsMode AbstractWaylandOutput::dpmsMode() const -{ - return m_dpmsMode; -} - -QMatrix4x4 AbstractWaylandOutput::logicalToNativeMatrix(const QRect &rect, qreal scale, Transform transform) -{ - QMatrix4x4 matrix; - matrix.scale(scale); - - switch (transform) { - case Transform::Normal: - case Transform::Flipped: - break; - case Transform::Rotated90: - case Transform::Flipped90: - matrix.translate(0, rect.width()); - matrix.rotate(-90, 0, 0, 1); - break; - case Transform::Rotated180: - case Transform::Flipped180: - matrix.translate(rect.width(), rect.height()); - matrix.rotate(-180, 0, 0, 1); - break; - case Transform::Rotated270: - case Transform::Flipped270: - matrix.translate(rect.height(), 0); - matrix.rotate(-270, 0, 0, 1); - break; - } - - switch (transform) { - case Transform::Flipped: - case Transform::Flipped90: - case Transform::Flipped180: - case Transform::Flipped270: - matrix.translate(rect.width(), 0); - matrix.scale(-1, 1); - break; - default: - break; - } - - matrix.translate(-rect.x(), -rect.y()); - - return matrix; -} - -void AbstractWaylandOutput::setOverscanInternal(uint32_t overscan) -{ - if (m_overscan != overscan) { - m_overscan = overscan; - Q_EMIT overscanChanged(); - } -} - -uint32_t AbstractWaylandOutput::overscan() const -{ - return m_overscan; -} - -void AbstractWaylandOutput::setVrrPolicy(RenderLoop::VrrPolicy policy) -{ - if (renderLoop()->vrrPolicy() != policy && (m_capabilities & Capability::Vrr)) { - renderLoop()->setVrrPolicy(policy); - Q_EMIT vrrPolicyChanged(); - } -} - -RenderLoop::VrrPolicy AbstractWaylandOutput::vrrPolicy() const -{ - return renderLoop()->vrrPolicy(); -} - -bool AbstractWaylandOutput::isPlaceholder() const -{ - return m_isPlaceholder; -} - -void AbstractWaylandOutput::setPlaceholder(bool isPlaceholder) -{ - m_isPlaceholder = isPlaceholder; -} - -AbstractWaylandOutput::RgbRange AbstractWaylandOutput::rgbRange() const -{ - return m_rgbRange; -} - -void AbstractWaylandOutput::setRgbRangeInternal(RgbRange range) -{ - if (m_rgbRange != range) { - m_rgbRange = range; - Q_EMIT rgbRangeChanged(); - } -} - -} diff --git a/src/abstract_wayland_output.h b/src/abstract_wayland_output.h deleted file mode 100644 index a94dd1be01..0000000000 --- a/src/abstract_wayland_output.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2019 Roman Gilg - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#ifndef KWIN_ABSTRACT_WAYLAND_OUTPUT_H -#define KWIN_ABSTRACT_WAYLAND_OUTPUT_H - -#include "abstract_output.h" -#include "renderloop.h" -#include "utils/common.h" -#include - -#include -#include -#include - -namespace KWin -{ - -class WaylandOutputConfig; - -/** - * Generic output representation in a Wayland session - */ -class KWIN_EXPORT AbstractWaylandOutput : public AbstractOutput -{ - Q_OBJECT -public: - enum class ModeFlag : uint { - Current = 0x1, - Preferred = 0x2, - }; - Q_DECLARE_FLAGS(ModeFlags, ModeFlag) - Q_ENUM(ModeFlag) - - struct Mode - { - QSize size; - int refreshRate; - ModeFlags flags; - int id; - - inline bool operator==(const Mode &other) const; - }; - - enum class DpmsMode { - On, - Standby, - Suspend, - Off, - }; - Q_ENUM(DpmsMode) - - enum class Capability : uint { - Dpms = 0x1, - Overscan = 0x2, - Vrr = 0x4, - RgbRange = 0x8, - }; - Q_DECLARE_FLAGS(Capabilities, Capability) - - enum class SubPixel { - Unknown, - None, - Horizontal_RGB, - Horizontal_BGR, - Vertical_RGB, - Vertical_BGR, - }; - Q_ENUM(SubPixel) - - enum class RgbRange { - Automatic = 0, - Full = 1, - Limited = 2, - }; - Q_ENUM(RgbRange) - - explicit AbstractWaylandOutput(QObject *parent = nullptr); - - QString name() const override; - QUuid uuid() const override; - - QSize modeSize() const; - - // TODO: The name is ambiguous. Rename this function. - QSize pixelSize() const override; - qreal scale() const override; - QRect geometry() const override; - QSize physicalSize() const override; - - /** - * Returns the orientation of this output. - * - * - Flipped along the vertical axis is landscape + inv. portrait. - * - Rotated 90° and flipped along the horizontal axis is portrait + inv. landscape - * - Rotated 180° and flipped along the vertical axis is inv. landscape + inv. portrait - * - Rotated 270° and flipped along the horizontal axis is inv. portrait + inv. landscape + - * portrait - */ - Transform transform() const override; - - int refreshRate() const override; - - bool isInternal() const override - { - return m_internal; - } - - QString eisaId() const; - QString manufacturer() const override; - QString model() const override; - QString serialNumber() const override; - - void moveTo(const QPoint &pos); - void setScale(qreal scale); - - void applyChanges(const WaylandOutputConfig &config); - - bool isEnabled() const override; - void setEnabled(bool enable) override; - - SubPixel subPixel() const; - QString description() const; - Capabilities capabilities() const; - QByteArray edid() const; - QVector modes() const; - void setModes(const QVector &modes); - DpmsMode dpmsMode() const; - virtual void setDpmsMode(DpmsMode mode); - - uint32_t overscan() const; - - /** - * Returns a matrix that can translate into the display's coordinates system - */ - static QMatrix4x4 logicalToNativeMatrix(const QRect &rect, qreal scale, Transform transform); - - void setVrrPolicy(RenderLoop::VrrPolicy policy); - RenderLoop::VrrPolicy vrrPolicy() const; - RgbRange rgbRange() const; - - bool isPlaceholder() const; - -Q_SIGNALS: - void currentModeChanged(); - void modesChanged(); - void outputChange(const QRegion &damagedRegion); - void transformChanged(); - void dpmsModeChanged(); - void capabilitiesChanged(); - void overscanChanged(); - void vrrPolicyChanged(); - void rgbRangeChanged(); - -protected: - void initialize(const QString &model, const QString &manufacturer, - const QString &eisaId, const QString &serialNumber, - const QSize &physicalSize, - const QVector &modes, const QByteArray &edid); - - void setName(const QString &name) - { - m_name = name; - } - void setInternal(bool set) - { - m_internal = set; - } - - virtual void updateEnablement(bool enable) - { - Q_UNUSED(enable); - } - virtual void updateTransform(Transform transform) - { - Q_UNUSED(transform); - } - - void setCurrentModeInternal(const QSize &size, int refreshRate); - void setTransformInternal(Transform transform); - void setDpmsModeInternal(DpmsMode dpmsMode); - void setCapabilityInternal(Capability capability, bool on = true); - void setSubPixelInternal(SubPixel subPixel); - void setOverscanInternal(uint32_t overscan); - void setPlaceholder(bool isPlaceholder); - void setRgbRangeInternal(RgbRange range); - - QSize orientateSize(const QSize &size) const; - -private: - QString m_name; - QString m_eisaId; - QString m_manufacturer; - QString m_model; - QString m_serialNumber; - QUuid m_uuid; - QSize m_modeSize; - QSize m_physicalSize; - QPoint m_position; - qreal m_scale = 1; - Capabilities m_capabilities; - Transform m_transform = Transform::Normal; - QByteArray m_edid; - QVector m_modes; - DpmsMode m_dpmsMode = DpmsMode::On; - SubPixel m_subPixel = SubPixel::Unknown; - int m_refreshRate = -1; - bool m_isEnabled = true; - bool m_internal = false; - bool m_isPlaceholder = false; - uint32_t m_overscan = 0; - RgbRange m_rgbRange = RgbRange::Automatic; -}; - -} - -Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::AbstractWaylandOutput::Capabilities) - -#endif // KWIN_OUTPUT_H diff --git a/src/backends/drm/drm_abstract_output.cpp b/src/backends/drm/drm_abstract_output.cpp index f660315b46..d6b47b7cfa 100644 --- a/src/backends/drm/drm_abstract_output.cpp +++ b/src/backends/drm/drm_abstract_output.cpp @@ -15,7 +15,7 @@ namespace KWin { DrmAbstractOutput::DrmAbstractOutput(DrmGpu *gpu) - : AbstractWaylandOutput(gpu->platform()) + : AbstractOutput(gpu->platform()) , m_renderLoop(new RenderLoop(this)) , m_gpu(gpu) { @@ -39,7 +39,7 @@ void DrmAbstractOutput::pageFlipped(std::chrono::nanoseconds timestamp) const QVector DrmAbstractOutput::regionToRects(const QRegion ®ion) const { const int height = pixelSize().height(); - const QMatrix4x4 matrix = AbstractWaylandOutput::logicalToNativeMatrix(rect(), scale(), transform()); + const QMatrix4x4 matrix = AbstractOutput::logicalToNativeMatrix(rect(), scale(), transform()); QVector rects; rects.reserve(region.rectCount() * 4); for (const QRect &_rect : region) { diff --git a/src/backends/drm/drm_abstract_output.h b/src/backends/drm/drm_abstract_output.h index 783bea77e6..364d2a9752 100644 --- a/src/backends/drm/drm_abstract_output.h +++ b/src/backends/drm/drm_abstract_output.h @@ -8,7 +8,7 @@ */ #pragma once -#include "abstract_wayland_output.h" +#include "abstract_output.h" namespace KWin { @@ -17,7 +17,7 @@ class DrmBackend; class DrmGpu; class DrmOutputLayer; -class DrmAbstractOutput : public AbstractWaylandOutput +class DrmAbstractOutput : public AbstractOutput { Q_OBJECT public: diff --git a/src/backends/drm/drm_backend.cpp b/src/backends/drm/drm_backend.cpp index a1988064aa..1b0307e5f5 100644 --- a/src/backends/drm/drm_backend.cpp +++ b/src/backends/drm/drm_backend.cpp @@ -107,7 +107,7 @@ void DrmBackend::turnOutputsOn() { m_dpmsFilter.reset(); for (auto it = m_enabledOutputs.constBegin(), end = m_enabledOutputs.constEnd(); it != end; it++) { - (*it)->setDpmsMode(AbstractWaylandOutput::DpmsMode::On); + (*it)->setDpmsMode(AbstractOutput::DpmsMode::On); } } @@ -118,7 +118,7 @@ void DrmBackend::checkOutputsAreOn() return; } for (auto it = m_enabledOutputs.constBegin(), end = m_enabledOutputs.constEnd(); it != end; it++) { - if ((*it)->dpmsMode() != AbstractWaylandOutput::DpmsMode::On) { + if ((*it)->dpmsMode() != AbstractOutput::DpmsMode::On) { // dpms still disabled, need to keep the filter return; } @@ -435,7 +435,7 @@ bool DrmBackend::readOutputsConfiguration(const QVector &ou Q_ASSERT(!outputs.isEmpty()); const auto outputsInfo = KWinKScreenIntegration::outputsConfig(outputs); - AbstractWaylandOutput *primaryOutput = outputs.constFirst(); + AbstractOutput *primaryOutput = outputs.constFirst(); WaylandOutputConfig cfg; // default position goes from left to right QPoint pos(0, 0); @@ -460,7 +460,7 @@ bool DrmBackend::readOutputsConfiguration(const QVector &ou props->overscan = static_cast(outputInfo["overscan"].toInt(props->overscan)); props->vrrPolicy = static_cast(outputInfo["vrrpolicy"].toInt(static_cast(props->vrrPolicy))); - props->rgbRange = static_cast(outputInfo["rgbrange"].toInt(static_cast(props->rgbRange))); + props->rgbRange = static_cast(outputInfo["rgbrange"].toInt(static_cast(props->rgbRange))); if (const QJsonObject mode = outputInfo["mode"].toObject(); !mode.isEmpty()) { const QJsonObject size = mode["size"].toObject(); diff --git a/src/backends/drm/drm_object_connector.cpp b/src/backends/drm/drm_object_connector.cpp index 05e5f875f8..19a5b9cdc5 100644 --- a/src/backends/drm/drm_object_connector.cpp +++ b/src/backends/drm/drm_object_connector.cpp @@ -207,21 +207,21 @@ QSharedPointer DrmConnector::findMode(const drmModeModeInfo &m return it == m_modes.constEnd() ? nullptr : *it; } -AbstractWaylandOutput::SubPixel DrmConnector::subpixel() const +AbstractOutput::SubPixel DrmConnector::subpixel() const { switch (m_conn->subpixel) { case DRM_MODE_SUBPIXEL_UNKNOWN: - return AbstractWaylandOutput::SubPixel::Unknown; + return AbstractOutput::SubPixel::Unknown; case DRM_MODE_SUBPIXEL_NONE: - return AbstractWaylandOutput::SubPixel::None; + return AbstractOutput::SubPixel::None; case DRM_MODE_SUBPIXEL_HORIZONTAL_RGB: - return AbstractWaylandOutput::SubPixel::Horizontal_RGB; + return AbstractOutput::SubPixel::Horizontal_RGB; case DRM_MODE_SUBPIXEL_HORIZONTAL_BGR: - return AbstractWaylandOutput::SubPixel::Horizontal_BGR; + return AbstractOutput::SubPixel::Horizontal_BGR; case DRM_MODE_SUBPIXEL_VERTICAL_RGB: - return AbstractWaylandOutput::SubPixel::Vertical_RGB; + return AbstractOutput::SubPixel::Vertical_RGB; case DRM_MODE_SUBPIXEL_VERTICAL_BGR: - return AbstractWaylandOutput::SubPixel::Vertical_BGR; + return AbstractOutput::SubPixel::Vertical_BGR; default: Q_UNREACHABLE(); } @@ -271,10 +271,10 @@ bool DrmConnector::hasRgbRange() const return rgb && rgb->hasAllEnums(); } -AbstractWaylandOutput::RgbRange DrmConnector::rgbRange() const +AbstractOutput::RgbRange DrmConnector::rgbRange() const { const auto &rgb = getProp(PropertyIndex::Broadcast_RGB); - return rgb->enumForValue(rgb->pending()); + return rgb->enumForValue(rgb->pending()); } bool DrmConnector::updateProperties() diff --git a/src/backends/drm/drm_object_connector.h b/src/backends/drm/drm_object_connector.h index b7a8a70808..2866c0a0ad 100644 --- a/src/backends/drm/drm_object_connector.h +++ b/src/backends/drm/drm_object_connector.h @@ -14,7 +14,7 @@ #include -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include "drm_object.h" #include "drm_pointer.h" #include "edid.h" @@ -101,12 +101,12 @@ public: QVector> modes() const; QSharedPointer findMode(const drmModeModeInfo &modeInfo) const; - AbstractWaylandOutput::SubPixel subpixel() const; + AbstractOutput::SubPixel subpixel() const; bool hasOverscan() const; uint32_t overscan() const; bool vrrCapable() const; bool hasRgbRange() const; - AbstractWaylandOutput::RgbRange rgbRange() const; + AbstractOutput::RgbRange rgbRange() const; LinkStatus linkStatus() const; private: diff --git a/src/backends/drm/drm_output.cpp b/src/backends/drm/drm_output.cpp index 666acc9b7c..9fe36373d6 100644 --- a/src/backends/drm/drm_output.cpp +++ b/src/backends/drm/drm_output.cpp @@ -165,7 +165,7 @@ void DrmOutput::moveCursor() } } -QVector DrmOutput::getModes() const +QVector DrmOutput::getModes() const { bool modeFound = false; QVector modes; diff --git a/src/backends/drm/drm_output.h b/src/backends/drm/drm_output.h index 8aeeca949e..53986e4a13 100644 --- a/src/backends/drm/drm_output.h +++ b/src/backends/drm/drm_output.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,7 @@ private: bool setDrmDpmsMode(DpmsMode mode); void setDpmsMode(DpmsMode mode) override; - QVector getModes() const; + QVector getModes() const; int gammaRampSize() const override; bool setGammaRamp(const GammaRamp &gamma) override; diff --git a/src/backends/drm/drm_pipeline.h b/src/backends/drm/drm_pipeline.h index 11783de44a..b17a3b133b 100644 --- a/src/backends/drm/drm_pipeline.h +++ b/src/backends/drm/drm_pipeline.h @@ -17,7 +17,7 @@ #include #include -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include "drm_object_plane.h" #include "renderloop_p.h" @@ -104,7 +104,7 @@ public: bool enabled = true; // whether or not the pipeline needs a crtc QSharedPointer mode; uint32_t overscan = 0; - AbstractWaylandOutput::RgbRange rgbRange = AbstractWaylandOutput::RgbRange::Automatic; + AbstractOutput::RgbRange rgbRange = AbstractOutput::RgbRange::Automatic; RenderLoopPrivate::SyncMode syncMode = RenderLoopPrivate::SyncMode::Fixed; QSharedPointer gamma; diff --git a/src/backends/drm/drm_virtual_output.cpp b/src/backends/drm/drm_virtual_output.cpp index e7a8e396cd..bfe2beba8c 100644 --- a/src/backends/drm/drm_virtual_output.cpp +++ b/src/backends/drm/drm_virtual_output.cpp @@ -34,7 +34,7 @@ DrmVirtualOutput::DrmVirtualOutput(const QString &name, DrmGpu *gpu, const QSize setName("Virtual-" + name); m_modeIndex = 0; - QVector modes = {{size, 60000, AbstractWaylandOutput::ModeFlags(AbstractWaylandOutput::ModeFlag::Current) | AbstractWaylandOutput::ModeFlag::Preferred, 0}}; + QVector modes = {{size, 60000, AbstractOutput::ModeFlags(AbstractOutput::ModeFlag::Current) | AbstractOutput::ModeFlag::Preferred, 0}}; initialize(QLatin1String("model_") + name, QLatin1String("manufacturer_") + name, QLatin1String("eisa_") + name, diff --git a/src/backends/libinput/connection.cpp b/src/backends/libinput/connection.cpp index 95fae76a4c..648a84d8b1 100644 --- a/src/backends/libinput/connection.cpp +++ b/src/backends/libinput/connection.cpp @@ -14,7 +14,7 @@ // TODO: Make it compile also in testing environment #ifndef KWIN_BUILD_TESTING #include "abstract_client.h" -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include "main.h" #include "platform.h" #include "workspace.h" @@ -194,9 +194,9 @@ void Connection::handleEvent() } #ifndef KWIN_BUILD_TESTING -QPointF devicePointToGlobalPosition(const QPointF &devicePos, const AbstractWaylandOutput *output) +QPointF devicePointToGlobalPosition(const QPointF &devicePos, const AbstractOutput *output) { - using Transform = AbstractWaylandOutput::Transform; + using Transform = AbstractOutput::Transform; QPointF pos = devicePos; // TODO: Do we need to handle the flipped cases differently? @@ -358,10 +358,8 @@ void Connection::processEvents() case LIBINPUT_EVENT_TOUCH_DOWN: { #ifndef KWIN_BUILD_TESTING TouchEvent *te = static_cast(event.data()); - const auto *output = static_cast(te->device()->output()); - const QPointF globalPos = - devicePointToGlobalPosition(te->absolutePos(output->modeSize()), - output); + const auto *output = te->device()->output(); + const QPointF globalPos = devicePointToGlobalPosition(te->absolutePos(output->modeSize()), output); Q_EMIT te->device()->touchDown(te->id(), globalPos, te->time(), te->device()); break; #endif @@ -374,10 +372,8 @@ void Connection::processEvents() case LIBINPUT_EVENT_TOUCH_MOTION: { #ifndef KWIN_BUILD_TESTING TouchEvent *te = static_cast(event.data()); - const auto *output = static_cast(te->device()->output()); - const QPointF globalPos = - devicePointToGlobalPosition(te->absolutePos(output->modeSize()), - output); + const auto *output = te->device()->output(); + const QPointF globalPos = devicePointToGlobalPosition(te->absolutePos(output->modeSize()), output); Q_EMIT te->device()->touchMotion(te->id(), globalPos, te->time(), te->device()); break; #endif @@ -477,12 +473,12 @@ void Connection::processEvents() if (workspace()) { #ifndef KWIN_BUILD_TESTING - AbstractWaylandOutput *output = static_cast(tte->device()->output()); + AbstractOutput *output = tte->device()->output(); if (!output && workspace()->activeClient()) { - output = static_cast(workspace()->activeClient()->output()); + output = workspace()->activeClient()->output(); } if (!output) { - output = static_cast(workspace()->activeOutput()); + output = workspace()->activeOutput(); } const QPointF globalPos = devicePointToGlobalPosition(tte->transformedPosition(output->modeSize()), diff --git a/src/backends/libinput/device.cpp b/src/backends/libinput/device.cpp index 8baee01559..1340fd562e 100644 --- a/src/backends/libinput/device.cpp +++ b/src/backends/libinput/device.cpp @@ -672,6 +672,7 @@ AbstractOutput *Device::output() const void Device::setOutput(AbstractOutput *output) { +#ifndef KWIN_BUILD_TESTING m_output = output; if (m_output) { writeEntry(ConfigKey::OutputName, output->name()); @@ -679,6 +680,9 @@ void Device::setOutput(AbstractOutput *output) writeEntry(ConfigKey::OutputName, QString()); } Q_EMIT outputNameChanged(); +#else + Q_UNUSED(output) +#endif } static libinput_led toLibinputLEDS(LEDs leds) diff --git a/src/backends/virtual/virtual_output.cpp b/src/backends/virtual/virtual_output.cpp index 96d8f876f4..646abf5894 100644 --- a/src/backends/virtual/virtual_output.cpp +++ b/src/backends/virtual/virtual_output.cpp @@ -16,7 +16,7 @@ namespace KWin { VirtualOutput::VirtualOutput(VirtualBackend *parent) - : AbstractWaylandOutput(parent) + : AbstractOutput(parent) , m_backend(parent) , m_renderLoop(new RenderLoop(this)) , m_vsyncMonitor(SoftwareVsyncMonitor::create(this)) diff --git a/src/backends/virtual/virtual_output.h b/src/backends/virtual/virtual_output.h index 42cce32f16..3962d356dd 100644 --- a/src/backends/virtual/virtual_output.h +++ b/src/backends/virtual/virtual_output.h @@ -9,7 +9,7 @@ #ifndef KWIN_VIRTUAL_OUTPUT_H #define KWIN_VIRTUAL_OUTPUT_H -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include #include @@ -20,7 +20,7 @@ namespace KWin class SoftwareVsyncMonitor; class VirtualBackend; -class VirtualOutput : public AbstractWaylandOutput +class VirtualOutput : public AbstractOutput { Q_OBJECT diff --git a/src/backends/wayland/egl_wayland_backend.cpp b/src/backends/wayland/egl_wayland_backend.cpp index 03addc7925..e0cedb4422 100644 --- a/src/backends/wayland/egl_wayland_backend.cpp +++ b/src/backends/wayland/egl_wayland_backend.cpp @@ -44,7 +44,7 @@ namespace KWin namespace Wayland { -static QVector regionToRects(const QRegion ®ion, AbstractWaylandOutput *output) +static QVector regionToRects(const QRegion ®ion, AbstractOutput *output) { const int height = output->modeSize().height(); const QMatrix4x4 matrix = WaylandOutput::logicalToNativeMatrix(output->rect(), diff --git a/src/backends/wayland/wayland_output.cpp b/src/backends/wayland/wayland_output.cpp index 18bab33f57..843dcc6c9b 100644 --- a/src/backends/wayland/wayland_output.cpp +++ b/src/backends/wayland/wayland_output.cpp @@ -25,7 +25,7 @@ using namespace KWayland::Client; static const int s_refreshRate = 60000; // TODO: can we get refresh rate data from Wayland host? WaylandOutput::WaylandOutput(Surface *surface, WaylandBackend *backend) - : AbstractWaylandOutput(backend) + : AbstractOutput(backend) , m_renderLoop(new RenderLoop(this)) , m_surface(surface) , m_backend(backend) @@ -102,7 +102,7 @@ void WaylandOutput::updateEnablement(bool enable) setDpmsMode(enable ? DpmsMode::On : DpmsMode::Off); } -void WaylandOutput::setDpmsMode(KWin::AbstractWaylandOutput::DpmsMode mode) +void WaylandOutput::setDpmsMode(DpmsMode mode) { if (mode == DpmsMode::Off) { if (!m_turnOffTimer.isActive()) { diff --git a/src/backends/wayland/wayland_output.h b/src/backends/wayland/wayland_output.h index 3650069655..3e2a907f41 100644 --- a/src/backends/wayland/wayland_output.h +++ b/src/backends/wayland/wayland_output.h @@ -9,11 +9,12 @@ #ifndef KWIN_WAYLAND_OUTPUT_H #define KWIN_WAYLAND_OUTPUT_H -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include #include +#include namespace KWayland { @@ -35,7 +36,7 @@ namespace Wayland { class WaylandBackend; -class WaylandOutput : public AbstractWaylandOutput +class WaylandOutput : public AbstractOutput { Q_OBJECT public: @@ -80,7 +81,7 @@ public: void updateEnablement(bool enable) override; void updateTransform(Transform transform) override; - void setDpmsMode(KWin::AbstractWaylandOutput::DpmsMode mode) override; + void setDpmsMode(DpmsMode mode) override; Q_SIGNALS: void sizeChanged(const QSize &size); diff --git a/src/backends/x11/standalone/x11_output.cpp b/src/backends/x11/standalone/x11_output.cpp index 12d2074a03..9764298086 100644 --- a/src/backends/x11/standalone/x11_output.cpp +++ b/src/backends/x11/standalone/x11_output.cpp @@ -14,13 +14,8 @@ namespace KWin X11Output::X11Output(const QString &name, QObject *parent) : AbstractOutput(parent) - , m_name(name) { -} - -QString X11Output::name() const -{ - return m_name; + setName(name); } RenderLoop *X11Output::renderLoop() const @@ -43,29 +38,6 @@ void X11Output::setXineramaNumber(int number) m_xineramaNumber = number; } -QRect X11Output::geometry() const -{ - return m_geometry; -} - -void X11Output::setGeometry(QRect set) -{ - if (m_geometry != set) { - m_geometry = set; - Q_EMIT geometryChanged(); - } -} - -int X11Output::refreshRate() const -{ - return m_refreshRate; -} - -void X11Output::setRefreshRate(int set) -{ - m_refreshRate = set; -} - int X11Output::gammaRampSize() const { return m_gammaRampSize; @@ -93,24 +65,19 @@ void X11Output::setGammaRampSize(int size) m_gammaRampSize = size; } -QSize X11Output::physicalSize() const -{ - return m_physicalSize; -} - -void X11Output::setPhysicalSize(const QSize &size) -{ - m_physicalSize = size; -} - -QSize X11Output::pixelSize() const -{ - return geometry().size(); -} - bool X11Output::usesSoftwareCursor() const { return false; } +void X11Output::setMode(const QSize &size, int refreshRate) +{ + setCurrentModeInternal(size, refreshRate); +} + +void X11Output::setPhysicalSize(const QSize &size) +{ + setPhysicalSizeInternal(size); +} + } diff --git a/src/backends/x11/standalone/x11_output.h b/src/backends/x11/standalone/x11_output.h index bf20b2a80f..844e1c37b4 100644 --- a/src/backends/x11/standalone/x11_output.h +++ b/src/backends/x11/standalone/x11_output.h @@ -30,7 +30,7 @@ class KWIN_EXPORT X11Output : public AbstractOutput public: explicit X11Output(const QString &name, QObject *parent = nullptr); - QString name() const override; + bool usesSoftwareCursor() const override; RenderLoop *renderLoop() const override; void setRenderLoop(RenderLoop *loop); @@ -38,20 +38,11 @@ public: int xineramaNumber() const; void setXineramaNumber(int number); - QRect geometry() const override; - void setGeometry(QRect set); - - int refreshRate() const override; - void setRefreshRate(int set); - int gammaRampSize() const override; bool setGammaRamp(const GammaRamp &gamma) override; - QSize physicalSize() const override; void setPhysicalSize(const QSize &size); - - QSize pixelSize() const override; - bool usesSoftwareCursor() const override; + void setMode(const QSize &size, int refreshRate); private: void setCrtc(xcb_randr_crtc_t crtc); @@ -59,11 +50,7 @@ private: RenderLoop *m_loop = nullptr; xcb_randr_crtc_t m_crtc = XCB_NONE; - QString m_name; - QRect m_geometry; - QSize m_physicalSize; int m_gammaRampSize; - int m_refreshRate; int m_xineramaNumber = 0; friend class X11StandalonePlatform; diff --git a/src/backends/x11/standalone/x11_platform.cpp b/src/backends/x11/standalone/x11_platform.cpp index 3036dfb1f1..bd284ce1ab 100644 --- a/src/backends/x11/standalone/x11_platform.cpp +++ b/src/backends/x11/standalone/x11_platform.cpp @@ -543,8 +543,8 @@ void X11StandalonePlatform::doUpdateOutputs() output->setRenderLoop(m_renderLoop); output->setCrtc(crtcs[i]); output->setGammaRampSize(gamma.isNull() ? 0 : gamma->size); - output->setGeometry(geometry); - output->setRefreshRate(refreshRate * 1000); + output->setMode(geometry.size(), refreshRate * 1000); + output->moveTo(geometry.topLeft()); output->setXineramaNumber(i); QSize physicalSize(outputInfo->mm_width, outputInfo->mm_height); diff --git a/src/backends/x11/standalone/x11placeholderoutput.cpp b/src/backends/x11/standalone/x11placeholderoutput.cpp index 7a48f11eff..dd14ee755e 100644 --- a/src/backends/x11/standalone/x11placeholderoutput.cpp +++ b/src/backends/x11/standalone/x11placeholderoutput.cpp @@ -14,6 +14,26 @@ X11PlaceholderOutput::X11PlaceholderOutput(RenderLoop *loop, QObject *parent) : AbstractOutput(parent) , m_loop(loop) { + QSize pixelSize; + xcb_screen_t *screen = kwinApp()->x11DefaultScreen(); + if (screen) { + pixelSize = QSize(screen->width_in_pixels, screen->height_in_pixels); + } + + const Mode mode{ + .size = pixelSize, + .refreshRate = 60000, + .flags = ModeFlag::Current, + .id = 0, + }; + + const QByteArray model = QByteArrayLiteral("kwin"); + const QByteArray manufacturer = QByteArrayLiteral("xorg"); + const QByteArray eisaId; + const QByteArray serial; + + initialize(model, manufacturer, eisaId, serial, pixelSize, {mode}, QByteArray()); + setName(QStringLiteral("Placeholder-0")); } RenderLoop *X11PlaceholderOutput::renderLoop() const @@ -21,28 +41,4 @@ RenderLoop *X11PlaceholderOutput::renderLoop() const return m_loop; } -QString X11PlaceholderOutput::name() const -{ - return QStringLiteral("Placeholder-0"); -} - -QRect X11PlaceholderOutput::geometry() const -{ - xcb_screen_t *screen = kwinApp()->x11DefaultScreen(); - if (screen) { - return QRect(0, 0, screen->width_in_pixels, screen->height_in_pixels); - } - return QRect(); -} - -int X11PlaceholderOutput::refreshRate() const -{ - return 60000; -} - -QSize X11PlaceholderOutput::pixelSize() const -{ - return geometry().size(); -} - } // namespace KWin diff --git a/src/backends/x11/standalone/x11placeholderoutput.h b/src/backends/x11/standalone/x11placeholderoutput.h index a046c18b62..845c3b77c2 100644 --- a/src/backends/x11/standalone/x11placeholderoutput.h +++ b/src/backends/x11/standalone/x11placeholderoutput.h @@ -19,10 +19,6 @@ public: explicit X11PlaceholderOutput(RenderLoop *loop, QObject *parent = nullptr); RenderLoop *renderLoop() const override; - QString name() const override; - QRect geometry() const override; - int refreshRate() const override; - QSize pixelSize() const override; private: RenderLoop *m_loop; diff --git a/src/backends/x11/windowed/x11windowed_output.cpp b/src/backends/x11/windowed/x11windowed_output.cpp index 07d6be65a5..1ea24e53a8 100644 --- a/src/backends/x11/windowed/x11windowed_output.cpp +++ b/src/backends/x11/windowed/x11windowed_output.cpp @@ -26,7 +26,7 @@ namespace KWin { X11WindowedOutput::X11WindowedOutput(X11WindowedBackend *backend) - : AbstractWaylandOutput(backend) + : AbstractOutput(backend) , m_renderLoop(new RenderLoop(this)) , m_vsyncMonitor(SoftwareVsyncMonitor::create(this)) , m_backend(backend) diff --git a/src/backends/x11/windowed/x11windowed_output.h b/src/backends/x11/windowed/x11windowed_output.h index aa508acf13..b90c5c2cb2 100644 --- a/src/backends/x11/windowed/x11windowed_output.h +++ b/src/backends/x11/windowed/x11windowed_output.h @@ -9,7 +9,7 @@ #ifndef KWIN_X11WINDOWED_OUTPUT_H #define KWIN_X11WINDOWED_OUTPUT_H -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include #include @@ -29,7 +29,7 @@ class X11WindowedBackend; /** * Wayland outputs in a nested X11 setup */ -class KWIN_EXPORT X11WindowedOutput : public AbstractWaylandOutput +class KWIN_EXPORT X11WindowedOutput : public AbstractOutput { Q_OBJECT public: diff --git a/src/dpmsinputeventfilter.cpp b/src/dpmsinputeventfilter.cpp index 058810a416..cd5546c87a 100644 --- a/src/dpmsinputeventfilter.cpp +++ b/src/dpmsinputeventfilter.cpp @@ -7,7 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "dpmsinputeventfilter.h" -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include "main.h" #include "platform.h" #include "wayland_server.h" @@ -107,9 +107,8 @@ bool DpmsInputEventFilter::touchMotion(qint32 id, const QPointF &pos, quint32 ti void DpmsInputEventFilter::notify() { const QVector enabledOutputs = kwinApp()->platform()->enabledOutputs(); - for (auto it = enabledOutputs.constBegin(), end = enabledOutputs.constEnd(); it != end; it++) { - auto waylandOutput = static_cast(*it); - waylandOutput->setDpmsMode(AbstractWaylandOutput::DpmsMode::On); + for (AbstractOutput *output : enabledOutputs) { + output->setDpmsMode(AbstractOutput::DpmsMode::On); } } diff --git a/src/inputpanelv1client.cpp b/src/inputpanelv1client.cpp index 84e85d800a..432c983534 100644 --- a/src/inputpanelv1client.cpp +++ b/src/inputpanelv1client.cpp @@ -8,7 +8,7 @@ */ #include "inputpanelv1client.h" -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include "deleted.h" #include "inputmethod.h" #include "platform.h" @@ -166,13 +166,13 @@ QRect InputPanelV1Client::inputGeometry() const void InputPanelV1Client::setOutput(OutputInterface *outputIface) { if (m_output) { - disconnect(m_output, &AbstractWaylandOutput::geometryChanged, this, &InputPanelV1Client::reposition); + disconnect(m_output, &AbstractOutput::geometryChanged, this, &InputPanelV1Client::reposition); } m_output = waylandServer()->findOutput(outputIface); if (m_output) { - connect(m_output, &AbstractWaylandOutput::geometryChanged, this, &InputPanelV1Client::reposition); + connect(m_output, &AbstractOutput::geometryChanged, this, &InputPanelV1Client::reposition); } } diff --git a/src/inputpanelv1client.h b/src/inputpanelv1client.h index 97172074f8..d8a10e56d8 100644 --- a/src/inputpanelv1client.h +++ b/src/inputpanelv1client.h @@ -15,7 +15,7 @@ namespace KWin { -class AbstractWaylandOutput; +class AbstractOutput; class InputPanelV1Client : public WaylandClient { @@ -87,7 +87,7 @@ private: void reposition(); void setOutput(KWaylandServer::OutputInterface *output); - QPointer m_output; + QPointer m_output; Mode m_mode = Toplevel; const QPointer m_panelSurface; }; diff --git a/src/layershellv1integration.cpp b/src/layershellv1integration.cpp index f1910435b6..e7a16e64d1 100644 --- a/src/layershellv1integration.cpp +++ b/src/layershellv1integration.cpp @@ -5,7 +5,7 @@ */ #include "layershellv1integration.h" -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include "layershellv1client.h" #include "platform.h" #include "screens.h" diff --git a/src/platform.cpp b/src/platform.cpp index 576c04be97..b47781373f 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -102,7 +102,7 @@ void Platform::requestOutputsChange(KWaylandServer::OutputConfigurationV2Interfa const auto changes = config->changes(); for (auto it = changes.begin(); it != changes.end(); it++) { const KWaylandServer::OutputChangeSetV2 *changeset = it.value(); - auto output = qobject_cast(findOutput(it.key()->uuid())); + auto output = findOutput(it.key()->uuid()); if (!output) { qCWarning(KWIN_CORE) << "Could NOT find output matching " << it.key()->uuid(); continue; @@ -113,20 +113,15 @@ void Platform::requestOutputsChange(KWaylandServer::OutputConfigurationV2Interfa props->scale = changeset->scale(); props->modeSize = changeset->size(); props->refreshRate = changeset->refreshRate(); - props->transform = static_cast(changeset->transform()); + props->transform = static_cast(changeset->transform()); props->overscan = changeset->overscan(); - props->rgbRange = static_cast(changeset->rgbRange()); + props->rgbRange = static_cast(changeset->rgbRange()); props->vrrPolicy = static_cast(changeset->vrrPolicy()); } const auto allOutputs = outputs(); bool allDisabled = !std::any_of(allOutputs.begin(), allOutputs.end(), [&cfg](const auto &output) { - auto o = qobject_cast(output); - if (!o) { - qCWarning(KWIN_CORE) << "Platform::requestOutputsChange should only be called for Wayland platforms!"; - return false; - } - return cfg.changeSet(o)->enabled; + return cfg.changeSet(output)->enabled; }); if (allDisabled) { qCWarning(KWIN_CORE) << "Disabling all outputs through configuration changes is not allowed"; @@ -159,17 +154,17 @@ bool Platform::applyOutputChanges(const WaylandOutputConfig &config) QVector toBeEnabledOutputs; QVector toBeDisabledOutputs; for (const auto &output : availableOutputs) { - if (config.constChangeSet(qobject_cast(output))->enabled) { + if (config.constChangeSet(output)->enabled) { toBeEnabledOutputs << output; } else { toBeDisabledOutputs << output; } } for (const auto &output : toBeEnabledOutputs) { - static_cast(output)->applyChanges(config); + output->applyChanges(config); } for (const auto &output : toBeDisabledOutputs) { - static_cast(output)->applyChanges(config); + output->applyChanges(config); } return true; } diff --git a/src/platformsupport/scenes/opengl/abstract_egl_backend.cpp b/src/platformsupport/scenes/opengl/abstract_egl_backend.cpp index ffbbb1ef92..0e47c9149a 100644 --- a/src/platformsupport/scenes/opengl/abstract_egl_backend.cpp +++ b/src/platformsupport/scenes/opengl/abstract_egl_backend.cpp @@ -7,11 +7,12 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "abstract_egl_backend.h" -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include "composite.h" #include "egl_dmabuf.h" #include "options.h" #include "platform.h" +#include "utils/common.h" #include "utils/egl_context_attribute_builder.h" #include "wayland_server.h" #include diff --git a/src/plugins/screencast/regionscreencastsource.cpp b/src/plugins/screencast/regionscreencastsource.cpp index 103e784763..3d0e9882db 100644 --- a/src/plugins/screencast/regionscreencastsource.cpp +++ b/src/plugins/screencast/regionscreencastsource.cpp @@ -7,7 +7,7 @@ #include "regionscreencastsource.h" #include "screencastutils.h" -#include +#include #include #include #include @@ -38,7 +38,7 @@ bool RegionScreenCastSource::hasAlphaChannel() const return true; } -void RegionScreenCastSource::updateOutput(AbstractWaylandOutput *output) +void RegionScreenCastSource::updateOutput(AbstractOutput *output) { m_last = output->renderLoop()->lastPresentationTimestamp(); @@ -80,9 +80,8 @@ void RegionScreenCastSource::render(GLFramebuffer *target) m_target.reset(new GLFramebuffer(m_renderedTexture.data())); const auto allOutputs = kwinApp()->platform()->enabledOutputs(); for (auto output : allOutputs) { - AbstractWaylandOutput *streamOutput = qobject_cast(output); - if (streamOutput->geometry().intersects(m_region)) { - updateOutput(streamOutput); + if (output->geometry().intersects(m_region)) { + updateOutput(output); } } } diff --git a/src/plugins/screencast/regionscreencastsource.h b/src/plugins/screencast/regionscreencastsource.h index 664a548cc5..f9509c82b5 100644 --- a/src/plugins/screencast/regionscreencastsource.h +++ b/src/plugins/screencast/regionscreencastsource.h @@ -14,7 +14,7 @@ namespace KWin { -class AbstractWaylandOutput; +class AbstractOutput; class RegionScreenCastSource : public ScreenCastSource { @@ -34,7 +34,7 @@ public: { return m_region; } - void updateOutput(AbstractWaylandOutput *output); + void updateOutput(AbstractOutput *output); private: const QRect m_region; diff --git a/src/plugins/screencast/screencastmanager.cpp b/src/plugins/screencast/screencastmanager.cpp index c0767985a8..a1f9a660a3 100644 --- a/src/plugins/screencast/screencastmanager.cpp +++ b/src/plugins/screencast/screencastmanager.cpp @@ -8,7 +8,7 @@ #include "screencastmanager.h" #include "abstract_client.h" -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include "composite.h" #include "deleted.h" #include "effects.h" @@ -107,7 +107,7 @@ void ScreencastManager::streamVirtualOutput(KWaylandServer::ScreencastStreamV1In double scale, KWaylandServer::ScreencastV1Interface::CursorMode mode) { - auto output = qobject_cast(kwinApp()->platform()->createVirtualOutput(name, size, scale)); + auto output = kwinApp()->platform()->createVirtualOutput(name, size, scale); streamOutput(stream, output, mode); connect(stream, &KWaylandServer::ScreencastStreamV1Interface::finished, output, [output] { kwinApp()->platform()->removeVirtualOutput(output); @@ -122,7 +122,7 @@ void ScreencastManager::streamWaylandOutput(KWaylandServer::ScreencastStreamV1In } void ScreencastManager::streamOutput(KWaylandServer::ScreencastStreamV1Interface *waylandStream, - AbstractWaylandOutput *streamOutput, + AbstractOutput *streamOutput, KWaylandServer::ScreencastV1Interface::CursorMode mode) { if (!streamOutput) { @@ -144,7 +144,7 @@ void ScreencastManager::streamOutput(KWaylandServer::ScreencastStreamV1Interface }; connect(stream, &ScreenCastStream::startStreaming, waylandStream, [streamOutput, stream, bufferToStream] { Compositor::self()->scene()->addRepaint(streamOutput->geometry()); - connect(streamOutput, &AbstractWaylandOutput::outputChange, stream, bufferToStream); + connect(streamOutput, &AbstractOutput::outputChange, stream, bufferToStream); }); integrateStreams(waylandStream, stream); } @@ -171,19 +171,18 @@ void ScreencastManager::streamRegion(KWaylandServer::ScreencastStreamV1Interface const auto allOutputs = kwinApp()->platform()->enabledOutputs(); for (auto output : allOutputs) { - AbstractWaylandOutput *streamOutput = qobject_cast(output); - if (streamOutput->geometry().intersects(geometry)) { - auto bufferToStream = [streamOutput, stream, source](const QRegion &damagedRegion) { + if (output->geometry().intersects(geometry)) { + auto bufferToStream = [output, stream, source](const QRegion &damagedRegion) { if (damagedRegion.isEmpty()) { return; } const QRect streamRegion = source->region(); - const QRegion region = streamOutput->pixelSize() != streamOutput->modeSize() ? streamOutput->geometry() : damagedRegion; - source->updateOutput(streamOutput); + const QRegion region = output->pixelSize() != output->modeSize() ? output->geometry() : damagedRegion; + source->updateOutput(output); stream->recordFrame(region.translated(-streamRegion.topLeft()).intersected(streamRegion)); }; - connect(streamOutput, &AbstractWaylandOutput::outputChange, stream, bufferToStream); + connect(output, &AbstractOutput::outputChange, stream, bufferToStream); } } }); diff --git a/src/plugins/screencast/screencastmanager.h b/src/plugins/screencast/screencastmanager.h index cc1c97f58b..ce28f07ea2 100644 --- a/src/plugins/screencast/screencastmanager.h +++ b/src/plugins/screencast/screencastmanager.h @@ -14,7 +14,7 @@ namespace KWin { -class AbstractWaylandOutput; +class AbstractOutput; class ScreenCastStream; class ScreencastManager : public Plugin @@ -30,7 +30,7 @@ private: KWaylandServer::OutputInterface *output, KWaylandServer::ScreencastV1Interface::CursorMode mode); void - streamOutput(KWaylandServer::ScreencastStreamV1Interface *stream, AbstractWaylandOutput *output, KWaylandServer::ScreencastV1Interface::CursorMode mode); + streamOutput(KWaylandServer::ScreencastStreamV1Interface *stream, AbstractOutput *output, KWaylandServer::ScreencastV1Interface::CursorMode mode); void streamVirtualOutput(KWaylandServer::ScreencastStreamV1Interface *stream, const QString &name, const QSize &size, diff --git a/src/wayland_server.cpp b/src/wayland_server.cpp index 4f0152c95c..e706e9fac2 100644 --- a/src/wayland_server.cpp +++ b/src/wayland_server.cpp @@ -10,7 +10,7 @@ #include -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include "composite.h" #include "idle_inhibition.h" #include "inputpanelv1integration.h" @@ -306,37 +306,33 @@ void WaylandServer::initPlatform() void WaylandServer::handleOutputAdded(AbstractOutput *output) { - auto o = static_cast(output); - if (!o->isPlaceholder()) { - m_waylandOutputDevices.insert(o, new WaylandOutputDevice(o)); + if (!output->isPlaceholder()) { + m_waylandOutputDevices.insert(output, new WaylandOutputDevice(output)); } } void WaylandServer::handleOutputRemoved(AbstractOutput *output) { - auto o = static_cast(output); - if (!o->isPlaceholder()) { - delete m_waylandOutputDevices.take(o); + if (!output->isPlaceholder()) { + delete m_waylandOutputDevices.take(output); } } void WaylandServer::handleOutputEnabled(AbstractOutput *output) { - auto o = static_cast(output); - if (!o->isPlaceholder()) { - m_waylandOutputs.insert(o, new WaylandOutput(o)); + if (!output->isPlaceholder()) { + m_waylandOutputs.insert(output, new WaylandOutput(output)); } } void WaylandServer::handleOutputDisabled(AbstractOutput *output) { - auto o = static_cast(output); - if (!o->isPlaceholder()) { - delete m_waylandOutputs.take(o); + if (!output->isPlaceholder()) { + delete m_waylandOutputs.take(output); } } -AbstractWaylandOutput *WaylandServer::findOutput(KWaylandServer::OutputInterface *outputIface) const +AbstractOutput *WaylandServer::findOutput(KWaylandServer::OutputInterface *outputIface) const { for (auto it = m_waylandOutputs.constBegin(); it != m_waylandOutputs.constEnd(); ++it) { if ((*it)->waylandOutput() == outputIface) { diff --git a/src/wayland_server.h b/src/wayland_server.h index fdccf3c297..04c4885709 100644 --- a/src/wayland_server.h +++ b/src/wayland_server.h @@ -59,7 +59,6 @@ class Toplevel; class XdgPopupClient; class XdgSurfaceClient; class XdgToplevelClient; -class AbstractWaylandOutput; class WaylandOutput; class WaylandOutputDevice; @@ -226,7 +225,7 @@ public: m_linuxDmabufBuffers.remove(buffer); } - AbstractWaylandOutput *findOutput(KWaylandServer::OutputInterface *output) const; + AbstractOutput *findOutput(KWaylandServer::OutputInterface *output) const; /** * Returns the first socket name that can be used to connect to this server. @@ -291,8 +290,8 @@ private: KWaylandServer::PrimaryOutputV1Interface *m_primary = nullptr; QList m_clients; InitializationFlags m_initFlags; - QHash m_waylandOutputs; - QHash m_waylandOutputDevices; + QHash m_waylandOutputs; + QHash m_waylandOutputDevices; KWIN_SINGLETON(WaylandServer) }; diff --git a/src/waylandoutput.cpp b/src/waylandoutput.cpp index 49863e2438..9108cb2d7e 100644 --- a/src/waylandoutput.cpp +++ b/src/waylandoutput.cpp @@ -12,83 +12,83 @@ namespace KWin { -static KWaylandServer::OutputInterface::Transform kwinTransformToOutputTransform(AbstractWaylandOutput::Transform transform) +static KWaylandServer::OutputInterface::Transform kwinTransformToOutputTransform(AbstractOutput::Transform transform) { switch (transform) { - case AbstractWaylandOutput::Transform::Normal: + case AbstractOutput::Transform::Normal: return KWaylandServer::OutputInterface::Transform::Normal; - case AbstractWaylandOutput::Transform::Rotated90: + case AbstractOutput::Transform::Rotated90: return KWaylandServer::OutputInterface::Transform::Rotated90; - case AbstractWaylandOutput::Transform::Rotated180: + case AbstractOutput::Transform::Rotated180: return KWaylandServer::OutputInterface::Transform::Rotated180; - case AbstractWaylandOutput::Transform::Rotated270: + case AbstractOutput::Transform::Rotated270: return KWaylandServer::OutputInterface::Transform::Rotated270; - case AbstractWaylandOutput::Transform::Flipped: + case AbstractOutput::Transform::Flipped: return KWaylandServer::OutputInterface::Transform::Flipped; - case AbstractWaylandOutput::Transform::Flipped90: + case AbstractOutput::Transform::Flipped90: return KWaylandServer::OutputInterface::Transform::Flipped90; - case AbstractWaylandOutput::Transform::Flipped180: + case AbstractOutput::Transform::Flipped180: return KWaylandServer::OutputInterface::Transform::Flipped180; - case AbstractWaylandOutput::Transform::Flipped270: + case AbstractOutput::Transform::Flipped270: return KWaylandServer::OutputInterface::Transform::Flipped270; default: Q_UNREACHABLE(); } } -static KWaylandServer::OutputInterface::SubPixel kwinSubPixelToOutputSubPixel(AbstractWaylandOutput::SubPixel subPixel) +static KWaylandServer::OutputInterface::SubPixel kwinSubPixelToOutputSubPixel(AbstractOutput::SubPixel subPixel) { switch (subPixel) { - case AbstractWaylandOutput::SubPixel::Unknown: + case AbstractOutput::SubPixel::Unknown: return KWaylandServer::OutputInterface::SubPixel::Unknown; - case AbstractWaylandOutput::SubPixel::None: + case AbstractOutput::SubPixel::None: return KWaylandServer::OutputInterface::SubPixel::None; - case AbstractWaylandOutput::SubPixel::Horizontal_RGB: + case AbstractOutput::SubPixel::Horizontal_RGB: return KWaylandServer::OutputInterface::SubPixel::HorizontalRGB; - case AbstractWaylandOutput::SubPixel::Horizontal_BGR: + case AbstractOutput::SubPixel::Horizontal_BGR: return KWaylandServer::OutputInterface::SubPixel::HorizontalBGR; - case AbstractWaylandOutput::SubPixel::Vertical_RGB: + case AbstractOutput::SubPixel::Vertical_RGB: return KWaylandServer::OutputInterface::SubPixel::VerticalRGB; - case AbstractWaylandOutput::SubPixel::Vertical_BGR: + case AbstractOutput::SubPixel::Vertical_BGR: return KWaylandServer::OutputInterface::SubPixel::VerticalBGR; default: Q_UNREACHABLE(); } } -static KWaylandServer::OutputInterface::DpmsMode kwinDpmsModeToOutputDpmsMode(AbstractWaylandOutput::DpmsMode dpmsMode) +static KWaylandServer::OutputInterface::DpmsMode kwinDpmsModeToOutputDpmsMode(AbstractOutput::DpmsMode dpmsMode) { switch (dpmsMode) { - case AbstractWaylandOutput::DpmsMode::Off: + case AbstractOutput::DpmsMode::Off: return KWaylandServer::OutputInterface::DpmsMode::Off; - case AbstractWaylandOutput::DpmsMode::On: + case AbstractOutput::DpmsMode::On: return KWaylandServer::OutputInterface::DpmsMode::On; - case AbstractWaylandOutput::DpmsMode::Standby: + case AbstractOutput::DpmsMode::Standby: return KWaylandServer::OutputInterface::DpmsMode::Standby; - case AbstractWaylandOutput::DpmsMode::Suspend: + case AbstractOutput::DpmsMode::Suspend: return KWaylandServer::OutputInterface::DpmsMode::Suspend; default: Q_UNREACHABLE(); } } -static AbstractWaylandOutput::DpmsMode outputDpmsModeToKWinDpmsMode(KWaylandServer::OutputInterface::DpmsMode dpmsMode) +static AbstractOutput::DpmsMode outputDpmsModeToKWinDpmsMode(KWaylandServer::OutputInterface::DpmsMode dpmsMode) { switch (dpmsMode) { case KWaylandServer::OutputInterface::DpmsMode::Off: - return AbstractWaylandOutput::DpmsMode::Off; + return AbstractOutput::DpmsMode::Off; case KWaylandServer::OutputInterface::DpmsMode::On: - return AbstractWaylandOutput::DpmsMode::On; + return AbstractOutput::DpmsMode::On; case KWaylandServer::OutputInterface::DpmsMode::Standby: - return AbstractWaylandOutput::DpmsMode::Standby; + return AbstractOutput::DpmsMode::Standby; case KWaylandServer::OutputInterface::DpmsMode::Suspend: - return AbstractWaylandOutput::DpmsMode::Suspend; + return AbstractOutput::DpmsMode::Suspend; default: Q_UNREACHABLE(); } } -WaylandOutput::WaylandOutput(AbstractWaylandOutput *output, QObject *parent) +WaylandOutput::WaylandOutput(AbstractOutput *output, QObject *parent) : QObject(parent) , m_platformOutput(output) , m_waylandOutput(new KWaylandServer::OutputInterface(waylandServer()->display())) @@ -101,7 +101,7 @@ WaylandOutput::WaylandOutput(AbstractWaylandOutput *output, QObject *parent) m_waylandOutput->setModel(output->model()); m_waylandOutput->setPhysicalSize(output->physicalSize()); m_waylandOutput->setDpmsMode(kwinDpmsModeToOutputDpmsMode(output->dpmsMode())); - m_waylandOutput->setDpmsSupported(output->capabilities() & AbstractWaylandOutput::Capability::Dpms); + m_waylandOutput->setDpmsSupported(output->capabilities() & AbstractOutput::Capability::Dpms); m_waylandOutput->setGlobalPosition(geometry.topLeft()); m_waylandOutput->setScale(std::ceil(output->scale())); m_waylandOutput->setMode(output->modeSize(), output->refreshRate()); @@ -116,7 +116,7 @@ WaylandOutput::WaylandOutput(AbstractWaylandOutput *output, QObject *parent) m_xdgOutputV1->done(); // The dpms functionality is not part of the wl_output interface, but org_kde_kwin_dpms. - connect(output, &AbstractWaylandOutput::dpmsModeChanged, + connect(output, &AbstractOutput::dpmsModeChanged, this, &WaylandOutput::handleDpmsModeChanged); connect(m_waylandOutput.data(), &KWaylandServer::OutputInterface::dpmsModeRequested, this, &WaylandOutput::handleDpmsModeRequested); @@ -125,10 +125,10 @@ WaylandOutput::WaylandOutput(AbstractWaylandOutput *output, QObject *parent) m_updateTimer.setSingleShot(true); connect(&m_updateTimer, &QTimer::timeout, this, &WaylandOutput::update); - connect(output, &AbstractWaylandOutput::currentModeChanged, this, &WaylandOutput::scheduleUpdate); - connect(output, &AbstractWaylandOutput::geometryChanged, this, &WaylandOutput::scheduleUpdate); - connect(output, &AbstractWaylandOutput::transformChanged, this, &WaylandOutput::scheduleUpdate); - connect(output, &AbstractWaylandOutput::scaleChanged, this, &WaylandOutput::scheduleUpdate); + connect(output, &AbstractOutput::currentModeChanged, this, &WaylandOutput::scheduleUpdate); + connect(output, &AbstractOutput::geometryChanged, this, &WaylandOutput::scheduleUpdate); + connect(output, &AbstractOutput::transformChanged, this, &WaylandOutput::scheduleUpdate); + connect(output, &AbstractOutput::scaleChanged, this, &WaylandOutput::scheduleUpdate); } KWaylandServer::OutputInterface *WaylandOutput::waylandOutput() const diff --git a/src/waylandoutput.h b/src/waylandoutput.h index 2d6bf0b9c7..a9404b7d16 100644 --- a/src/waylandoutput.h +++ b/src/waylandoutput.h @@ -6,12 +6,14 @@ #pragma once -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include #include #include +#include + namespace KWin { @@ -20,7 +22,7 @@ class WaylandOutput : public QObject Q_OBJECT public: - explicit WaylandOutput(AbstractWaylandOutput *output, QObject *parent = nullptr); + explicit WaylandOutput(AbstractOutput *output, QObject *parent = nullptr); KWaylandServer::OutputInterface *waylandOutput() const; @@ -32,7 +34,7 @@ private Q_SLOTS: void scheduleUpdate(); private: - AbstractWaylandOutput *m_platformOutput; + AbstractOutput *m_platformOutput; QTimer m_updateTimer; KWaylandServer::ScopedGlobalPointer m_waylandOutput; KWaylandServer::XdgOutputV1Interface *m_xdgOutputV1; diff --git a/src/waylandoutputconfig.cpp b/src/waylandoutputconfig.cpp index d36a820619..f8044f5e4b 100644 --- a/src/waylandoutputconfig.cpp +++ b/src/waylandoutputconfig.cpp @@ -11,14 +11,14 @@ namespace KWin { -QSharedPointer WaylandOutputConfig::changeSet(AbstractWaylandOutput *output) +QSharedPointer WaylandOutputConfig::changeSet(AbstractOutput *output) { const auto ptr = constChangeSet(output); m_properties[output] = ptr; return ptr; } -QSharedPointer WaylandOutputConfig::constChangeSet(AbstractWaylandOutput *output) const +QSharedPointer WaylandOutputConfig::constChangeSet(AbstractOutput *output) const { if (!m_properties.contains(output)) { auto props = QSharedPointer::create(); diff --git a/src/waylandoutputconfig.h b/src/waylandoutputconfig.h index 5d98921e1f..a404abc2b2 100644 --- a/src/waylandoutputconfig.h +++ b/src/waylandoutputconfig.h @@ -11,7 +11,7 @@ #include #include -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include "kwin_export.h" namespace KWin @@ -25,20 +25,20 @@ public: float scale; QSize modeSize; uint32_t refreshRate; - AbstractWaylandOutput::Transform transform; + AbstractOutput::Transform transform; uint32_t overscan; - AbstractWaylandOutput::RgbRange rgbRange; + AbstractOutput::RgbRange rgbRange; RenderLoop::VrrPolicy vrrPolicy; }; class KWIN_EXPORT WaylandOutputConfig { public: - QSharedPointer changeSet(AbstractWaylandOutput *output); - QSharedPointer constChangeSet(AbstractWaylandOutput *output) const; + QSharedPointer changeSet(AbstractOutput *output); + QSharedPointer constChangeSet(AbstractOutput *output) const; private: - QMap> m_properties; + QMap> m_properties; }; } diff --git a/src/waylandoutputdevicev2.cpp b/src/waylandoutputdevicev2.cpp index a60c8f26a6..df496983ce 100644 --- a/src/waylandoutputdevicev2.cpp +++ b/src/waylandoutputdevicev2.cpp @@ -13,26 +13,26 @@ using namespace KWaylandServer; namespace KWin { -static KWaylandServer::OutputDeviceV2Interface::Transform kwinTransformToOutputDeviceTransform(AbstractWaylandOutput::Transform transform) +static KWaylandServer::OutputDeviceV2Interface::Transform kwinTransformToOutputDeviceTransform(AbstractOutput::Transform transform) { return static_cast(transform); } -static KWaylandServer::OutputDeviceV2Interface::SubPixel kwinSubPixelToOutputDeviceSubPixel(AbstractWaylandOutput::SubPixel subPixel) +static KWaylandServer::OutputDeviceV2Interface::SubPixel kwinSubPixelToOutputDeviceSubPixel(AbstractOutput::SubPixel subPixel) { return static_cast(subPixel); } -static KWaylandServer::OutputDeviceV2Interface::Capabilities kwinCapabilitiesToOutputDeviceCapabilities(AbstractWaylandOutput::Capabilities caps) +static KWaylandServer::OutputDeviceV2Interface::Capabilities kwinCapabilitiesToOutputDeviceCapabilities(AbstractOutput::Capabilities caps) { KWaylandServer::OutputDeviceV2Interface::Capabilities ret; - if (caps & AbstractWaylandOutput::Capability::Overscan) { + if (caps & AbstractOutput::Capability::Overscan) { ret |= KWaylandServer::OutputDeviceV2Interface::Capability::Overscan; } - if (caps & AbstractWaylandOutput::Capability::Vrr) { + if (caps & AbstractOutput::Capability::Vrr) { ret |= KWaylandServer::OutputDeviceV2Interface::Capability::Vrr; } - if (caps & AbstractWaylandOutput::Capability::RgbRange) { + if (caps & AbstractOutput::Capability::RgbRange) { ret |= KWaylandServer::OutputDeviceV2Interface::Capability::RgbRange; } return ret; @@ -43,12 +43,12 @@ static KWaylandServer::OutputDeviceV2Interface::VrrPolicy kwinVrrPolicyToOutputD return static_cast(policy); } -static KWaylandServer::OutputDeviceV2Interface::RgbRange kwinRgbRangeToOutputDeviceRgbRange(AbstractWaylandOutput::RgbRange range) +static KWaylandServer::OutputDeviceV2Interface::RgbRange kwinRgbRangeToOutputDeviceRgbRange(AbstractOutput::RgbRange range) { return static_cast(range); } -WaylandOutputDevice::WaylandOutputDevice(AbstractWaylandOutput *output, QObject *parent) +WaylandOutputDevice::WaylandOutputDevice(AbstractOutput *output, QObject *parent) : QObject(parent) , m_platformOutput(output) , m_outputDeviceV2(new KWaylandServer::OutputDeviceV2Interface(waylandServer()->display())) @@ -72,41 +72,41 @@ WaylandOutputDevice::WaylandOutputDevice(AbstractWaylandOutput *output, QObject updateModes(output); - connect(output, &AbstractWaylandOutput::geometryChanged, + connect(output, &AbstractOutput::geometryChanged, this, &WaylandOutputDevice::handleGeometryChanged); - connect(output, &AbstractWaylandOutput::scaleChanged, + connect(output, &AbstractOutput::scaleChanged, this, &WaylandOutputDevice::handleScaleChanged); - connect(output, &AbstractWaylandOutput::enabledChanged, + connect(output, &AbstractOutput::enabledChanged, this, &WaylandOutputDevice::handleEnabledChanged); - connect(output, &AbstractWaylandOutput::transformChanged, + connect(output, &AbstractOutput::transformChanged, this, &WaylandOutputDevice::handleTransformChanged); - connect(output, &AbstractWaylandOutput::currentModeChanged, + connect(output, &AbstractOutput::currentModeChanged, this, &WaylandOutputDevice::handleCurrentModeChanged); - connect(output, &AbstractWaylandOutput::capabilitiesChanged, + connect(output, &AbstractOutput::capabilitiesChanged, this, &WaylandOutputDevice::handleCapabilitiesChanged); - connect(output, &AbstractWaylandOutput::overscanChanged, + connect(output, &AbstractOutput::overscanChanged, this, &WaylandOutputDevice::handleOverscanChanged); - connect(output, &AbstractWaylandOutput::vrrPolicyChanged, + connect(output, &AbstractOutput::vrrPolicyChanged, this, &WaylandOutputDevice::handleVrrPolicyChanged); - connect(output, &AbstractWaylandOutput::modesChanged, + connect(output, &AbstractOutput::modesChanged, this, &WaylandOutputDevice::handleModesChanged); - connect(output, &AbstractWaylandOutput::rgbRangeChanged, + connect(output, &AbstractOutput::rgbRangeChanged, this, &WaylandOutputDevice::handleRgbRangeChanged); } -void WaylandOutputDevice::updateModes(AbstractWaylandOutput *output) +void WaylandOutputDevice::updateModes(AbstractOutput *output) { QList deviceModes; const auto modes = output->modes(); deviceModes.reserve(modes.size()); - for (const AbstractWaylandOutput::Mode &mode : modes) { + for (const AbstractOutput::Mode &mode : modes) { OutputDeviceModeV2Interface::ModeFlags flags; - if (mode.flags & AbstractWaylandOutput::ModeFlag::Current) { + if (mode.flags & AbstractOutput::ModeFlag::Current) { flags |= OutputDeviceModeV2Interface::ModeFlag::Current; } - if (mode.flags & AbstractWaylandOutput::ModeFlag::Preferred) { + if (mode.flags & AbstractOutput::ModeFlag::Preferred) { flags |= OutputDeviceModeV2Interface::ModeFlag::Preferred; } diff --git a/src/waylandoutputdevicev2.h b/src/waylandoutputdevicev2.h index 04e4be49cb..b78d069e58 100644 --- a/src/waylandoutputdevicev2.h +++ b/src/waylandoutputdevicev2.h @@ -7,7 +7,7 @@ #pragma once -#include "abstract_wayland_output.h" +#include "abstract_output.h" #include #include @@ -20,7 +20,7 @@ class WaylandOutputDevice : public QObject Q_OBJECT public: - explicit WaylandOutputDevice(AbstractWaylandOutput *output, QObject *parent = nullptr); + explicit WaylandOutputDevice(AbstractOutput *output, QObject *parent = nullptr); private Q_SLOTS: void handleGeometryChanged(); @@ -35,9 +35,9 @@ private Q_SLOTS: void handleRgbRangeChanged(); private: - void updateModes(AbstractWaylandOutput *output); + void updateModes(AbstractOutput *output); - AbstractWaylandOutput *m_platformOutput; + AbstractOutput *m_platformOutput; KWaylandServer::ScopedGlobalPointer m_outputDeviceV2; }; diff --git a/src/workspace.cpp b/src/workspace.cpp index a5c2c07280..37b83cd5b6 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -13,7 +13,7 @@ // kwin libs #include // kwin -#include "abstract_wayland_output.h" +#include "abstract_output.h" #if KWIN_BUILD_ACTIVITIES #include "activities.h" #endif @@ -1622,24 +1622,21 @@ QString Workspace::supportInformation() const .arg(geo.height())); support.append(QStringLiteral("Scale: %1\n").arg(output->scale())); support.append(QStringLiteral("Refresh Rate: %1\n").arg(output->refreshRate())); - const auto waylandOutput = qobject_cast(output); - if (waylandOutput) { - QString vrr = QStringLiteral("incapable"); - if (waylandOutput->capabilities() & AbstractWaylandOutput::Capability::Vrr) { - switch (waylandOutput->vrrPolicy()) { - case RenderLoop::VrrPolicy::Never: - vrr = QStringLiteral("never"); - break; - case RenderLoop::VrrPolicy::Always: - vrr = QStringLiteral("always"); - break; - case RenderLoop::VrrPolicy::Automatic: - vrr = QStringLiteral("automatic"); - break; - } + QString vrr = QStringLiteral("incapable"); + if (output->capabilities() & AbstractOutput::Capability::Vrr) { + switch (output->vrrPolicy()) { + case RenderLoop::VrrPolicy::Never: + vrr = QStringLiteral("never"); + break; + case RenderLoop::VrrPolicy::Always: + vrr = QStringLiteral("always"); + break; + case RenderLoop::VrrPolicy::Automatic: + vrr = QStringLiteral("automatic"); + break; } - support.append(QStringLiteral("Adaptive Sync: %1\n").arg(vrr)); } + support.append(QStringLiteral("Adaptive Sync: %1\n").arg(vrr)); } support.append(QStringLiteral("\nCompositing\n")); support.append(QStringLiteral("===========\n")); diff --git a/src/xdgshellclient.cpp b/src/xdgshellclient.cpp index d62acae54a..6022e0d1bf 100644 --- a/src/xdgshellclient.cpp +++ b/src/xdgshellclient.cpp @@ -9,7 +9,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "xdgshellclient.h" -#include "abstract_wayland_output.h" +#include "abstract_output.h" #if KWIN_BUILD_ACTIVITIES #include "activities.h" #endif