summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPier Luigi Fiorini <pierluigi.fiorini@gmail.com>2016-06-05 11:55:55 +0200
committerPier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>2016-06-23 16:06:51 +0000
commitdb229d2502ae92bb9b483d83d212b2eaa29da622 (patch)
tree607773e3b75c4344d2987a85d75c671a9af74384
parent5c9be7fc18e4b3c7cfa2e5b562dc25ed0006035c (diff)
Emit a signal when QWaylandXdgSurface changes window type
This allows compositors to track when a window changes type and act accordingly (for example do a different show animation). Compositors might also want to keep track of the window type in order to filter out windows when presenting them to the user, think of a spread windows effect that only shows top level windows. Change-Id: I13c0ed3db2bdc6318ff1f4345d065e188b7c2435 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r--src/compositor/extensions/qwaylandxdgshell.cpp45
-rw-r--r--src/compositor/extensions/qwaylandxdgshell.h2
-rw-r--r--src/compositor/extensions/qwaylandxdgshell_p.h8
3 files changed, 50 insertions, 5 deletions
diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp
index 8b07283e7..137f3ec31 100644
--- a/src/compositor/extensions/qwaylandxdgshell.cpp
+++ b/src/compositor/extensions/qwaylandxdgshell.cpp
@@ -221,6 +221,7 @@ QWaylandXdgSurfacePrivate::QWaylandXdgSurfacePrivate()
, xdg_surface()
, m_surface(nullptr)
, m_parentSurface(nullptr)
+ , m_windowType(UnknownWindowType)
, m_unsetWindowGeometry(true)
, m_lastAckedConfigure({{}, QSize(0, 0), 0})
{
@@ -346,12 +347,22 @@ void QWaylandXdgSurfacePrivate::xdg_surface_set_parent(Resource *resource, wl_re
QWaylandXdgSurfacePrivate::Resource::fromResource(parent)->xdg_surface_object)->q_func();
}
- if (m_parentSurface == parentSurface)
- return;
-
Q_Q(QWaylandXdgSurface);
- m_parentSurface = parentSurface;
- emit q->parentSurfaceChanged();
+
+ if (m_parentSurface != parentSurface) {
+ m_parentSurface = parentSurface;
+ emit q->parentSurfaceChanged();
+ }
+
+ if (m_parentSurface && m_windowType != TransientWindowType) {
+ // There's a parent now, which means the surface is transient
+ m_windowType = TransientWindowType;
+ emit q->setTransient();
+ } else if (!m_parentSurface && m_windowType != TopLevelWindowType) {
+ // When the surface has no parent it is toplevel
+ m_windowType = TopLevelWindowType;
+ emit q->setTopLevel();
+ }
}
void QWaylandXdgSurfacePrivate::xdg_surface_set_app_id(Resource *resource, const QString &app_id)
@@ -611,6 +622,20 @@ void QWaylandXdgShell::handleFocusChanged(QWaylandSurface *newSurface, QWaylandS
*/
/*!
+ * \qmlsignal QtWaylandCompositor::XdgSurface::setTopLevel()
+ *
+ * This signal is emitted when the parent surface is unset, effectively
+ * making the window top level.
+ */
+
+/*!
+ * \qmlsignal QtWaylandCompositor::XdgSurface::setTransient()
+ *
+ * This signal is emitted when the parent surface is set, effectively
+ * making the window transient.
+ */
+
+/*!
* Constructs a QWaylandXdgSurface.
*/
QWaylandXdgSurface::QWaylandXdgSurface()
@@ -704,12 +729,22 @@ QWaylandSurface *QWaylandXdgSurface::surface() const
* \qmlproperty object QtWaylandCompositor::XdgSurface::parentSurface
*
* This property holds the XdgSurface parent of this XdgSurface.
+ * When a parent surface is set, the parentSurfaceChanged() signal
+ * is guaranteed to be emitted before setTopLevel() and setTransient().
+ *
+ * \sa QtWaylandCompositor::XdgSurface::setTopLevel()
+ * \sa QtWaylandCompositor::XdgSurface::setTransient()
*/
/*!
* \property QWaylandXdgSurface::surface
*
* This property holds the XdgSurface parent of this XdgSurface.
+ * When a parent surface is set, the parentSurfaceChanged() signal
+ * is guaranteed to be emitted before setTopLevel() and setTransient().
+ *
+ * \sa QWaylandXdgSurface::setTopLevel()
+ * \sa QWaylandXdgSurface::setTransient()
*/
QWaylandXdgSurface *QWaylandXdgSurface::parentSurface() const
{
diff --git a/src/compositor/extensions/qwaylandxdgshell.h b/src/compositor/extensions/qwaylandxdgshell.h
index 2da7f3d3d..a12d16480 100644
--- a/src/compositor/extensions/qwaylandxdgshell.h
+++ b/src/compositor/extensions/qwaylandxdgshell.h
@@ -177,6 +177,8 @@ Q_SIGNALS:
void showWindowMenu(QWaylandInputDevice *inputDevice, const QPoint &localSurfacePosition);
void startMove(QWaylandInputDevice *inputDevice);
void startResize(QWaylandInputDevice *inputDevice, ResizeEdge edges);
+ void setTopLevel();
+ void setTransient();
void setMaximized();
void unsetMaximized();
void setFullscreen(QWaylandOutput *output);
diff --git a/src/compositor/extensions/qwaylandxdgshell_p.h b/src/compositor/extensions/qwaylandxdgshell_p.h
index 23c95bdeb..0b2d22e6f 100644
--- a/src/compositor/extensions/qwaylandxdgshell_p.h
+++ b/src/compositor/extensions/qwaylandxdgshell_p.h
@@ -99,6 +99,12 @@ public:
QWaylandXdgSurfacePrivate();
static QWaylandXdgSurfacePrivate *get(QWaylandXdgSurface *xdgSurface) { return xdgSurface->d_func(); }
+ enum WindowType {
+ UnknownWindowType,
+ TopLevelWindowType,
+ TransientWindowType
+ };
+
struct ConfigureEvent {
QVector<uint> states;
QSize size;
@@ -115,6 +121,8 @@ private:
QWaylandSurface *m_surface;
QWaylandXdgSurface *m_parentSurface;
+ WindowType m_windowType;
+
QString m_title;
QString m_appId;
QRect m_windowGeometry;