Commit 49e0cf53 authored by David Edmundson's avatar David Edmundson
Browse files

Implement set_window_geometry

Summary:
Used by clients to say where their true window geometry is relative to
the buffer size. Important if a client has client side shadows which
shouldn't be included for positioning tasks.

Technically this should be double buffered, but for consistency with all
other XdgShell properties this will be a task left to ShellClient.

Test Plan: Unit test

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D20595
parent a5c4c32f
......@@ -37,6 +37,8 @@ private Q_SLOTS:
void testMultipleRoles1();
void testMultipleRoles2();
void testWindowGeometry();
};
void XdgShellTestStable::testMaxSize()
......@@ -217,6 +219,31 @@ void XdgShellTestStable::testMultipleRoles2()
xdg_surface_destroy(xdgSurface);
}
void XdgShellTestStable::testWindowGeometry()
{
SURFACE
QSignalSpy windowGeometryChangedSpy(serverXdgSurface, &XdgShellSurfaceInterface::windowGeometryChanged);
xdgSurface->setWindowGeometry(QRect(50, 50, 400, 400));
windowGeometryChangedSpy.wait();
QCOMPARE(serverXdgSurface->windowGeometry(), QRect(50, 50, 400, 400));
//add a popup to this surface
XdgPositioner positioner(QSize(10,10), QRect(100,100,50,50));
QSignalSpy xdgPopupCreatedSpy(m_xdgShellInterface, &XdgShellInterface::xdgPopupCreated);
QScopedPointer<Surface> popupSurface(m_compositor->createSurface());
QScopedPointer<XdgShellPopup> xdgPopupSurface(m_xdgShell->createPopup(popupSurface.data(), xdgSurface.data(), positioner));
QVERIFY(xdgPopupCreatedSpy.wait());
auto serverXdgPopup = xdgPopupCreatedSpy.first().first().value<XdgShellPopupInterface*>();
QVERIFY(serverXdgPopup);
QSignalSpy popupWindowGeometryChangedSpy(serverXdgPopup, &XdgShellPopupInterface::windowGeometryChanged);
xdgPopupSurface->setWindowGeometry(QRect(60, 60, 300, 300));
popupWindowGeometryChangedSpy.wait();
QCOMPARE(serverXdgPopup->windowGeometry(), QRect(60, 60, 300, 300));
}
QTEST_GUILESS_MAIN(XdgShellTestStable)
......
......@@ -515,13 +515,18 @@ void XdgSurfaceStableInterface::Private::ackConfigureCallback(wl_client *client,
void XdgSurfaceStableInterface::Private::setWindowGeometryCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
{
// TODO: implement - not done for v5 either
Q_UNUSED(client)
Q_UNUSED(resource)
Q_UNUSED(x)
Q_UNUSED(y)
Q_UNUSED(width)
Q_UNUSED(height)
auto s = cast<Private>(resource);
Q_ASSERT(client == *s->client);
const QRect windowRect(x, y, width, height);
if (s->m_topLevel) {
s->m_topLevel->d_func()->windowGeometry = windowRect;
emit s->m_topLevel->windowGeometryChanged(windowRect);
} else if (s->m_popup) {
s->m_popup->d_func()->windowGeometry = windowRect;
emit s->m_popup->windowGeometryChanged(windowRect);
}
}
XdgSurfaceStableInterface::Private::Private(XdgSurfaceStableInterface *q, XdgShellStableInterface *c, SurfaceInterface *surface, wl_resource *parentResource)
......
......@@ -154,6 +154,12 @@ void XdgShellSurfaceInterface::close()
d->close();
}
QRect XdgShellSurfaceInterface::windowGeometry() const
{
Q_D();
return d->windowGeometry;
}
XdgShellSurfaceInterface::Private *XdgShellSurfaceInterface::d_func() const
{
return reinterpret_cast<Private*>(d.data());
......@@ -252,6 +258,12 @@ PositionerConstraints XdgShellPopupInterface::constraintAdjustments() const
return d->constraintAdjustments;
}
QRect XdgShellPopupInterface::windowGeometry() const
{
Q_D();
return d->windowGeometry;
}
void XdgShellPopupInterface::popupDone()
{
Q_D();
......
......@@ -278,6 +278,15 @@ public:
**/
void close();
/**
* @brief windowGeometry
* The geometry of the window within the buffer
*
* If invalid, the geometry of the bufer should be used instead
* @since 5.59
*/
QRect windowGeometry() const;
Q_SIGNALS:
/**
* Emitted whenever the title changes.
......@@ -346,6 +355,13 @@ Q_SIGNALS:
*/
void minSizeChanged(const QSize &size);
/**
* @brief windowGeometryChanged
* @param windowGeometry the newly changed windowGeometry
* @since 5.59
*/
void windowGeometryChanged(const QRect &windowGeometry);
protected:
class Private;
explicit XdgShellSurfaceInterface(Private *p);
......@@ -444,6 +460,13 @@ public:
**/
void popupDone();
/**
* @brief windowGeometryChanged
* @param windowGeometry the newly changed geometry of the window contents within the buffer
* @since 5.59
*/
QRect windowGeometry()const;
Q_SIGNALS:
/**
* A configure event with @p serial got acknowledged.
......@@ -462,6 +485,13 @@ Q_SIGNALS:
*/
void grabRequested(KWayland::Server::SeatInterface *seat, quint32 serial);
/**
* @brief windowGeometryChanged
* @param windowGeometry the newly changed windowGeometry
* @since 5.59
*/
void windowGeometryChanged(const QRect &windowGeometry);
protected:
class Private;
explicit XdgShellPopupInterface(Private *p);
......
......@@ -60,6 +60,7 @@ public:
QVector<quint32> configureSerials;
QPointer<XdgShellSurfaceInterface> parent;
QRect windowGeometry;
XdgShellInterfaceVersion interfaceVersion;
protected:
......@@ -93,6 +94,7 @@ public:
Qt::Edges gravity;
PositionerConstraints constraintAdjustments;
QPoint anchorOffset;
QRect windowGeometry;
XdgShellInterfaceVersion interfaceVersion;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment