summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@theqtcompany.com>2016-02-26 13:10:36 +0100
committerJohan Helsing <johan.helsing@qt.io>2016-04-26 12:29:04 +0000
commitb04a737dc694064b4fd507f0f52a7b9537c09bc7 (patch)
tree335d18f572926e082affb7d9e682b7feb3502144
parent38cdbabc0fe92a105ac6f6accaa6e75a6d730e56 (diff)
QML API for xdg-shell
Exposes QWaylandXdgShell and QWaylandXdgSurface as QML types, along with a new QWaylandXdgSurfaceItem. All of this mirrors the implementation of wl_shell closely. The biggest difference is how resize is handled. There is now some duplication in the window chrome implementation of the pure-qml compositor. This may be improved by refactoring the existing API for shell extensions. Change-Id: I4f2ceff7e0462034cd295a27c3eefea457cc9b96 Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-rw-r--r--examples/wayland/pure-qml/pure-qml.pro1
-rw-r--r--examples/wayland/pure-qml/pure-qml.qrc1
-rw-r--r--examples/wayland/pure-qml/qml/XdgChrome.qml90
-rw-r--r--examples/wayland/pure-qml/qml/main.qml17
-rw-r--r--src/compositor/extensions/extensions.pri3
-rw-r--r--src/compositor/extensions/qwaylandquickxdgsurfaceitem.cpp285
-rw-r--r--src/compositor/extensions/qwaylandquickxdgsurfaceitem.h87
-rw-r--r--src/compositor/extensions/qwaylandquickxdgsurfaceitem_p.h99
-rw-r--r--src/compositor/extensions/qwaylandxdgshell.h2
-rw-r--r--src/imports/compositor/qwaylandquickcompositorplugin.cpp9
10 files changed, 593 insertions, 1 deletions
diff --git a/examples/wayland/pure-qml/pure-qml.pro b/examples/wayland/pure-qml/pure-qml.pro
index 20fc529ed..f0a10260a 100644
--- a/examples/wayland/pure-qml/pure-qml.pro
+++ b/examples/wayland/pure-qml/pure-qml.pro
@@ -8,6 +8,7 @@ OTHER_FILES = \
qml/Screen.qml \
qml/Chrome.qml \
qml/Keyboard.qml \
+ qml/XdgChrome.qml \
images/background.jpg \
RESOURCES += pure-qml.qrc
diff --git a/examples/wayland/pure-qml/pure-qml.qrc b/examples/wayland/pure-qml/pure-qml.qrc
index 8c95434d3..333f5e613 100644
--- a/examples/wayland/pure-qml/pure-qml.qrc
+++ b/examples/wayland/pure-qml/pure-qml.qrc
@@ -5,5 +5,6 @@
<file>qml/Screen.qml</file>
<file>qml/Chrome.qml</file>
<file>qml/Keyboard.qml</file>
+ <file>qml/XdgChrome.qml</file>
</qresource>
</RCC>
diff --git a/examples/wayland/pure-qml/qml/XdgChrome.qml b/examples/wayland/pure-qml/qml/XdgChrome.qml
new file mode 100644
index 000000000..afe137c68
--- /dev/null
+++ b/examples/wayland/pure-qml/qml/XdgChrome.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtWayland.Compositor 1.0
+
+XdgSurfaceItem {
+ id: rootChrome
+
+ xdgSurface: XdgSurface {
+ id: xdgSurface
+ onActivatedChanged: {
+ if (xdgSurface.activated) {
+ receivedFocusAnimation.start();
+ }
+ }
+ }
+
+ onSurfaceDestroyed: {
+ view.bufferLock = true;
+ destroyAnimation.start();
+ }
+
+ SequentialAnimation {
+ id: receivedFocusAnimation
+ ParallelAnimation {
+ NumberAnimation { target: scaleTransform; property: "yScale"; to: 1.02; duration: 100; easing.type: Easing.OutQuad }
+ NumberAnimation { target: scaleTransform; property: "xScale"; to: 1.02; duration: 100; easing.type: Easing.OutQuad }
+ }
+ ParallelAnimation {
+ NumberAnimation { target: scaleTransform; property: "yScale"; to: 1; duration: 100; easing.type: Easing.InOutQuad }
+ NumberAnimation { target: scaleTransform; property: "xScale"; to: 1; duration: 100; easing.type: Easing.InOutQuad }
+ }
+ }
+
+ SequentialAnimation {
+ id: destroyAnimation
+ ParallelAnimation {
+ NumberAnimation { target: scaleTransform; property: "yScale"; to: 2/height; duration: 150 }
+ NumberAnimation { target: scaleTransform; property: "xScale"; to: 0.4; duration: 150 }
+ }
+ NumberAnimation { target: scaleTransform; property: "xScale"; to: 0; duration: 150 }
+ ScriptAction { script: { rootChrome.destroy(); } }
+ }
+
+ transform: [
+ Scale {
+ id: scaleTransform
+ origin.x: rootChrome.width / 2
+ origin.y: rootChrome.height / 2
+ }
+ ]
+}
diff --git a/examples/wayland/pure-qml/qml/main.qml b/examples/wayland/pure-qml/qml/main.qml
index ac8dde712..65ac36166 100644
--- a/examples/wayland/pure-qml/qml/main.qml
+++ b/examples/wayland/pure-qml/qml/main.qml
@@ -57,6 +57,12 @@ WaylandCompositor {
}
Component {
+ id: xdgChromeComponent
+ XdgChrome {
+ }
+ }
+
+ Component {
id: surfaceComponent
WaylandSurface {
}
@@ -82,6 +88,17 @@ WaylandCompositor {
initialize();
}
},
+ XdgShell {
+ id: xdgShell
+
+ onXdgSurfaceCreated: {
+ xdgChromeComponent.createObject(defaultOutput.surfaceArea, { "xdgSurface": xdgSurface } );
+ }
+
+ Component.onCompleted: {
+ initialize();
+ }
+ },
TextInputManager {
Component.onCompleted: {
initialize();
diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri
index 1d34803f0..717162433 100644
--- a/src/compositor/extensions/extensions.pri
+++ b/src/compositor/extensions/extensions.pri
@@ -36,9 +36,12 @@ qtHaveModule(quick) {
HEADERS += \
extensions/qwaylandquickwlshellsurfaceitem.h \
extensions/qwaylandquickwlshellsurfaceitem_p.h \
+ extensions/qwaylandquickxdgsurfaceitem.h \
+ extensions/qwaylandquickxdgsurfaceitem_p.h \
SOURCES += \
extensions/qwaylandquickwlshellsurfaceitem.cpp \
+ extensions/qwaylandquickxdgsurfaceitem.cpp \
}
diff --git a/src/compositor/extensions/qwaylandquickxdgsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickxdgsurfaceitem.cpp
new file mode 100644
index 000000000..3344ef74d
--- /dev/null
+++ b/src/compositor/extensions/qwaylandquickxdgsurfaceitem.cpp
@@ -0,0 +1,285 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** 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 "qwaylandquickxdgsurfaceitem.h"
+#include "qwaylandquickxdgsurfaceitem_p.h"
+
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/QWaylandInputDevice>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ * \qmltype XdgSurfaceItem
+ * \inqmlmodule QtWayland.Compositor
+ * \brief An item representing a XdgSurface.
+ *
+ * This type can be used to render xdg surfaces as part of a Qt Quick scene.
+ * It handles moving and resizing triggered by clicking on the window decorations.
+ */
+
+/*!
+ * \class QWaylandQuickXdgSurfaceItem
+ * \inmodule QtWaylandCompositor
+ * \brief A Qt Quick item for QWaylandXdgSurface.
+ *
+ * This class can be used to create Qt Quick items representing xdg surfaces.
+ * It handles moving and resizing triggered by clicking on the window decorations.
+ *
+ * \sa QWaylandQuickItem
+ */
+
+/*!
+ * Constructs a QWaylandQuickXdgSurfaceItem with the given \a parent.
+ */
+QWaylandQuickXdgSurfaceItem::QWaylandQuickXdgSurfaceItem(QQuickItem *parent)
+ : QWaylandQuickItem(*new QWaylandQuickXdgSurfaceItemPrivate(), parent)
+{
+}
+
+/*!
+ * \internal
+ */
+QWaylandQuickXdgSurfaceItem::QWaylandQuickXdgSurfaceItem(QWaylandQuickXdgSurfaceItemPrivate &dd, QQuickItem *parent)
+ : QWaylandQuickItem(dd, parent)
+{
+}
+
+/*!
+ * \qmlproperty object QtWaylandCompositor::XdgSurfaceItem::xdgSurface
+ *
+ * This property holds the xdg surface rendered by this XdgSurfaceItem.
+ */
+
+/*!
+ * \property QWaylandQuickXdgSurfaceItem::xdgSurface
+ *
+ * This property holds the xdg surface rendered by this QWaylandQuickXdgSurfaceItem.
+ */
+QWaylandXdgSurface *QWaylandQuickXdgSurfaceItem::xdgSurface() const
+{
+ Q_D(const QWaylandQuickXdgSurfaceItem);
+ return d->xdgSurface;
+}
+
+void QWaylandQuickXdgSurfaceItem::setXdgSurface(QWaylandXdgSurface *xdgSurface)
+{
+ Q_D(QWaylandQuickXdgSurfaceItem);
+ if (xdgSurface == d->xdgSurface)
+ return;
+
+ if (d->xdgSurface) {
+ disconnect(d->xdgSurface, &QWaylandXdgSurface::startMove, this, &QWaylandQuickXdgSurfaceItem::handleStartMove);
+ disconnect(d->xdgSurface, &QWaylandXdgSurface::startResize, this, &QWaylandQuickXdgSurfaceItem::handleStartResize);
+ disconnect(d->xdgSurface, &QWaylandXdgSurface::setMaximized, this, &QWaylandQuickXdgSurfaceItem::handleSetMaximized);
+ disconnect(d->xdgSurface, &QWaylandXdgSurface::unsetMaximized, this, &QWaylandQuickXdgSurfaceItem::handleUnsetMaximized);
+ disconnect(d->xdgSurface, &QWaylandXdgSurface::maximizedChanged, this, &QWaylandQuickXdgSurfaceItem::handleMaximizedChanged);
+ disconnect(d->xdgSurface, &QWaylandXdgSurface::activatedChanged, this, &QWaylandQuickXdgSurfaceItem::handleActivatedChanged);
+ }
+ d->xdgSurface = xdgSurface;
+ if (d->xdgSurface) {
+ connect(d->xdgSurface, &QWaylandXdgSurface::startMove, this, &QWaylandQuickXdgSurfaceItem::handleStartMove);
+ connect(d->xdgSurface, &QWaylandXdgSurface::startResize, this, &QWaylandQuickXdgSurfaceItem::handleStartResize);
+ connect(d->xdgSurface, &QWaylandXdgSurface::setMaximized, this, &QWaylandQuickXdgSurfaceItem::handleSetMaximized);
+ connect(d->xdgSurface, &QWaylandXdgSurface::unsetMaximized, this, &QWaylandQuickXdgSurfaceItem::handleUnsetMaximized);
+ connect(d->xdgSurface, &QWaylandXdgSurface::maximizedChanged, this, &QWaylandQuickXdgSurfaceItem::handleMaximizedChanged);
+ connect(d->xdgSurface, &QWaylandXdgSurface::activatedChanged, this, &QWaylandQuickXdgSurfaceItem::handleActivatedChanged);
+ }
+ setSurface(xdgSurface ? xdgSurface->surface() : nullptr);
+ emit xdgSurfaceChanged();
+}
+
+/*!
+ * \internal
+ * \property QWaylandQuickXdgSurfaceItem::moveItem
+ *
+ * This property holds the move item for this QWaylandQuickXdgSurfaceItem.
+ */
+QQuickItem *QWaylandQuickXdgSurfaceItem::moveItem() const
+{
+ Q_D(const QWaylandQuickXdgSurfaceItem);
+ return d->moveItem;
+}
+
+void QWaylandQuickXdgSurfaceItem::setMoveItem(QQuickItem *moveItem)
+{
+ Q_D(QWaylandQuickXdgSurfaceItem);
+ if (d->moveItem == moveItem)
+ return;
+ d->moveItem = moveItem;
+ moveItemChanged();
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickXdgSurfaceItem::handleStartMove(QWaylandInputDevice *inputDevice)
+{
+ Q_D(QWaylandQuickXdgSurfaceItem);
+ d->grabberState = QWaylandQuickXdgSurfaceItemPrivate::MoveState;
+ d->moveState.inputDevice = inputDevice;
+ d->moveState.initialized = false;
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickXdgSurfaceItem::handleStartResize(QWaylandInputDevice *inputDevice, QWaylandXdgSurface::ResizeEdge edges)
+{
+ Q_D(QWaylandQuickXdgSurfaceItem);
+ d->grabberState = QWaylandQuickXdgSurfaceItemPrivate::ResizeState;
+ d->resizeState.inputDevice = inputDevice;
+ d->resizeState.resizeEdges = edges;
+ d->resizeState.initialWindowSize = xdgSurface()->windowGeometry().size();
+ d->resizeState.initialPosition = position();
+ d->resizeState.initialSurfaceSize = surface()->size();
+ d->resizeState.initialized = false;
+}
+
+void QWaylandQuickXdgSurfaceItem::handleSetMaximized()
+{
+ Q_D(QWaylandQuickXdgSurfaceItem);
+
+ d->maximizeState.initialWindowSize = xdgSurface()->windowGeometry().size();
+ d->maximizeState.initialPosition = position();
+
+ QWaylandOutput *output = compositor()->outputs().first();
+ xdgSurface()->requestMaximized(output->geometry().size());
+}
+
+void QWaylandQuickXdgSurfaceItem::handleUnsetMaximized()
+{
+ Q_D(QWaylandQuickXdgSurfaceItem);
+ xdgSurface()->requestUnMaximized(d->maximizeState.initialWindowSize);
+}
+
+void QWaylandQuickXdgSurfaceItem::handleMaximizedChanged()
+{
+ Q_D(QWaylandQuickXdgSurfaceItem);
+ if (xdgSurface()->maximized()) {
+ QWaylandOutput *output = compositor()->outputs().first();
+ setPosition(output->geometry().topLeft());
+ } else {
+ setPosition(d->maximizeState.initialPosition);
+ }
+}
+
+void QWaylandQuickXdgSurfaceItem::handleActivatedChanged()
+{
+ if (xdgSurface()->activated())
+ raise();
+}
+
+void QWaylandQuickXdgSurfaceItem::handleSurfaceSizeChanged()
+{
+ Q_D(QWaylandQuickXdgSurfaceItem);
+ if (d->grabberState == QWaylandQuickXdgSurfaceItemPrivate::ResizeState) {
+ float x = d->resizeState.initialPosition.x();
+ float y = d->resizeState.initialPosition.y();
+ if (d->resizeState.resizeEdges & QWaylandXdgSurface::ResizeEdge::TopEdge)
+ y += d->resizeState.initialSurfaceSize.height() - surface()->size().height();
+
+ if (d->resizeState.resizeEdges & QWaylandXdgSurface::ResizeEdge::LeftEdge)
+ x += d->resizeState.initialSurfaceSize.width() - surface()->size().width();
+ setPosition(QPoint(x,y));
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickXdgSurfaceItem::mouseMoveEvent(QMouseEvent *event)
+{
+ Q_D(QWaylandQuickXdgSurfaceItem);
+ if (d->grabberState == QWaylandQuickXdgSurfaceItemPrivate::ResizeState) {
+ Q_ASSERT(d->resizeState.inputDevice == compositor()->inputDeviceFor(event));
+ if (!d->resizeState.initialized) {
+ d->resizeState.initialMousePos = event->windowPos();
+ d->resizeState.initialized = true;
+ return;
+ }
+ QPointF delta = event->windowPos() - d->resizeState.initialMousePos;
+ QSize newSize = xdgSurface()->sizeForResize(d->resizeState.initialWindowSize, delta, d->resizeState.resizeEdges);
+ xdgSurface()->requestResizing(newSize);
+ } else if (d->grabberState == QWaylandQuickXdgSurfaceItemPrivate::MoveState) {
+ Q_ASSERT(d->moveState.inputDevice == compositor()->inputDeviceFor(event));
+ QQuickItem *moveItem = d->moveItem ? d->moveItem : this;
+ if (!d->moveState.initialized) {
+ d->moveState.initialOffset = moveItem->mapFromItem(Q_NULLPTR, event->windowPos());
+ d->moveState.initialized = true;
+ return;
+ }
+ if (!moveItem->parentItem())
+ return;
+ QPointF parentPos = moveItem->parentItem()->mapFromItem(Q_NULLPTR, event->windowPos());
+ moveItem->setPosition(parentPos - d->moveState.initialOffset);
+ } else {
+ QWaylandQuickItem::mouseMoveEvent(event);
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickXdgSurfaceItem::mouseReleaseEvent(QMouseEvent *event)
+{
+ Q_D(QWaylandQuickXdgSurfaceItem);
+ if (d->grabberState == QWaylandQuickXdgSurfaceItemPrivate::ResizeState) {
+ QPointF delta = event->windowPos() - d->resizeState.initialMousePos;
+ QSize newSize = xdgSurface()->sizeForResize(d->resizeState.initialWindowSize, delta, d->resizeState.resizeEdges);
+ xdgSurface()->requestUnMaximized(newSize);
+ d->grabberState = QWaylandQuickXdgSurfaceItemPrivate::DefaultState;
+ return;
+ } else if (d->grabberState == QWaylandQuickXdgSurfaceItemPrivate::MoveState) {
+ d->grabberState = QWaylandQuickXdgSurfaceItemPrivate::DefaultState;
+ return;
+ }
+ QWaylandQuickItem::mouseReleaseEvent(event);
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickXdgSurfaceItem::surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface)
+{
+ if (oldSurface)
+ disconnect(oldSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickXdgSurfaceItem::handleSurfaceSizeChanged);
+
+ if (newSurface)
+ connect(newSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickXdgSurfaceItem::handleSurfaceSizeChanged);
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwaylandquickxdgsurfaceitem.h b/src/compositor/extensions/qwaylandquickxdgsurfaceitem.h
new file mode 100644
index 000000000..d19d03c28
--- /dev/null
+++ b/src/compositor/extensions/qwaylandquickxdgsurfaceitem.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** 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 QWAYLANDQUICKXDGSURFACEITEM_H
+#define QWAYLANDQUICKXDGSURFACEITEM_H
+
+#include <QtWaylandCompositor/QWaylandQuickItem>
+#include <QtWaylandCompositor/QWaylandXdgSurface>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandQuickXdgSurfaceItemPrivate;
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickXdgSurfaceItem : public QWaylandQuickItem
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandQuickXdgSurfaceItem)
+ Q_PROPERTY(QWaylandXdgSurface *xdgSurface READ xdgSurface WRITE setXdgSurface NOTIFY xdgSurfaceChanged)
+ Q_PROPERTY(QQuickItem *moveItem READ moveItem WRITE setMoveItem NOTIFY moveItemChanged)
+
+public:
+ QWaylandQuickXdgSurfaceItem(QQuickItem *parent = nullptr);
+
+ QWaylandXdgSurface *xdgSurface() const;
+ void setXdgSurface(QWaylandXdgSurface *xdgSurface);
+
+ QQuickItem *moveItem() const;
+ void setMoveItem(QQuickItem *moveItem);
+
+Q_SIGNALS:
+ void xdgSurfaceChanged();
+ void moveItemChanged();
+
+private Q_SLOTS:
+ void handleStartMove(QWaylandInputDevice *inputDevice);
+ void handleStartResize(QWaylandInputDevice *inputDevice, QWaylandXdgSurface::ResizeEdge edges);
+ void handleSetMaximized();
+ void handleUnsetMaximized();
+ void handleMaximizedChanged();
+ void handleActivatedChanged();
+ void handleSurfaceSizeChanged();
+
+protected:
+ QWaylandQuickXdgSurfaceItem(QWaylandQuickXdgSurfaceItemPrivate &dd, QQuickItem *parent);
+
+ void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+
+ void surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface) Q_DECL_OVERRIDE;
+};
+
+QT_END_NAMESPACE
+
+#endif /*QWAYLANDQUICKXDGSURFACEITEM_H*/
diff --git a/src/compositor/extensions/qwaylandquickxdgsurfaceitem_p.h b/src/compositor/extensions/qwaylandquickxdgsurfaceitem_p.h
new file mode 100644
index 000000000..4ac2853d3
--- /dev/null
+++ b/src/compositor/extensions/qwaylandquickxdgsurfaceitem_p.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** 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 QWAYLANDQUICKXDGSURFACEITEM_P_H
+#define QWAYLANDQUICKXDGSURFACEITEM_P_H
+
+#include <QtWaylandCompositor/private/qwaylandquickitem_p.h>
+
+QT_BEGIN_NAMESPACE
+
+//
+// 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.
+//
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickXdgSurfaceItemPrivate : public QWaylandQuickItemPrivate
+{
+public:
+ enum GrabberState {
+ DefaultState,
+ ResizeState,
+ MoveState
+ };
+
+ QWaylandQuickXdgSurfaceItemPrivate()
+ : QWaylandQuickItemPrivate()
+ , xdgSurface(Q_NULLPTR)
+ , moveItem(Q_NULLPTR)
+ , grabberState(DefaultState)
+ {}
+
+ QWaylandXdgSurface *xdgSurface;
+ QQuickItem *moveItem;
+
+ GrabberState grabberState;
+ struct {
+ QWaylandInputDevice *inputDevice;
+ QPointF initialOffset;
+ bool initialized;
+ } moveState;
+
+ struct {
+ QWaylandInputDevice *inputDevice;
+ QWaylandXdgSurface::ResizeEdge resizeEdges;
+ QSizeF initialWindowSize;
+ QPointF initialMousePos;
+ QPointF initialPosition;
+ QSize initialSurfaceSize;
+ bool initialized;
+ } resizeState;
+
+ struct {
+ QSize initialWindowSize;
+ QPointF initialPosition;
+ } maximizeState;
+};
+
+QT_END_NAMESPACE
+
+#endif /*QWAYLANDQUICKXDGSURFACEITEM_P_H*/
diff --git a/src/compositor/extensions/qwaylandxdgshell.h b/src/compositor/extensions/qwaylandxdgshell.h
index 1a6145800..2b751aee9 100644
--- a/src/compositor/extensions/qwaylandxdgshell.h
+++ b/src/compositor/extensions/qwaylandxdgshell.h
@@ -38,6 +38,7 @@
#define QWAYLANDXDGSHELL_H
#include <QtWaylandCompositor/QWaylandExtension>
+#include <QtWaylandCompositor/QWaylandResource>
#include <QtCore/QRect>
@@ -53,7 +54,6 @@ class QWaylandXdgPopupPrivate;
class QWaylandSurface;
class QWaylandSurfaceRole;
-class QWaylandResource;
class QWaylandInputDevice;
class QWaylandOutput;
class QWaylandClient;
diff --git a/src/imports/compositor/qwaylandquickcompositorplugin.cpp b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
index 6b42a2e0a..d2d8189bf 100644
--- a/src/imports/compositor/qwaylandquickcompositorplugin.cpp
+++ b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
@@ -48,11 +48,13 @@
#include <QtWaylandCompositor/QWaylandQuickExtension>
#include <QtWaylandCompositor/QWaylandInputDevice>
#include <QtWaylandCompositor/QWaylandQuickWlShellSurfaceItem>
+#include <QtWaylandCompositor/QWaylandQuickXdgSurfaceItem>
#include <QtWaylandCompositor/QWaylandResource>
#include <QtWaylandCompositor/QWaylandWindowManagerExtension>
#include <QtWaylandCompositor/QWaylandWlShell>
#include <QtWaylandCompositor/QWaylandTextInputManager>
+#include <QtWaylandCompositor/QWaylandXdgShell>
#include <QtWaylandCompositor/qwaylandexport.h>
#include "qwaylandmousetracker_p.h"
@@ -63,6 +65,8 @@ Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandQuickCompositor)
Q_COMPOSITOR_DECLARE_QUICK_DATA_CLASS(QWaylandWindowManagerExtension)
Q_COMPOSITOR_DECLARE_QUICK_DATA_CLASS(QWaylandWlShell)
Q_COMPOSITOR_DECLARE_QUICK_DATA_CLASS(QWaylandWlShellSurface)
+Q_COMPOSITOR_DECLARE_QUICK_DATA_CLASS(QWaylandXdgShell)
+Q_COMPOSITOR_DECLARE_QUICK_DATA_CLASS(QWaylandXdgSurface)
Q_COMPOSITOR_DECLARE_QUICK_DATA_CLASS(QWaylandTextInputManager)
@@ -142,6 +146,7 @@ public:
qmlRegisterUncreatableType<QWaylandCompositor>(uri, 1, 0, "WaylandCompositorBase", QObject::tr("Cannot create instance of WaylandCompositorBase, use WaylandCompositor instead"));
qmlRegisterUncreatableType<QWaylandSurface>(uri, 1, 0, "WaylandSurfaceBase", QObject::tr("Cannot create instance of WaylandSurfaceBase, use WaylandSurface instead"));
qmlRegisterUncreatableType<QWaylandWlShellSurface>(uri, 1, 0, "WlShellSurfaceBase", QObject::tr("Cannot create instance of WlShellSurfaceBase, use WlShellSurface instead"));
+ qmlRegisterUncreatableType<QWaylandXdgSurface>(uri, 1, 0, "XdgSurfaceBase", QObject::tr("Cannot create instance of XdgSurfaceBase, use XdgSurface instead"));
qmlRegisterUncreatableType<QWaylandResource>(uri, 1, 0, "WaylandResource", QObject::tr("Cannot create instance of WaylandResource"));
//This should probably be somewhere else
@@ -149,6 +154,10 @@ public:
qmlRegisterType<QWaylandWlShellSurfaceQuickData>(uri, 1, 0, "WlShellSurface");
qmlRegisterType<QWaylandQuickWlShellSurfaceItem>(uri, 1, 0, "WlShellSurfaceItem");
qmlRegisterType<QWaylandTextInputManagerQuickData>(uri, 1, 0, "TextInputManager");
+
+ qmlRegisterType<QWaylandXdgShellQuickData>(uri, 1, 0, "XdgShell");
+ qmlRegisterType<QWaylandXdgSurfaceQuickData>(uri, 1, 0, "XdgSurface");
+ qmlRegisterType<QWaylandQuickXdgSurfaceItem>(uri, 1, 0, "XdgSurfaceItem");
}
};
//![class decl]