summaryrefslogtreecommitdiffstats
path: root/src/compositor/extensions
diff options
context:
space:
mode:
authorPier Luigi Fiorini <pierluigi.fiorini@liri.io>2019-01-06 18:09:00 +0100
committerPier Luigi Fiorini <pierluigi.fiorini@liri.io>2019-08-16 10:13:34 +0200
commit3be538b89c82d580133aadcf1615311a49786761 (patch)
tree518d8f5c6db6cc46140c2222fcc3ec003b9e71a5 /src/compositor/extensions
parente0115d9ccdbb541033b9ebc43c11fb4943becaff (diff)
Compositor: Add idle-inhibit unstable v1 protocol
Allows disabling of screen blanking on a per-surface basis. [ChangeLog][Compositor] Added support for idle-inhibit unstable v1 Wayland extension. Change-Id: I3cd392f9e1bb3604691f2a496579aad3b87383b6 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'src/compositor/extensions')
-rw-r--r--src/compositor/extensions/extensions.pri4
-rw-r--r--src/compositor/extensions/qwaylandidleinhibitv1.cpp185
-rw-r--r--src/compositor/extensions/qwaylandidleinhibitv1.h61
-rw-r--r--src/compositor/extensions/qwaylandidleinhibitv1_p.h88
4 files changed, 338 insertions, 0 deletions
diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri
index 027ea114b..c1a9f7882 100644
--- a/src/compositor/extensions/extensions.pri
+++ b/src/compositor/extensions/extensions.pri
@@ -15,6 +15,7 @@ WAYLANDSERVERSOURCES += \
../3rdparty/protocol/xdg-shell.xml \
../3rdparty/protocol/xdg-decoration-unstable-v1.xml \
../3rdparty/protocol/ivi-application.xml \
+ ../3rdparty/protocol/idle-inhibit-unstable-v1.xml \
HEADERS += \
extensions/qwlqttouch_p.h \
@@ -42,6 +43,8 @@ HEADERS += \
extensions/qwaylandxdgdecorationv1.h \
extensions/qwaylandxdgdecorationv1_p.h \
extensions/qwaylandshellsurface.h \
+ extensions/qwaylandidleinhibitv1.h \
+ extensions/qwaylandidleinhibitv1_p.h \
extensions/qwaylandiviapplication.h \
extensions/qwaylandiviapplication_p.h \
extensions/qwaylandivisurface.h \
@@ -62,6 +65,7 @@ SOURCES += \
extensions/qwaylandxdgshell.cpp \
extensions/qwaylandxdgdecorationv1.cpp \
extensions/qwaylandshellsurface.cpp \
+ extensions/qwaylandidleinhibitv1.cpp \
extensions/qwaylandiviapplication.cpp \
extensions/qwaylandivisurface.cpp \
diff --git a/src/compositor/extensions/qwaylandidleinhibitv1.cpp b/src/compositor/extensions/qwaylandidleinhibitv1.cpp
new file mode 100644
index 000000000..9e586a779
--- /dev/null
+++ b/src/compositor/extensions/qwaylandidleinhibitv1.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
+
+#include "qwaylandidleinhibitv1_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QWaylandIdleInhibitManagerV1
+ \inmodule QtWaylandCompositor
+ \since 5.14
+ \brief Provides an extension that allows to inhibit the idle behavior of the compositor
+ \sa QWaylandSurface::inhibitsIdle
+
+ The QWaylandIdleInhibitV1 extension provides a way for a client to inhibit the idle behavior of
+ the compositor when a specific surface is visually relevant to the user.
+
+ QWaylandIdleInhibitManagerV1 corresponds to the Wayland interface, \c zwp_idle_inhibit_manager_v1.
+
+ Inhibited surfaces have the QWaylandSurface::inhibitsIdle property set to \c true.
+*/
+
+/*!
+ \qmltype IdleInhibitManagerV1
+ \inqmlmodule QtWayland.Compositor
+ \since 5.14
+ \brief Provides an extension that allows to inhibit the idle behavior of the compositor
+ \sa WaylandSurface::inhibitsIdle
+
+ The IdleInhibitManagerV1 extension provides a way for a client to inhibit the idle behavior of
+ the compositor when a specific surface is visually relevant to the user.
+
+ IdleInhibitManagerV1 corresponds to the Wayland interface, \c zwp_idle_inhibit_manager_v1.
+
+ To provide the functionality of the extension in a compositor, create an instance of the
+ IdleInhibitManagerV1 component and add it to the list of extensions supported by the compositor:
+
+ \qml \QtMinorVersion
+ import QtWayland.Compositor 1.\1
+
+ WaylandCompositor {
+ IdleInhibitManagerV1 {
+ // ...
+ }
+ }
+ \endqml
+
+ Inhibited surfaces have the WaylandSurface::inhibitsIdle property set to \c true.
+*/
+
+/*!
+ Constructs a QWaylandIdleInhibitManagerV1 object.
+*/
+QWaylandIdleInhibitManagerV1::QWaylandIdleInhibitManagerV1()
+ : QWaylandCompositorExtensionTemplate<QWaylandIdleInhibitManagerV1>(*new QWaylandIdleInhibitManagerV1Private())
+{
+}
+
+/*!
+ Constructs a QWaylandIdleInhibitManagerV1 object for the provided \a compositor.
+*/
+QWaylandIdleInhibitManagerV1::QWaylandIdleInhibitManagerV1(QWaylandCompositor *compositor)
+ : QWaylandCompositorExtensionTemplate<QWaylandIdleInhibitManagerV1>(compositor, *new QWaylandIdleInhibitManagerV1Private())
+{
+}
+
+/*!
+ Initializes the extension.
+*/
+void QWaylandIdleInhibitManagerV1::initialize()
+{
+ Q_D(QWaylandIdleInhibitManagerV1);
+
+ QWaylandCompositorExtensionTemplate::initialize();
+ QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
+ if (!compositor) {
+ qCWarning(qLcWaylandCompositor) << "Failed to find QWaylandCompositor when initializing QWaylandIdleInhibitManagerV1";
+ return;
+ }
+ d->init(compositor->display(), d->interfaceVersion());
+}
+
+/*!
+ Returns the Wayland interface for the QWaylandIdleInhibitManagerV1.
+*/
+const wl_interface *QWaylandIdleInhibitManagerV1::interface()
+{
+ return QWaylandIdleInhibitManagerV1Private::interface();
+}
+
+
+void QWaylandIdleInhibitManagerV1Private::zwp_idle_inhibit_manager_v1_create_inhibitor(Resource *resource, uint id, wl_resource *surfaceResource)
+{
+ auto *surface = QWaylandSurface::fromResource(surfaceResource);
+ if (!surface) {
+ qCWarning(qLcWaylandCompositor) << "Couldn't find surface requested for creating an inhibitor";
+ wl_resource_post_error(resource->handle, WL_DISPLAY_ERROR_INVALID_OBJECT,
+ "invalid wl_surface@%d", wl_resource_get_id(surfaceResource));
+ return;
+ }
+
+ auto *surfacePrivate = QWaylandSurfacePrivate::get(surface);
+ if (!surfacePrivate) {
+ wl_resource_post_no_memory(resource->handle);
+ return;
+ }
+
+ auto *inhibitor = new Inhibitor(surface, resource->client(), id, resource->version());
+ if (!inhibitor) {
+ wl_resource_post_no_memory(resource->handle);
+ return;
+ }
+ surfacePrivate->idleInhibitors.append(inhibitor);
+
+ if (surfacePrivate->idleInhibitors.size() == 1)
+ Q_EMIT surface->inhibitsIdleChanged();
+}
+
+
+QWaylandIdleInhibitManagerV1Private::Inhibitor::Inhibitor(QWaylandSurface *surface,
+ wl_client *client,
+ quint32 id, quint32 version)
+ : QtWaylandServer::zwp_idle_inhibitor_v1(client, id, qMin<quint32>(version, interfaceVersion()))
+ , m_surface(surface)
+{
+ Q_ASSERT(surface);
+}
+
+void QWaylandIdleInhibitManagerV1Private::Inhibitor::zwp_idle_inhibitor_v1_destroy_resource(Resource *resource)
+{
+ Q_UNUSED(resource);
+ delete this;
+}
+
+void QWaylandIdleInhibitManagerV1Private::Inhibitor::zwp_idle_inhibitor_v1_destroy(Resource *resource)
+{
+ if (m_surface) {
+ auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface.data());
+ Q_ASSERT(surfacePrivate->idleInhibitors.contains(this));
+ surfacePrivate->idleInhibitors.removeOne(this);
+
+ if (surfacePrivate->idleInhibitors.isEmpty())
+ Q_EMIT m_surface.data()->inhibitsIdleChanged();
+ }
+
+ wl_resource_destroy(resource->handle);
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwaylandidleinhibitv1.h b/src/compositor/extensions/qwaylandidleinhibitv1.h
new file mode 100644
index 000000000..49e38fcfd
--- /dev/null
+++ b/src/compositor/extensions/qwaylandidleinhibitv1.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDIDLEINHIBITV1_H
+#define QWAYLANDIDLEINHIBITV1_H
+
+#include <QtWaylandCompositor/QWaylandCompositorExtension>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandIdleInhibitManagerV1Private;
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIdleInhibitManagerV1 : public QWaylandCompositorExtensionTemplate<QWaylandIdleInhibitManagerV1>
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandIdleInhibitManagerV1)
+public:
+ explicit QWaylandIdleInhibitManagerV1();
+ QWaylandIdleInhibitManagerV1(QWaylandCompositor *compositor);
+
+ void initialize() override;
+
+ static const struct wl_interface *interface();
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDIDLEINHIBITV1_H
diff --git a/src/compositor/extensions/qwaylandidleinhibitv1_p.h b/src/compositor/extensions/qwaylandidleinhibitv1_p.h
new file mode 100644
index 000000000..380551804
--- /dev/null
+++ b/src/compositor/extensions/qwaylandidleinhibitv1_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDIDLEINHIBITV1_P_H
+#define QWAYLANDIDLEINHIBITV1_P_H
+
+#include <QtWaylandCompositor/QWaylandSurface>
+#include <QtWaylandCompositor/QWaylandIdleInhibitManagerV1>
+#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h>
+#include <QtWaylandCompositor/private/qwayland-server-idle-inhibit-unstable-v1.h>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIdleInhibitManagerV1Private
+ : public QWaylandCompositorExtensionPrivate
+ , public QtWaylandServer::zwp_idle_inhibit_manager_v1
+{
+ Q_DECLARE_PUBLIC(QWaylandIdleInhibitManagerV1)
+public:
+ explicit QWaylandIdleInhibitManagerV1Private() = default;
+
+ class Q_WAYLAND_COMPOSITOR_EXPORT Inhibitor
+ : public QtWaylandServer::zwp_idle_inhibitor_v1
+ {
+ public:
+ explicit Inhibitor(QWaylandSurface *surface, wl_client *client, quint32 id, quint32 version);
+
+ protected:
+ void zwp_idle_inhibitor_v1_destroy_resource(Resource *resource) override;
+ void zwp_idle_inhibitor_v1_destroy(Resource *resource) override;
+
+ private:
+ QPointer<QWaylandSurface> m_surface;
+ };
+
+ static QWaylandIdleInhibitManagerV1Private *get(QWaylandIdleInhibitManagerV1 *manager) { return manager ? manager->d_func() : nullptr; }
+
+protected:
+ void zwp_idle_inhibit_manager_v1_create_inhibitor(Resource *resource, uint32_t id, wl_resource *surfaceResource) override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDIDLEINHIBITV1_P_H