summaryrefslogtreecommitdiffstats
path: root/src/compositor/extensions/qwaylandwlshell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compositor/extensions/qwaylandwlshell.cpp')
-rw-r--r--src/compositor/extensions/qwaylandwlshell.cpp103
1 files changed, 94 insertions, 9 deletions
diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp
index c79ddac7c..a1313a6c2 100644
--- a/src/compositor/extensions/qwaylandwlshell.cpp
+++ b/src/compositor/extensions/qwaylandwlshell.cpp
@@ -38,7 +38,9 @@
#include "qwaylandwlshell.h"
#include "qwaylandwlshell_p.h"
+#ifdef QT_WAYLAND_COMPOSITOR_QUICK
#include "qwaylandwlshellintegration_p.h"
+#endif
#include <QtWaylandCompositor/QWaylandCompositor>
#include <QtWaylandCompositor/QWaylandView>
@@ -77,16 +79,23 @@ void QWaylandWlShellPrivate::shell_get_shell_surface(Resource *resource, uint32_
if (!surface->setRole(QWaylandWlShellSurface::role(), displayRes, WL_DISPLAY_ERROR_INVALID_OBJECT))
return;
- emit q->createShellSurface(surface, shellSurfaceResource);
+ emit q->wlShellSurfaceRequested(surface, shellSurfaceResource);
QWaylandWlShellSurface *shellSurface = QWaylandWlShellSurface::fromResource(shellSurfaceResource.resource());
if (!shellSurface) {
- // A QWaylandShellSurface was not created in response to the createShellSurface signal
- // we create one as fallback here instead.
+ // A QWaylandWlShellSurface was not created in response to the wlShellSurfaceRequested
+ // signal, so we create one as fallback here instead.
shellSurface = new QWaylandWlShellSurface(q, surface, shellSurfaceResource);
}
- emit q->shellSurfaceCreated(shellSurface);
+ m_shellSurfaces.append(shellSurface);
+ emit q->wlShellSurfaceCreated(shellSurface);
+}
+
+void QWaylandWlShellPrivate::unregisterShellSurface(QWaylandWlShellSurface *shellSurface)
+{
+ if (!m_shellSurfaces.removeOne(shellSurface))
+ qWarning("Unexpected state. Can't find registered shell surface.");
}
QWaylandWlShellSurfacePrivate::QWaylandWlShellSurfacePrivate()
@@ -95,6 +104,7 @@ QWaylandWlShellSurfacePrivate::QWaylandWlShellSurfacePrivate()
, m_shell(Q_NULLPTR)
, m_surface(Q_NULLPTR)
, m_focusPolicy(QWaylandWlShellSurface::DefaultFocus)
+ , m_windowType(Qt::WindowType::Window)
{
}
@@ -108,6 +118,16 @@ void QWaylandWlShellSurfacePrivate::ping(uint32_t serial)
send_ping(serial);
}
+void QWaylandWlShellSurfacePrivate::setWindowType(Qt::WindowType windowType)
+{
+ if (m_windowType == windowType)
+ return;
+ m_windowType = windowType;
+
+ Q_Q(QWaylandWlShellSurface);
+ emit q->windowTypeChanged();
+}
+
void QWaylandWlShellSurfacePrivate::shell_surface_destroy_resource(Resource *)
{
Q_Q(QWaylandWlShellSurface);
@@ -123,7 +143,7 @@ void QWaylandWlShellSurfacePrivate::shell_surface_move(Resource *resource,
Q_UNUSED(serial);
Q_Q(QWaylandWlShellSurface);
- QWaylandInputDevice *input_device = QWaylandInputDevice::fromSeatResource(input_device_super);
+ QWaylandSeat *input_device = QWaylandSeat::fromSeatResource(input_device_super);
emit q->startMove(input_device);
}
@@ -136,7 +156,7 @@ void QWaylandWlShellSurfacePrivate::shell_surface_resize(Resource *resource,
Q_UNUSED(serial);
Q_Q(QWaylandWlShellSurface);
- QWaylandInputDevice *input_device = QWaylandInputDevice::fromSeatResource(input_device_super);
+ QWaylandSeat *input_device = QWaylandSeat::fromSeatResource(input_device_super);
emit q->startResize(input_device, QWaylandWlShellSurface::ResizeEdge(edges));
}
@@ -145,6 +165,7 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_toplevel(Resource *resourc
Q_UNUSED(resource);
Q_Q(QWaylandWlShellSurface);
setFocusPolicy(QWaylandWlShellSurface::DefaultFocus);
+ setWindowType(Qt::WindowType::Window);
emit q->setDefaultToplevel();
}
@@ -162,6 +183,7 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_transient(Resource *resour
flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE ? QWaylandWlShellSurface::NoKeyboardFocus
: QWaylandWlShellSurface::DefaultFocus;
setFocusPolicy(focusPolicy);
+ setWindowType(Qt::WindowType::SubWindow);
emit q->setTransient(parent_surface, QPoint(x,y), focusPolicy);
}
@@ -178,6 +200,7 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_fullscreen(Resource *resou
QWaylandOutput *output = output_resource
? QWaylandOutput::fromResource(output_resource)
: Q_NULLPTR;
+ setWindowType(Qt::WindowType::Window);
emit q->setFullScreen(QWaylandWlShellSurface::FullScreenMethod(method), framerate, output);
}
@@ -188,8 +211,9 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_popup(Resource *resource,
Q_UNUSED(flags);
Q_Q(QWaylandWlShellSurface);
setFocusPolicy(QWaylandWlShellSurface::DefaultFocus);
- QWaylandInputDevice *input = QWaylandInputDevice::fromSeatResource(input_device);
+ QWaylandSeat *input = QWaylandSeat::fromSeatResource(input_device);
QWaylandSurface *parentSurface = QWaylandSurface::fromResource(parent);
+ setWindowType(Qt::WindowType::Popup);
emit q->setPopup(input, parentSurface, QPoint(x,y));
}
@@ -203,6 +227,7 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_maximized(Resource *resour
QWaylandOutput *output = output_resource
? QWaylandOutput::fromResource(output_resource)
: Q_NULLPTR;
+ setWindowType(Qt::WindowType::Window);
emit q->setMaximized(output);
}
@@ -308,6 +333,23 @@ void QWaylandWlShell::initialize()
d->init(compositor->display(), 1);
}
+QList<QWaylandWlShellSurface *> QWaylandWlShell::shellSurfaces() const
+{
+ Q_D(const QWaylandWlShell);
+ return d->m_shellSurfaces;
+}
+
+QList<QWaylandWlShellSurface *> QWaylandWlShell::shellSurfacesForClient(QWaylandClient *client) const
+{
+ Q_D(const QWaylandWlShell);
+ QList<QWaylandWlShellSurface *> surfsForClient;
+ Q_FOREACH (QWaylandWlShellSurface *shellSurface, d->m_shellSurfaces) {
+ if (shellSurface->surface()->client() == client)
+ surfsForClient.append(shellSurface);
+ }
+ return surfsForClient;
+}
+
/*!
* Returns the Wayland interface for the QWaylandWlShell.
*/
@@ -317,7 +359,7 @@ const struct wl_interface *QWaylandWlShell::interface()
}
/*!
- * \qmlsignal void QtWaylandCompositor::WlShell::createShellSurface(object surface, object client, int id)
+ * \qmlsignal void QtWaylandCompositor::WlShell::wlShellSurfaceRequested(object surface, object client, int id)
*
* This signal is emitted when the \a client has requested a \c wl_shell_surface to be associated
* with \a surface, which is identified by \a id. The handler for this signal is
@@ -326,7 +368,7 @@ const struct wl_interface *QWaylandWlShell::interface()
*/
/*!
- * \fn void QWaylandWlShell::createShellSurface(QWaylandSurface *surface, const QWaylandResource &resource)
+ * \fn void QWaylandWlShell::wlShellSurfaceRequested(QWaylandSurface *surface, const QWaylandResource &resource)
*
* Constructs a QWaylandSurface, assigns it to \a surface and initializes it with the given \a resource.
*/
@@ -382,6 +424,12 @@ QWaylandWlShellSurface::QWaylandWlShellSurface(QWaylandWlShell *shell, QWaylandS
initialize(shell, surface, res);
}
+QWaylandWlShellSurface::~QWaylandWlShellSurface()
+{
+ Q_D(QWaylandWlShellSurface);
+ QWaylandWlShellPrivate::get(d->m_shell)->unregisterShellSurface(this);
+}
+
/*!
* \qmlmethod void QtWaylandCompositor::WlShellSurface::initialize(object shell, object surface, object client, int id)
*
@@ -399,6 +447,7 @@ void QWaylandWlShellSurface::initialize(QWaylandWlShell *shell, QWaylandSurface
d->init(resource.resource());
setExtensionContainer(surface);
emit surfaceChanged();
+ emit shellChanged();
QWaylandCompositorExtension::initialize();
}
@@ -493,10 +542,12 @@ void QWaylandWlShellSurface::sendPopupDone()
d->send_popup_done();
}
+#ifdef QT_WAYLAND_COMPOSITOR_QUICK
QWaylandQuickShellIntegration *QWaylandWlShellSurface::createIntegration(QWaylandQuickShellSurfaceItem *item)
{
return new QtWayland::WlShellIntegration(item);
}
+#endif
/*!
* \qmlproperty object QtWaylandCompositor::WlShellSurface::surface
@@ -516,6 +567,23 @@ QWaylandSurface *QWaylandWlShellSurface::surface() const
}
/*!
+ * \qmlproperty object QtWaylandCompositor::WlShellSurface::shell
+ *
+ * This property holds the shell associated with this WlShellSurface.
+ */
+
+/*!
+ * \property QWaylandWlShellSurface::shell
+ *
+ * This property holds the shell associated with this QWaylandWlShellSurface.
+ */
+QWaylandWlShell *QWaylandWlShellSurface::shell() const
+{
+ Q_D(const QWaylandWlShellSurface);
+ return d->m_shell;
+}
+
+/*!
* \enum QWaylandWlShellSurface::FocusPolicy
*
* This enum type is used to specify the focus policy of a shell surface.
@@ -542,6 +610,23 @@ QWaylandWlShellSurface::FocusPolicy QWaylandWlShellSurface::focusPolicy() const
}
/*!
+ * \qmlproperty enum QtWaylandCompositor::WlShellSurface::windowType
+ *
+ * This property holds the window type of the WlShellSurface.
+ */
+
+/*!
+ * \property QWaylandWlShellSurface::windowType
+ *
+ * This property holds the window type of the QWaylandWlShellSurface.
+ */
+Qt::WindowType QWaylandWlShellSurface::windowType() const
+{
+ Q_D(const QWaylandWlShellSurface);
+ return d->m_windowType;
+}
+
+/*!
* \qmlproperty string QtWaylandCompositor::WlShellSurface::title
*
* This property holds the title of the WlShellSurface.