Commit 0665cacd authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

xdg-shell: Reset xdg_toplevel and xdg_popup on unmap

parent 5d1713b1
......@@ -16,8 +16,6 @@
namespace KWaylandServer
{
// TODO: Reset the surface when it becomes unmapped.
XdgShellInterfacePrivate::XdgShellInterfacePrivate(XdgShellInterface *shell)
: q(shell)
{
......@@ -151,6 +149,14 @@ void XdgSurfaceInterfacePrivate::commit()
current.windowGeometry = next.windowGeometry;
emit q->windowGeometryChanged(current.windowGeometry);
}
isMapped = surface->buffer();
}
void XdgSurfaceInterfacePrivate::reset()
{
isConfigured = false;
current = next = State();
emit q->resetOccurred();
}
XdgSurfaceInterfacePrivate *XdgSurfaceInterfacePrivate::get(XdgSurfaceInterface *surface)
......@@ -307,6 +313,8 @@ void XdgToplevelInterfacePrivate::commit()
{
auto xdgSurfacePrivate = XdgSurfaceInterfacePrivate::get(xdgSurface);
bool isResettable = xdgSurfacePrivate->isConfigured && xdgSurfacePrivate->isMapped;
if (xdgSurfacePrivate->isConfigured) {
xdgSurfacePrivate->commit();
} else {
......@@ -314,6 +322,11 @@ void XdgToplevelInterfacePrivate::commit()
return;
}
if (isResettable && !xdgSurfacePrivate->isMapped) {
reset();
return;
}
if (current.minimumSize != next.minimumSize) {
current.minimumSize = next.minimumSize;
emit q->minimumSizeChanged(current.minimumSize);
......@@ -324,6 +337,18 @@ void XdgToplevelInterfacePrivate::commit()
}
}
void XdgToplevelInterfacePrivate::reset()
{
auto xdgSurfacePrivate = XdgSurfaceInterfacePrivate::get(xdgSurface);
xdgSurfacePrivate->reset();
windowTitle = QString();
windowClass = QString();
current = next = State();
emit q->resetOccurred();
}
void XdgToplevelInterfacePrivate::xdg_toplevel_destroy_resource(Resource *resource)
{
Q_UNUSED(resource)
......@@ -600,11 +625,24 @@ void XdgPopupInterfacePrivate::commit()
{
auto xdgSurfacePrivate = XdgSurfaceInterfacePrivate::get(xdgSurface);
bool isResettable = xdgSurfacePrivate->isConfigured && xdgSurfacePrivate->isMapped;
if (xdgSurfacePrivate->isConfigured) {
xdgSurfacePrivate->commit();
} else {
emit q->initializeRequested();
return;
}
if (isResettable && !xdgSurfacePrivate->isMapped) {
reset();
}
}
void XdgPopupInterfacePrivate::reset()
{
auto xdgSurfacePrivate = XdgSurfaceInterfacePrivate::get(xdgSurface);
xdgSurfacePrivate->reset();
}
void XdgPopupInterfacePrivate::xdg_popup_destroy_resource(Resource *resource)
......
......@@ -176,6 +176,11 @@ Q_SIGNALS:
*/
void windowGeometryChanged(const QRect &rect);
/**
* This signal is emitted when the surface has been unmapped and its state has been reset.
*/
void resetOccurred();
private:
QScopedPointer<XdgSurfaceInterfacePrivate> d;
friend class XdgSurfaceInterfacePrivate;
......@@ -283,6 +288,11 @@ Q_SIGNALS:
*/
void initializeRequested();
/**
* This signal is emitted when the toplevel has been unmapped and its state has been reset.
*/
void resetOccurred();
/**
* This signal is emitted when the toplevel's title has been changed.
*/
......
......@@ -82,12 +82,14 @@ public:
XdgSurfaceInterfacePrivate(XdgSurfaceInterface *xdgSurface);
void commit();
void reset();
XdgSurfaceInterface *q;
XdgShellInterface *shell;
QPointer<XdgToplevelInterface> toplevel;
QPointer<XdgPopupInterface> popup;
QPointer<SurfaceInterface> surface;
bool isMapped = false;
bool isConfigured = false;
struct State
......@@ -115,6 +117,7 @@ public:
XdgToplevelInterfacePrivate(XdgToplevelInterface *toplevel, XdgSurfaceInterface *surface);
void commit() override;
void reset();
static XdgToplevelInterfacePrivate *get(XdgToplevelInterface *toplevel);
static XdgToplevelInterfacePrivate *get(::wl_resource *resource);
......@@ -160,6 +163,7 @@ public:
XdgPopupInterfacePrivate(XdgPopupInterface *popup, XdgSurfaceInterface *surface);
void commit() override;
void reset();
XdgPopupInterface *q;
XdgSurfaceInterface *parentXdgSurface;
......
Markdown is supported
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