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"
|
2019-06-13 09:36:07 +00:00
|
|
|
#include <kwin_export.h>
|
|
|
|
|
|
|
|
#include <QObject>
|
2021-04-04 14:11:13 +00:00
|
|
|
#include <QTimer>
|
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:
|
2019-11-26 22:53:17 +00:00
|
|
|
enum class Transform {
|
|
|
|
Normal,
|
|
|
|
Rotated90,
|
|
|
|
Rotated180,
|
|
|
|
Rotated270,
|
|
|
|
Flipped,
|
|
|
|
Flipped90,
|
|
|
|
Flipped180,
|
|
|
|
Flipped270
|
|
|
|
};
|
|
|
|
|
2021-04-04 14:11:13 +00:00
|
|
|
enum class ModeFlag : uint {
|
|
|
|
Current = 0x1,
|
|
|
|
Preferred = 0x2,
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(ModeFlags, ModeFlag)
|
|
|
|
|
|
|
|
struct Mode
|
|
|
|
{
|
|
|
|
QSize size;
|
|
|
|
int refreshRate;
|
|
|
|
ModeFlags flags;
|
|
|
|
int id;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class DpmsMode {
|
|
|
|
On,
|
|
|
|
Standby,
|
|
|
|
Suspend,
|
|
|
|
Off,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class Capability : uint {
|
|
|
|
Dpms = 0x1,
|
|
|
|
};
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2019-06-13 09:36:07 +00:00
|
|
|
explicit AbstractWaylandOutput(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
QString name() const override;
|
2021-03-10 08:50:32 +00:00
|
|
|
QString 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
|
|
|
|
*/
|
|
|
|
Transform transform() const;
|
|
|
|
|
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;
|
|
|
|
|
2019-06-13 09:36:07 +00:00
|
|
|
void setGlobalPos(const QPoint &pos);
|
|
|
|
void setScale(qreal scale);
|
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
void applyChanges(const KWaylandServer::OutputChangeSet *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;
|
|
|
|
DpmsMode dpmsMode() const;
|
|
|
|
virtual void setDpmsMode(DpmsMode mode);
|
2020-04-08 09:38:41 +00:00
|
|
|
|
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();
|
|
|
|
|
2019-06-13 09:36:07 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void modeChanged();
|
2020-07-22 17:22:36 +00:00
|
|
|
void outputChange(const QRegion &damagedRegion);
|
2021-04-04 14:11:13 +00:00
|
|
|
void scaleChanged();
|
|
|
|
void transformChanged();
|
|
|
|
void dpmsModeChanged();
|
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-04 14:11:13 +00:00
|
|
|
const QString &uuid, const QSize &physicalSize,
|
|
|
|
const QVector<Mode> &modes, const QByteArray &edid);
|
2019-06-13 09:36:07 +00:00
|
|
|
|
2019-08-27 12:41:16 +00:00
|
|
|
QPoint globalPos() const;
|
2019-06-13 09:36:07 +00:00
|
|
|
|
|
|
|
bool internal() const {
|
|
|
|
return m_internal;
|
|
|
|
}
|
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);
|
|
|
|
}
|
2019-06-13 09:36:07 +00:00
|
|
|
virtual void updateMode(int modeIndex) {
|
|
|
|
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);
|
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;
|
|
|
|
QString 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<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;
|
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
|