[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;
|
||||
|
||||
/**
|
||||
* Returns the human readable name of this output.
|
||||
* Returns a short identifiable name of this output.
|
||||
*/
|
||||
virtual QString name() const = 0;
|
||||
|
||||
|
|
|
@ -54,8 +54,7 @@ AbstractWaylandOutput::~AbstractWaylandOutput()
|
|||
|
||||
QString AbstractWaylandOutput::name() const
|
||||
{
|
||||
return QStringLiteral("%1 %2").arg(m_waylandOutputDevice->manufacturer()).arg(
|
||||
m_waylandOutputDevice->model());
|
||||
return m_name;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
// start off enabled
|
||||
m_waylandOutput->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->done();
|
||||
}
|
||||
|
|
|
@ -124,6 +124,8 @@ public:
|
|||
*/
|
||||
void setEnabled(bool enable) override;
|
||||
|
||||
QString description() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void modeChanged();
|
||||
|
||||
|
@ -137,6 +139,9 @@ protected:
|
|||
bool internal() const {
|
||||
return m_internal;
|
||||
}
|
||||
void setName(const QString &name) {
|
||||
m_name = name;
|
||||
}
|
||||
void setInternal(bool set) {
|
||||
m_internal = set;
|
||||
}
|
||||
|
@ -170,6 +175,7 @@ private:
|
|||
KWayland::Server::OutputDeviceInterface *m_waylandOutputDevice;
|
||||
KWayland::Server::OutputInterface::DpmsMode m_dpms = KWayland::Server::OutputInterface::DpmsMode::On;
|
||||
|
||||
QString m_name;
|
||||
bool m_internal = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -155,6 +155,10 @@ void ScreenChangesTest::testScreenAddRemove()
|
|||
QCOMPARE(xdgO2->logicalPosition(), geometries.at(1).topLeft());
|
||||
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
|
||||
outputAnnouncedSpy.clear();
|
||||
outputRemovedSpy.clear();
|
||||
|
|
|
@ -300,7 +300,7 @@ void DrmOutput::initOutputDevice(drmModeConnector *connector)
|
|||
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;
|
||||
|
||||
if (!m_edid.monitorName().isEmpty()) {
|
||||
|
@ -316,7 +316,7 @@ void DrmOutput::initOutputDevice(drmModeConnector *connector)
|
|||
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
|
||||
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;
|
||||
physicalSize = overwriteSize;
|
||||
}
|
||||
|
||||
setName(connectorName);
|
||||
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
|
||||
{
|
||||
|
||||
FramebufferOutput::FramebufferOutput(QObject *parent):
|
||||
AbstractWaylandOutput(parent)
|
||||
{
|
||||
setName("FB-0");
|
||||
}
|
||||
|
||||
void FramebufferOutput::init(const QSize &pixelSize, const QSize &physicalSize)
|
||||
{
|
||||
KWayland::Server::OutputDeviceInterface::Mode mode;
|
||||
|
|
|
@ -34,7 +34,7 @@ class FramebufferOutput : public AbstractWaylandOutput
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FramebufferOutput(QObject *parent = nullptr) : AbstractWaylandOutput(parent) {}
|
||||
FramebufferOutput(QObject *parent = nullptr);
|
||||
~FramebufferOutput() override = default;
|
||||
|
||||
void init(const QSize &pixelSize, const QSize &physicalSize);
|
||||
|
|
|
@ -26,6 +26,9 @@ VirtualOutput::VirtualOutput(QObject *parent)
|
|||
: AbstractWaylandOutput()
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
static int identifier = -1;
|
||||
identifier++;
|
||||
setName("Virtual-" + QString::number(identifier));
|
||||
}
|
||||
|
||||
VirtualOutput::~VirtualOutput()
|
||||
|
|
|
@ -41,6 +41,10 @@ WaylandOutput::WaylandOutput(Surface *surface, WaylandBackend *backend)
|
|||
, m_surface(surface)
|
||||
, m_backend(backend)
|
||||
{
|
||||
static int identifier = -1;
|
||||
identifier++;
|
||||
setName("WL-" + QString::number(identifier));
|
||||
|
||||
connect(surface, &Surface::frameRendered, [this] {
|
||||
m_rendered = true;
|
||||
emit frameRendered();
|
||||
|
|
|
@ -37,6 +37,10 @@ X11WindowedOutput::X11WindowedOutput(X11WindowedBackend *backend)
|
|||
, m_backend(backend)
|
||||
{
|
||||
m_window = xcb_generate_id(m_backend->connection());
|
||||
|
||||
static int identifier = -1;
|
||||
identifier++;
|
||||
setName("X11-" + QString::number(identifier));
|
||||
}
|
||||
|
||||
X11WindowedOutput::~X11WindowedOutput()
|
||||
|
|
Loading…
Reference in a new issue