2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2019-06-13 09:36:07 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
|
2019-06-13 09:36:07 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2019-06-13 09:36:07 +00:00
|
|
|
#ifndef KWIN_ABSTRACT_WAYLAND_OUTPUT_H
|
|
|
|
#define KWIN_ABSTRACT_WAYLAND_OUTPUT_H
|
|
|
|
|
|
|
|
#include "abstract_output.h"
|
2020-08-11 16:13:57 +00:00
|
|
|
#include "utils.h"
|
2021-02-20 15:04:18 +00:00
|
|
|
#include "renderloop.h"
|
2019-06-13 09:36:07 +00:00
|
|
|
#include <kwin_export.h>
|
|
|
|
|
|
|
|
#include <QObject>
|
2021-04-04 14:11:13 +00:00
|
|
|
#include <QTimer>
|
2021-07-21 10:11:21 +00:00
|
|
|
#include <QSize>
|
2019-06-13 09:36:07 +00:00
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
namespace KWaylandServer
|
2019-06-13 09:36:07 +00:00
|
|
|
{
|
|
|
|
class OutputChangeSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generic output representation in a Wayland session
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-06-13 09:36:07 +00:00
|
|
|
class KWIN_EXPORT AbstractWaylandOutput : public AbstractOutput
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-04-04 14:11:13 +00:00
|
|
|
enum class ModeFlag : uint {
|
|
|
|
Current = 0x1,
|
|
|
|
Preferred = 0x2,
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(ModeFlags, ModeFlag)
|
2021-06-08 20:22:39 +00:00
|
|
|
Q_ENUM(ModeFlag)
|
2021-04-04 14:11:13 +00:00
|
|
|
|
|
|
|
struct Mode
|
|
|
|
{
|
|
|
|
QSize size;
|
|
|
|
int refreshRate;
|
|
|
|
ModeFlags flags;
|
|
|
|
int id;
|
2021-07-21 10:11:21 +00:00
|
|
|
|
|
|
|
inline bool operator==(const Mode &other) const;
|
2021-04-04 14:11:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class DpmsMode {
|
|
|
|
On,
|
|
|
|
Standby,
|
|
|
|
Suspend,
|
|
|
|
Off,
|
|
|
|
};
|
2021-06-08 20:22:39 +00:00
|
|
|
Q_ENUM(DpmsMode)
|
2021-04-04 14:11:13 +00:00
|
|
|
|
|
|
|
enum class Capability : uint {
|
|
|
|
Dpms = 0x1,
|
2021-04-11 14:26:21 +00:00
|
|
|
Overscan = 0x2,
|
2021-02-20 15:04:18 +00:00
|
|
|
Vrr = 0x4,
|
2021-08-31 14:59:06 +00:00
|
|
|
RgbRange = 0x8,
|
2021-04-04 14:11:13 +00:00
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(Capabilities, Capability)
|
|
|
|
|
2021-04-07 13:31:04 +00:00
|
|
|
enum class SubPixel {
|
|
|
|
Unknown,
|
|
|
|
None,
|
|
|
|
Horizontal_RGB,
|
|
|
|
Horizontal_BGR,
|
|
|
|
Vertical_RGB,
|
|
|
|
Vertical_BGR,
|
|
|
|
};
|
2021-06-08 20:22:39 +00:00
|
|
|
Q_ENUM(SubPixel)
|
2021-04-07 13:31:04 +00:00
|
|
|
|
2021-08-31 14:59:06 +00:00
|
|
|
enum class RgbRange {
|
|
|
|
Automatic = 0,
|
|
|
|
Full = 1,
|
|
|
|
Limited = 2,
|
|
|
|
};
|
|
|
|
Q_ENUM(RgbRange)
|
|
|
|
|
2019-06-13 09:36:07 +00:00
|
|
|
explicit AbstractWaylandOutput(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
QString name() const override;
|
2021-04-06 20:08:02 +00:00
|
|
|
QUuid uuid() const override;
|
2019-06-13 09:36:07 +00:00
|
|
|
|
2020-01-02 14:55:05 +00:00
|
|
|
QSize modeSize() const;
|
|
|
|
|
|
|
|
// TODO: The name is ambiguous. Rename this function.
|
2020-07-22 17:22:36 +00:00
|
|
|
QSize pixelSize() const override;
|
2019-08-27 12:41:16 +00:00
|
|
|
qreal scale() const override;
|
2019-06-13 09:36:07 +00:00
|
|
|
QRect geometry() const override;
|
|
|
|
QSize physicalSize() const override;
|
|
|
|
|
2019-12-12 14:41:12 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2021-07-29 02:07:13 +00:00
|
|
|
Transform transform() const override;
|
2019-12-12 14:41:12 +00:00
|
|
|
|
2019-06-13 09:36:07 +00:00
|
|
|
int refreshRate() const override;
|
|
|
|
|
|
|
|
bool isInternal() const override {
|
|
|
|
return m_internal;
|
|
|
|
}
|
|
|
|
|
2021-04-06 20:15:24 +00:00
|
|
|
QString eisaId() const;
|
2020-11-24 17:31:06 +00:00
|
|
|
QString manufacturer() const override;
|
|
|
|
QString model() const override;
|
|
|
|
QString serialNumber() const override;
|
|
|
|
|
2021-08-26 12:06:16 +00:00
|
|
|
void moveTo(const QPoint &pos);
|
2019-06-13 09:36:07 +00:00
|
|
|
void setScale(qreal scale);
|
|
|
|
|
2021-07-21 10:11:21 +00:00
|
|
|
void applyChanges(const KWaylandServer::OutputChangeSetV2 *changeSet) override;
|
2019-06-13 09:36:07 +00:00
|
|
|
|
2021-01-22 08:22:24 +00:00
|
|
|
bool isEnabled() const override;
|
2019-08-28 18:54:37 +00:00
|
|
|
void setEnabled(bool enable) override;
|
2019-06-13 09:36:07 +00:00
|
|
|
|
2021-04-07 13:31:04 +00:00
|
|
|
SubPixel subPixel() const;
|
2020-04-08 09:38:41 +00:00
|
|
|
QString description() const;
|
2021-04-04 14:11:13 +00:00
|
|
|
Capabilities capabilities() const;
|
|
|
|
QByteArray edid() const;
|
|
|
|
QVector<Mode> modes() const;
|
2021-07-21 10:11:21 +00:00
|
|
|
void setModes(const QVector<Mode> &modes);
|
2021-04-04 14:11:13 +00:00
|
|
|
DpmsMode dpmsMode() const;
|
|
|
|
virtual void setDpmsMode(DpmsMode mode);
|
2020-04-08 09:38:41 +00:00
|
|
|
|
2021-04-11 14:26:21 +00:00
|
|
|
uint32_t overscan() const;
|
|
|
|
virtual void setOverscan(uint32_t overscan);
|
|
|
|
|
2020-08-12 16:52:08 +00:00
|
|
|
/**
|
|
|
|
* Returns a matrix that can translate into the display's coordinates system
|
|
|
|
*/
|
2020-10-13 20:57:15 +00:00
|
|
|
static QMatrix4x4 logicalToNativeMatrix(const QRect &rect, qreal scale, Transform transform);
|
2020-08-12 16:52:08 +00:00
|
|
|
|
2021-02-02 13:26:43 +00:00
|
|
|
void recordingStarted();
|
|
|
|
void recordingStopped();
|
|
|
|
|
|
|
|
bool isBeingRecorded();
|
|
|
|
|
2021-02-20 15:04:18 +00:00
|
|
|
void setVrrPolicy(RenderLoop::VrrPolicy policy);
|
|
|
|
RenderLoop::VrrPolicy vrrPolicy() const;
|
|
|
|
|
2021-08-31 14:59:06 +00:00
|
|
|
virtual void setRgbRange(RgbRange range);
|
|
|
|
RgbRange rgbRange() const;
|
|
|
|
|
2021-07-26 23:11:50 +00:00
|
|
|
bool isPlaceholder() const;
|
|
|
|
|
2019-06-13 09:36:07 +00:00
|
|
|
Q_SIGNALS:
|
2021-07-21 10:11:21 +00:00
|
|
|
void currentModeChanged();
|
|
|
|
void modesChanged();
|
2020-07-22 17:22:36 +00:00
|
|
|
void outputChange(const QRegion &damagedRegion);
|
2021-04-04 14:11:13 +00:00
|
|
|
void transformChanged();
|
|
|
|
void dpmsModeChanged();
|
2021-04-11 14:26:21 +00:00
|
|
|
void capabilitiesChanged();
|
|
|
|
void overscanChanged();
|
2021-02-20 15:04:18 +00:00
|
|
|
void vrrPolicyChanged();
|
2021-08-31 14:59:06 +00:00
|
|
|
void rgbRangeChanged();
|
2019-06-13 09:36:07 +00:00
|
|
|
|
|
|
|
protected:
|
2021-04-04 14:11:13 +00:00
|
|
|
void initialize(const QString &model, const QString &manufacturer,
|
2021-04-06 20:15:24 +00:00
|
|
|
const QString &eisaId, const QString &serialNumber,
|
2021-04-06 20:08:02 +00:00
|
|
|
const QSize &physicalSize,
|
2021-04-04 14:11:13 +00:00
|
|
|
const QVector<Mode> &modes, const QByteArray &edid);
|
2019-06-13 09:36:07 +00:00
|
|
|
|
2020-04-08 09:38:41 +00:00
|
|
|
void setName(const QString &name) {
|
|
|
|
m_name = name;
|
|
|
|
}
|
2019-06-13 09:36:07 +00:00
|
|
|
void setInternal(bool set) {
|
|
|
|
m_internal = set;
|
|
|
|
}
|
2019-08-31 08:27:04 +00:00
|
|
|
|
|
|
|
virtual void updateEnablement(bool enable) {
|
|
|
|
Q_UNUSED(enable);
|
|
|
|
}
|
2021-09-02 12:34:07 +00:00
|
|
|
virtual void updateMode(const QSize &size, uint32_t refreshRate)
|
2021-07-21 10:11:21 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(size);
|
|
|
|
Q_UNUSED(refreshRate);
|
|
|
|
}
|
|
|
|
virtual void applyMode(int modeIndex) {
|
2019-06-13 09:36:07 +00:00
|
|
|
Q_UNUSED(modeIndex);
|
|
|
|
}
|
2019-11-26 22:53:17 +00:00
|
|
|
virtual void updateTransform(Transform transform) {
|
2019-06-13 09:36:07 +00:00
|
|
|
Q_UNUSED(transform);
|
|
|
|
}
|
|
|
|
|
2021-04-04 14:11:13 +00:00
|
|
|
void setCurrentModeInternal(const QSize &size, int refreshRate);
|
|
|
|
void setTransformInternal(Transform transform);
|
|
|
|
void setDpmsModeInternal(DpmsMode dpmsMode);
|
|
|
|
void setCapabilityInternal(Capability capability, bool on = true);
|
2021-04-07 13:31:04 +00:00
|
|
|
void setSubPixelInternal(SubPixel subPixel);
|
2021-04-11 14:26:21 +00:00
|
|
|
void setOverscanInternal(uint32_t overscan);
|
2021-07-26 23:11:50 +00:00
|
|
|
void setPlaceholder(bool isPlaceholder);
|
2021-08-31 14:59:06 +00:00
|
|
|
void setRgbRangeInternal(RgbRange range);
|
2019-06-13 09:36:07 +00:00
|
|
|
|
|
|
|
QSize orientateSize(const QSize &size) const;
|
|
|
|
|
|
|
|
private:
|
2020-04-08 09:38:41 +00:00
|
|
|
QString m_name;
|
2021-04-06 20:15:24 +00:00
|
|
|
QString m_eisaId;
|
2021-04-04 14:11:13 +00:00
|
|
|
QString m_manufacturer;
|
|
|
|
QString m_model;
|
|
|
|
QString m_serialNumber;
|
2021-04-06 20:08:02 +00:00
|
|
|
QUuid m_uuid;
|
2021-04-04 14:11:13 +00:00
|
|
|
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<Mode> m_modes;
|
|
|
|
DpmsMode m_dpmsMode = DpmsMode::On;
|
2021-04-07 13:31:04 +00:00
|
|
|
SubPixel m_subPixel = SubPixel::Unknown;
|
2021-04-04 14:11:13 +00:00
|
|
|
int m_refreshRate = -1;
|
2021-02-02 13:26:43 +00:00
|
|
|
int m_recorders = 0;
|
2021-04-04 14:11:13 +00:00
|
|
|
bool m_isEnabled = true;
|
|
|
|
bool m_internal = false;
|
2021-07-26 23:11:50 +00:00
|
|
|
bool m_isPlaceholder = false;
|
2021-04-11 14:26:21 +00:00
|
|
|
uint32_t m_overscan = 0;
|
2021-08-31 14:59:06 +00:00
|
|
|
RgbRange m_rgbRange = RgbRange::Automatic;
|
2019-06-13 09:36:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-04-04 14:11:13 +00:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::AbstractWaylandOutput::Capabilities)
|
|
|
|
|
2019-06-13 09:36:07 +00:00
|
|
|
#endif // KWIN_OUTPUT_H
|