[wayland] Add new XdgOutput properties
Summary: AbstractOutput::name() behaviour is changed so that it matches the X11 behaviour, showing an identifier like "HDMI-0". XdgOutput.name is set to this name. XdgOutput.description is currently set to the manufacturer name and model, but it's not exposed to Qt so we probably don't care too much. This should fix plasmashell changing applets when switching between X11 and wayland. Test Plan: Relevant unit test I still need to run it on my laptop. Reviewers: #kwin, #plasma, zzag Reviewed By: #kwin, #plasma, zzag Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D28230
This commit is contained in:
parent
564c739371
commit
a13ecf8d0e
10 changed files with 45 additions and 9 deletions
|
@ -104,7 +104,7 @@ public:
|
||||||
~AbstractOutput() override;
|
~AbstractOutput() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the human readable name of this output.
|
* Returns a short identifiable name of this output.
|
||||||
*/
|
*/
|
||||||
virtual QString name() const = 0;
|
virtual QString name() const = 0;
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,7 @@ AbstractWaylandOutput::~AbstractWaylandOutput()
|
||||||
|
|
||||||
QString AbstractWaylandOutput::name() const
|
QString AbstractWaylandOutput::name() const
|
||||||
{
|
{
|
||||||
return QStringLiteral("%1 %2").arg(m_waylandOutputDevice->manufacturer()).arg(
|
return m_name;
|
||||||
m_waylandOutputDevice->model());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray AbstractWaylandOutput::uuid() const
|
QByteArray AbstractWaylandOutput::uuid() const
|
||||||
|
@ -234,6 +233,12 @@ void AbstractWaylandOutput::setEnabled(bool enable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AbstractWaylandOutput::description() const
|
||||||
|
{
|
||||||
|
return QStringLiteral("%1 %2").arg(m_waylandOutputDevice->manufacturer()).arg(
|
||||||
|
m_waylandOutputDevice->model());
|
||||||
|
}
|
||||||
|
|
||||||
void AbstractWaylandOutput::setWaylandMode(const QSize &size, int refreshRate)
|
void AbstractWaylandOutput::setWaylandMode(const QSize &size, int refreshRate)
|
||||||
{
|
{
|
||||||
m_waylandOutput->setCurrentMode(size, refreshRate);
|
m_waylandOutput->setCurrentMode(size, refreshRate);
|
||||||
|
@ -275,9 +280,13 @@ void AbstractWaylandOutput::initInterfaces(const QString &model, const QString &
|
||||||
m_waylandOutput->addMode(mode.size, flags, mode.refreshRate);
|
m_waylandOutput->addMode(mode.size, flags, mode.refreshRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// start off enabled
|
|
||||||
m_waylandOutput->create();
|
|
||||||
m_waylandOutputDevice->create();
|
m_waylandOutputDevice->create();
|
||||||
|
|
||||||
|
// start off enabled
|
||||||
|
|
||||||
|
m_waylandOutput->create();
|
||||||
|
m_xdgOutput->setName(name());
|
||||||
|
m_xdgOutput->setDescription(description());
|
||||||
m_xdgOutput->setLogicalSize(pixelSize() / scale());
|
m_xdgOutput->setLogicalSize(pixelSize() / scale());
|
||||||
m_xdgOutput->done();
|
m_xdgOutput->done();
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void setEnabled(bool enable) override;
|
void setEnabled(bool enable) override;
|
||||||
|
|
||||||
|
QString description() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void modeChanged();
|
void modeChanged();
|
||||||
|
|
||||||
|
@ -137,6 +139,9 @@ protected:
|
||||||
bool internal() const {
|
bool internal() const {
|
||||||
return m_internal;
|
return m_internal;
|
||||||
}
|
}
|
||||||
|
void setName(const QString &name) {
|
||||||
|
m_name = name;
|
||||||
|
}
|
||||||
void setInternal(bool set) {
|
void setInternal(bool set) {
|
||||||
m_internal = set;
|
m_internal = set;
|
||||||
}
|
}
|
||||||
|
@ -170,6 +175,7 @@ private:
|
||||||
KWayland::Server::OutputDeviceInterface *m_waylandOutputDevice;
|
KWayland::Server::OutputDeviceInterface *m_waylandOutputDevice;
|
||||||
KWayland::Server::OutputInterface::DpmsMode m_dpms = KWayland::Server::OutputInterface::DpmsMode::On;
|
KWayland::Server::OutputInterface::DpmsMode m_dpms = KWayland::Server::OutputInterface::DpmsMode::On;
|
||||||
|
|
||||||
|
QString m_name;
|
||||||
bool m_internal = false;
|
bool m_internal = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,10 @@ void ScreenChangesTest::testScreenAddRemove()
|
||||||
QCOMPARE(xdgO2->logicalPosition(), geometries.at(1).topLeft());
|
QCOMPARE(xdgO2->logicalPosition(), geometries.at(1).topLeft());
|
||||||
QCOMPARE(xdgO2->logicalSize(), geometries.at(1).size());
|
QCOMPARE(xdgO2->logicalSize(), geometries.at(1).size());
|
||||||
|
|
||||||
|
QVERIFY(xdgO1->name().startsWith("Virtual-"));
|
||||||
|
QVERIFY(xdgO1->name() != xdgO2->name());
|
||||||
|
QVERIFY(!xdgO1->description().isEmpty());
|
||||||
|
|
||||||
// now let's try to remove one output again
|
// now let's try to remove one output again
|
||||||
outputAnnouncedSpy.clear();
|
outputAnnouncedSpy.clear();
|
||||||
outputRemovedSpy.clear();
|
outputRemovedSpy.clear();
|
||||||
|
|
|
@ -300,7 +300,7 @@ void DrmOutput::initOutputDevice(drmModeConnector *connector)
|
||||||
manufacturer = QString::fromLatin1(m_edid.eisaId());
|
manufacturer = QString::fromLatin1(m_edid.eisaId());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString connectorName = s_connectorNames.value(connector->connector_type, QByteArrayLiteral("Unknown"));
|
QString connectorName = s_connectorNames.value(connector->connector_type, QByteArrayLiteral("Unknown")) + QStringLiteral("-") + QString::number(connector->connector_type_id);
|
||||||
QString modelName;
|
QString modelName;
|
||||||
|
|
||||||
if (!m_edid.monitorName().isEmpty()) {
|
if (!m_edid.monitorName().isEmpty()) {
|
||||||
|
@ -316,7 +316,7 @@ void DrmOutput::initOutputDevice(drmModeConnector *connector)
|
||||||
modelName = i18n("unknown");
|
modelName = i18n("unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString model = connectorName + QStringLiteral("-") + QString::number(connector->connector_type_id) + QStringLiteral("-") + modelName;
|
const QString model = connectorName + QStringLiteral("-") + modelName;
|
||||||
|
|
||||||
// read in mode information
|
// read in mode information
|
||||||
QVector<KWayland::Server::OutputDeviceInterface::Mode> modes;
|
QVector<KWayland::Server::OutputDeviceInterface::Mode> modes;
|
||||||
|
@ -352,7 +352,7 @@ void DrmOutput::initOutputDevice(drmModeConnector *connector)
|
||||||
qCWarning(KWIN_DRM) << "Overwriting monitor physical size for" << m_edid.eisaId() << "/" << m_edid.monitorName() << "/" << m_edid.serialNumber() << " from " << physicalSize << "to " << overwriteSize;
|
qCWarning(KWIN_DRM) << "Overwriting monitor physical size for" << m_edid.eisaId() << "/" << m_edid.monitorName() << "/" << m_edid.serialNumber() << " from " << physicalSize << "to " << overwriteSize;
|
||||||
physicalSize = overwriteSize;
|
physicalSize = overwriteSize;
|
||||||
}
|
}
|
||||||
|
setName(connectorName);
|
||||||
initInterfaces(model, manufacturer, m_uuid, physicalSize, modes);
|
initInterfaces(model, manufacturer, m_uuid, physicalSize, modes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
FramebufferOutput::FramebufferOutput(QObject *parent):
|
||||||
|
AbstractWaylandOutput(parent)
|
||||||
|
{
|
||||||
|
setName("FB-0");
|
||||||
|
}
|
||||||
|
|
||||||
void FramebufferOutput::init(const QSize &pixelSize, const QSize &physicalSize)
|
void FramebufferOutput::init(const QSize &pixelSize, const QSize &physicalSize)
|
||||||
{
|
{
|
||||||
KWayland::Server::OutputDeviceInterface::Mode mode;
|
KWayland::Server::OutputDeviceInterface::Mode mode;
|
||||||
|
|
|
@ -34,7 +34,7 @@ class FramebufferOutput : public AbstractWaylandOutput
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FramebufferOutput(QObject *parent = nullptr) : AbstractWaylandOutput(parent) {}
|
FramebufferOutput(QObject *parent = nullptr);
|
||||||
~FramebufferOutput() override = default;
|
~FramebufferOutput() override = default;
|
||||||
|
|
||||||
void init(const QSize &pixelSize, const QSize &physicalSize);
|
void init(const QSize &pixelSize, const QSize &physicalSize);
|
||||||
|
|
|
@ -26,6 +26,9 @@ VirtualOutput::VirtualOutput(QObject *parent)
|
||||||
: AbstractWaylandOutput()
|
: AbstractWaylandOutput()
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
|
static int identifier = -1;
|
||||||
|
identifier++;
|
||||||
|
setName("Virtual-" + QString::number(identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualOutput::~VirtualOutput()
|
VirtualOutput::~VirtualOutput()
|
||||||
|
|
|
@ -41,6 +41,10 @@ WaylandOutput::WaylandOutput(Surface *surface, WaylandBackend *backend)
|
||||||
, m_surface(surface)
|
, m_surface(surface)
|
||||||
, m_backend(backend)
|
, m_backend(backend)
|
||||||
{
|
{
|
||||||
|
static int identifier = -1;
|
||||||
|
identifier++;
|
||||||
|
setName("WL-" + QString::number(identifier));
|
||||||
|
|
||||||
connect(surface, &Surface::frameRendered, [this] {
|
connect(surface, &Surface::frameRendered, [this] {
|
||||||
m_rendered = true;
|
m_rendered = true;
|
||||||
emit frameRendered();
|
emit frameRendered();
|
||||||
|
|
|
@ -37,6 +37,10 @@ X11WindowedOutput::X11WindowedOutput(X11WindowedBackend *backend)
|
||||||
, m_backend(backend)
|
, m_backend(backend)
|
||||||
{
|
{
|
||||||
m_window = xcb_generate_id(m_backend->connection());
|
m_window = xcb_generate_id(m_backend->connection());
|
||||||
|
|
||||||
|
static int identifier = -1;
|
||||||
|
identifier++;
|
||||||
|
setName("X11-" + QString::number(identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
X11WindowedOutput::~X11WindowedOutput()
|
X11WindowedOutput::~X11WindowedOutput()
|
||||||
|
|
Loading…
Reference in a new issue