Add XdgOutputV1 version 2
Summary: Will be useful for making plasma widgets not move about on multi monitor. QtWayland already supports it Test Plan: Unit test Reviewers: #kwin, zzag Reviewed By: #kwin, zzag Subscribers: apol, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D27535
This commit is contained in:
parent
148888b569
commit
cbc38479d9
3 changed files with 74 additions and 2 deletions
|
@ -68,6 +68,9 @@ void TestXdgOutput::init()
|
|||
m_serverXdgOutput = m_serverXdgOutputManager->createXdgOutput(m_serverOutput, this);
|
||||
m_serverXdgOutput->setLogicalSize(QSize(1280, 720)); //a 1.5 scale factor
|
||||
m_serverXdgOutput->setLogicalPosition(QPoint(11,12)); //not a sensible value for one monitor, but works for this test
|
||||
m_serverXdgOutput->setName("testName");
|
||||
m_serverXdgOutput->setDescription("testDescription");
|
||||
|
||||
m_serverXdgOutput->done();
|
||||
|
||||
// setup connection
|
||||
|
@ -144,10 +147,15 @@ void TestXdgOutput::testChanges()
|
|||
xdgOutputChanged.clear();
|
||||
QCOMPARE(xdgOutput->logicalPosition(), QPoint(11,12));
|
||||
QCOMPARE(xdgOutput->logicalSize(), QSize(1280,720));
|
||||
QCOMPARE(xdgOutput->name(), "testName");
|
||||
QCOMPARE(xdgOutput->description(), "testDescription");
|
||||
|
||||
//dynamic updates
|
||||
|
||||
// dynamic updates
|
||||
m_serverXdgOutput->setLogicalPosition(QPoint(1000, 2000));
|
||||
m_serverXdgOutput->setLogicalSize(QSize(100,200));
|
||||
// names cannot dynamically change according to the spec
|
||||
|
||||
m_serverXdgOutput->done();
|
||||
|
||||
QVERIFY(xdgOutputChanged.wait());
|
||||
|
|
|
@ -40,7 +40,7 @@ private:
|
|||
static const quint32 s_version;
|
||||
};
|
||||
|
||||
const quint32 XdgOutputManagerInterface::Private::s_version = 1;
|
||||
const quint32 XdgOutputManagerInterface::Private::s_version = 2;
|
||||
|
||||
#ifndef K_DOXYGEN
|
||||
const struct zxdg_output_manager_v1_interface XdgOutputManagerInterface::Private::s_interface = {
|
||||
|
@ -56,6 +56,8 @@ public:
|
|||
~XdgOutputV1Interface();
|
||||
void setLogicalSize(const QSize &size);
|
||||
void setLogicalPosition(const QPoint &pos);
|
||||
void setName(const QString &name);
|
||||
void setDescription(const QString &description);
|
||||
void done();
|
||||
private:
|
||||
class Private;
|
||||
|
@ -68,6 +70,8 @@ public:
|
|||
void resourceDisconnected(XdgOutputV1Interface *resource);
|
||||
QPoint pos;
|
||||
QSize size;
|
||||
QString name;
|
||||
QString description;
|
||||
bool dirty = false;
|
||||
bool doneOnce = false;
|
||||
QList<XdgOutputV1Interface*> resources;
|
||||
|
@ -204,6 +208,16 @@ QPoint XdgOutputInterface::logicalPosition() const
|
|||
return d->pos;
|
||||
}
|
||||
|
||||
void XdgOutputInterface::setName(const QString &name)
|
||||
{
|
||||
d->name = name;
|
||||
}
|
||||
|
||||
void XdgOutputInterface::setDescription(const QString &description)
|
||||
{
|
||||
d->description = description;
|
||||
}
|
||||
|
||||
void XdgOutputInterface::done()
|
||||
{
|
||||
d->doneOnce = true;
|
||||
|
@ -220,6 +234,8 @@ void XdgOutputInterface::Private::resourceConnected(XdgOutputV1Interface *resour
|
|||
{
|
||||
resource->setLogicalPosition(pos);
|
||||
resource->setLogicalSize(size);
|
||||
resource->setName(name);
|
||||
resource->setDescription(description);
|
||||
if (doneOnce) {
|
||||
resource->done();
|
||||
}
|
||||
|
@ -270,6 +286,28 @@ void XdgOutputV1Interface::setLogicalPosition(const QPoint &pos)
|
|||
zxdg_output_v1_send_logical_position(d->resource, pos.x(), pos.y());
|
||||
}
|
||||
|
||||
void XdgOutputV1Interface::setName(const QString &name)
|
||||
{
|
||||
if (!d->resource) {
|
||||
return;
|
||||
}
|
||||
if (wl_resource_get_version(d->resource) < ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) {
|
||||
return;
|
||||
}
|
||||
zxdg_output_v1_send_name(d->resource, name.toUtf8().constData());
|
||||
}
|
||||
|
||||
void XdgOutputV1Interface::setDescription(const QString &description)
|
||||
{
|
||||
if (!d->resource) {
|
||||
return;
|
||||
}
|
||||
if (wl_resource_get_version(d->resource) < ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION) {
|
||||
return;
|
||||
}
|
||||
zxdg_output_v1_send_description(d->resource, description.toUtf8().constData());
|
||||
}
|
||||
|
||||
void XdgOutputV1Interface::done()
|
||||
{
|
||||
if (!d->resource) {
|
||||
|
|
|
@ -87,6 +87,32 @@ public:
|
|||
*/
|
||||
QPoint logicalPosition() const;
|
||||
|
||||
/**
|
||||
* @brief Sets a short name of the output
|
||||
* This should be consistent across reboots for the same monitor
|
||||
* It should be set once before the first done call
|
||||
* @since 5.XDGOUTPUT
|
||||
*/
|
||||
void setName(const QString &name);
|
||||
/**
|
||||
* The last set name
|
||||
* @since 5.XDGOUTPUT
|
||||
*/
|
||||
void name() const;
|
||||
|
||||
/**
|
||||
* @brief Sets a longer description of the output
|
||||
* This should be consistent across reboots for the same monitor
|
||||
* It should be set once before the first done call
|
||||
* @since 5.XDGOUTPUT
|
||||
*/
|
||||
void setDescription(const QString &description);
|
||||
/**
|
||||
* The last set description
|
||||
* @since 5.XDGOUTPUT
|
||||
*/
|
||||
void description() const;
|
||||
|
||||
/**
|
||||
* Submit changes to all clients
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue