summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@theqtcompany.com>2015-09-14 16:24:30 +0200
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-09-16 10:35:14 +0000
commitdae5d55dea859bb3a5722bf665d077f1f9b3d360 (patch)
treed08e0906b015add456105a1bc261fdcfba2f8701
parente9aa3a9edf63ff0f47f38e73ef20403f7bec1a0d (diff)
Implement resize/move for pure-qml
Change-Id: I7919f7715486fa2d8cfe35c08095f6c33757a515 Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
-rw-r--r--examples/wayland/pure-qml/qml/Chrome.qml5
-rw-r--r--examples/wayland/pure-qml/qml/main.qml40
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp10
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.h3
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.h1
-rw-r--r--src/compositor/extensions/extensions.pri10
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp177
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem.h86
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h81
-rw-r--r--src/compositor/extensions/qwaylandshell.cpp30
-rw-r--r--src/compositor/extensions/qwaylandshell.h28
-rw-r--r--src/imports/compositor/qwaylandquickcompositorplugin.cpp9
12 files changed, 427 insertions, 53 deletions
diff --git a/examples/wayland/pure-qml/qml/Chrome.qml b/examples/wayland/pure-qml/qml/Chrome.qml
index f52582816..acdb4c65e 100644
--- a/examples/wayland/pure-qml/qml/Chrome.qml
+++ b/examples/wayland/pure-qml/qml/Chrome.qml
@@ -41,9 +41,12 @@
import QtQuick 2.0
import QtWayland.Compositor 1.0
-WaylandQuickItem {
+ShellSurfaceItem {
id: rootChrome
+ shellSurface: ShellSurface {
+ }
+
onSurfaceDestroyed: {
lockedBuffer = true;
destroyAnimation.start();
diff --git a/examples/wayland/pure-qml/qml/main.qml b/examples/wayland/pure-qml/qml/main.qml
index 7f47e1325..d20ea10fd 100644
--- a/examples/wayland/pure-qml/qml/main.qml
+++ b/examples/wayland/pure-qml/qml/main.qml
@@ -60,49 +60,17 @@ WaylandCompositor {
Component {
id: surfaceComponent
WaylandSurface {
- property QtObject shellSurface: null
}
}
extensions: [
- DefaultShell {
+ Shell {
id: defaultShell
- Component {
- id: shellSurfaceComponent
- DefaultShellSurface {
- property Item chrome
- property var previousMousePosition
- property var originalInputEventsEnabled
- Connections {
- target: chrome ? chrome : null
- onMouseMove: {
- var deltaX = windowPosition.x - previousMousePosition.x
- var deltaY = windowPosition.y - previousMousePosition.y
- chrome.x = chrome.x + deltaX
- chrome.y = chrome.y + deltaY
- previousMousePosition = windowPosition;
- }
- onMouseRelease: {
- chrome.inputEventsEnabled = originalInputEventsEnabled;
- }
- }
-
- onStartMove: {
- previousMousePosition = chrome.mousePressPosition
- originalInputEventsEnabled = chrome.inputEventsEnabled
- chrome.inputEventsEnabled = false;
- }
-
- }
- }
onCreateShellSurface: {
var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "surface": surface } );
- var shellSurface = shellSurfaceComponent.createObject( null, { "chrome": item });
- shellSurface.chrome = item;
- shellSurface.initialize(defaultShell, surface, client, id);
- surface.shellSurface = shellSurface;
+ item.shellSurface.initialize(defaultShell, surface, client, id);
}
Component.onCompleted: {
@@ -112,12 +80,12 @@ WaylandCompositor {
]
onCreateSurface: {
- var surface = surfaceComponent.createObject(0, { } );
+ var surface = surfaceComponent.createObject(compositor, { } );
surface.initialize(compositor, client, id, version);
}
Component.onCompleted: {
- screenComponent.createObject(0, { "outputSpace" : defaultOutputSpace } );
+ screenComponent.createObject(compositor, { "outputSpace" : defaultOutputSpace } );
}
}
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index f108e0f67..90ca49d53 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -177,10 +177,10 @@ QSGTextureProvider *QWaylandQuickItem::textureProvider() const
return d->provider;
}
+
void QWaylandQuickItem::mousePressEvent(QMouseEvent *event)
{
Q_D(QWaylandQuickItem);
- m_mousePressPosition = event->windowPos();
if (!d->shouldSendInputEvents()) {
event->ignore();
return;
@@ -214,7 +214,6 @@ void QWaylandQuickItem::mouseMoveEvent(QMouseEvent *event)
void QWaylandQuickItem::mouseReleaseEvent(QMouseEvent *event)
{
Q_D(QWaylandQuickItem);
- m_mousePressPosition = QPointF();
if (d->shouldSendInputEvents()) {
QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
inputDevice->sendMouseReleaseEvent(event->button());
@@ -345,6 +344,12 @@ void QWaylandQuickItem::mouseUngrabEvent()
}
}
+void QWaylandQuickItem::surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface)
+{
+ Q_UNUSED(newSurface);
+ Q_UNUSED(oldSurface);
+}
+
void QWaylandQuickItem::handleSurfaceChanged()
{
Q_D(QWaylandQuickItem);
@@ -372,6 +377,7 @@ void QWaylandQuickItem::handleSurfaceChanged()
d->view->setOutput(output);
}
}
+ surfaceChangedEvent(d->view->surface(), d->oldSurface);
d->oldSurface = d->view->surface();
}
diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h
index 709e3e9c6..5bdd30566 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.h
+++ b/src/compositor/compositor_api/qwaylandquickitem.h
@@ -67,7 +67,6 @@ class Q_COMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem
Q_PROPERTY(bool resizeSurfaceToItem READ resizeSurfaceToItem WRITE setResizeSurfaceToItem NOTIFY resizeSurfaceToItemChanged)
Q_PROPERTY(bool inputEventsEnabled READ inputEventsEnabled WRITE setInputEventsEnabled NOTIFY inputEventsEnabledChanged)
Q_PROPERTY(bool focusOnClick READ focusOnClick WRITE setFocusOnClick NOTIFY focusOnClickChanged)
- Q_PROPERTY(QPointF mousePressPosition READ mousePressPosition)
public:
QWaylandQuickItem(QQuickItem *parent = 0);
@@ -113,6 +112,7 @@ protected:
void touchEvent(QTouchEvent *event);
void mouseUngrabEvent() Q_DECL_OVERRIDE;
+ virtual void surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface);
public Q_SLOTS:
virtual void takeFocus(QWaylandInputDevice *device = 0);
void setPaintEnabled(bool paintEnabled);
@@ -141,7 +141,6 @@ protected:
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *);
QWaylandQuickItem(QWaylandQuickItemPrivate &dd, QQuickItem *parent = 0);
- QPointF m_mousePressPosition;
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h
index 12209673f..5917e8c01 100644
--- a/src/compositor/compositor_api/qwaylandsurface.h
+++ b/src/compositor/compositor_api/qwaylandsurface.h
@@ -69,6 +69,7 @@ class Q_COMPOSITOR_EXPORT QWaylandSurface : public QObject, public QWaylandExten
Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged)
Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged)
Q_PROPERTY(bool isMapped READ isMapped NOTIFY mappedChanged)
+ Q_PROPERTY(bool cursorSurface READ isCursorSurface WRITE markAsCursorSurface)
public:
enum Origin {
diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri
index 99c14c96f..bede92580 100644
--- a/src/compositor/extensions/extensions.pri
+++ b/src/compositor/extensions/extensions.pri
@@ -35,4 +35,14 @@ SOURCES += \
extensions/qwlinputmethod.cpp \
extensions/qwlinputmethodcontext.cpp \
+qtHaveModule(quick) {
+ HEADERS += \
+ extensions/qwaylandquickshellsurfaceitem.h \
+ extensions/qwaylandquickshellsurfaceitem_p.h \
+
+ SOURCES += \
+ extensions/qwaylandquickshellsurfaceitem.cpp \
+
+}
+
INCLUDEPATH += extensions
diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp
new file mode 100644
index 000000000..2dcc8f762
--- /dev/null
+++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp
@@ -0,0 +1,177 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** 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 "qwaylandquickshellsurfaceitem.h"
+#include "qwaylandquickshellsurfaceitem_p.h"
+
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/QWaylandInputDevice>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandQuickShellSurfaceItem::QWaylandQuickShellSurfaceItem(QQuickItem *parent)
+ : QWaylandQuickItem(*new QWaylandQuickShellSurfaceItemPrivate(), parent)
+{
+}
+
+QWaylandQuickShellSurfaceItem::QWaylandQuickShellSurfaceItem(QWaylandQuickShellSurfaceItemPrivate &dd, QQuickItem *parent)
+ : QWaylandQuickItem(dd, parent)
+{
+}
+
+QWaylandShellSurface *QWaylandQuickShellSurfaceItem::shellSurface() const
+{
+ Q_D(const QWaylandQuickShellSurfaceItem);
+ return d->shellSurface;
+}
+
+void QWaylandQuickShellSurfaceItem::setShellSurface(QWaylandShellSurface *shellSurface)
+{
+ Q_D(QWaylandQuickShellSurfaceItem);
+ if (shellSurface == d->shellSurface)
+ return;
+
+ if (d->shellSurface) {
+ disconnect(d->shellSurface, &QWaylandShellSurface::startMove, this, &QWaylandQuickShellSurfaceItem::handleStartMove);
+ disconnect(d->shellSurface, &QWaylandShellSurface::startResize, this, &QWaylandQuickShellSurfaceItem::handleStartResize);
+ }
+ d->shellSurface = shellSurface;
+ if (d->shellSurface) {
+ connect(d->shellSurface, &QWaylandShellSurface::startMove, this, &QWaylandQuickShellSurfaceItem::handleStartMove);
+ connect(d->shellSurface, &QWaylandShellSurface::startResize, this, &QWaylandQuickShellSurfaceItem::handleStartResize);
+ }
+ emit shellSurfaceChanged();
+}
+
+QQuickItem *QWaylandQuickShellSurfaceItem::moveItem() const
+{
+ Q_D(const QWaylandQuickShellSurfaceItem);
+ return d->moveItem;
+}
+
+void QWaylandQuickShellSurfaceItem::setMoveItem(QQuickItem *moveItem)
+{
+ Q_D(QWaylandQuickShellSurfaceItem);
+ if (d->moveItem == moveItem)
+ return;
+ d->moveItem = moveItem;
+ moveItemChanged();
+}
+
+void QWaylandQuickShellSurfaceItem::handleStartMove(QWaylandInputDevice *inputDevice)
+{
+ Q_D(QWaylandQuickShellSurfaceItem);
+ d->grabberState = QWaylandQuickShellSurfaceItemPrivate::MoveState;
+ d->moveState.inputDevice = inputDevice;
+ d->moveState.initialized = false;
+}
+
+void QWaylandQuickShellSurfaceItem::handleStartResize(QWaylandInputDevice *inputDevice, QWaylandShellSurface::ResizeEdge edges)
+{
+ Q_D(QWaylandQuickShellSurfaceItem);
+ d->grabberState = QWaylandQuickShellSurfaceItemPrivate::ResizeState;
+ d->resizeState.inputDevice = inputDevice;
+ d->resizeState.resizeEdges = edges;
+ d->resizeState.initialSize = surface()->size();
+ d->resizeState.initialized = false;
+}
+
+void QWaylandQuickShellSurfaceItem::adjustOffsetForNextFrame(const QPointF &offset)
+{
+ Q_D(QWaylandQuickShellSurfaceItem);
+ QQuickItem *moveItem = d->moveItem ? d->moveItem : this;
+ moveItem->setPosition(moveItem->position() + offset);
+}
+
+void QWaylandQuickShellSurfaceItem::mouseMoveEvent(QMouseEvent *event)
+{
+ Q_D(QWaylandQuickShellSurfaceItem);
+ if (d->grabberState == QWaylandQuickShellSurfaceItemPrivate::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 = shellSurface()->sizeForResize(d->resizeState.initialSize, delta, d->resizeState.resizeEdges);
+ shellSurface()->sendConfigure(newSize, d->resizeState.resizeEdges);
+ } else if (d->grabberState == QWaylandQuickShellSurfaceItemPrivate::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);
+ }
+}
+
+void QWaylandQuickShellSurfaceItem::mouseReleaseEvent(QMouseEvent *event)
+{
+ Q_D(QWaylandQuickShellSurfaceItem);
+ if (d->grabberState != QWaylandQuickShellSurfaceItemPrivate::DefaultState) {
+ d->grabberState = QWaylandQuickShellSurfaceItemPrivate::DefaultState;
+ return;
+ }
+ QWaylandQuickItem::mouseReleaseEvent(event);
+}
+
+void QWaylandQuickShellSurfaceItem::surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface)
+{
+ if (oldSurface)
+ disconnect(oldSurface, &QWaylandSurface::offsetForNextFrame, this, &QWaylandQuickShellSurfaceItem::adjustOffsetForNextFrame);
+
+ if (newSurface)
+ connect(newSurface, &QWaylandSurface::offsetForNextFrame, this, &QWaylandQuickShellSurfaceItem::adjustOffsetForNextFrame);
+}
+
+void QWaylandQuickShellSurfaceItem::componentComplete()
+{
+ Q_D(QWaylandQuickShellSurfaceItem);
+ if (!d->shellSurface)
+ setShellSurface(new QWaylandShellSurface());
+
+ QWaylandQuickItem::componentComplete();
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h
new file mode 100644
index 000000000..fe24ce208
--- /dev/null
+++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** 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 QWAYLANDQUICKSHELLSURFACEITEM_H
+#define QWAYLANDQUICKSHELLSURFACEITEM_H
+
+#include <QtWaylandCompositor/QWaylandExtension>
+#include <QtWaylandCompositor/QWaylandQuickItem>
+#include <QtWaylandCompositor/QWaylandShellSurface>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandQuickShellSurfaceItemPrivate;
+
+class Q_COMPOSITOR_EXPORT QWaylandQuickShellSurfaceItem : public QWaylandQuickItem
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandQuickShellSurfaceItem)
+ Q_PROPERTY(QWaylandShellSurface *shellSurface READ shellSurface WRITE setShellSurface NOTIFY shellSurfaceChanged)
+ Q_PROPERTY(QQuickItem *moveItem READ moveItem WRITE setMoveItem NOTIFY moveItemChanged)
+
+public:
+ QWaylandQuickShellSurfaceItem(QQuickItem *parent = 0);
+
+ static QWaylandQuickShellSurfaceItemPrivate *get(QWaylandQuickShellSurfaceItem *item) { return item->d_func(); }
+
+ QWaylandShellSurface *shellSurface() const;
+ void setShellSurface(QWaylandShellSurface *shellSurface);
+
+ QQuickItem *moveItem() const;
+ void setMoveItem(QQuickItem *moveItem);
+Q_SIGNALS:
+ void shellSurfaceChanged();
+ void moveItemChanged();
+
+private Q_SLOTS:
+ void handleStartMove(QWaylandInputDevice *inputDevice);
+ void handleStartResize(QWaylandInputDevice *inputDevice, QWaylandShellSurface::ResizeEdge edges);
+ void adjustOffsetForNextFrame(const QPointF &offset);
+protected:
+ QWaylandQuickShellSurfaceItem(QWaylandQuickShellSurfaceItemPrivate &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;
+
+ void componentComplete() Q_DECL_OVERRIDE;
+};
+
+QT_END_NAMESPACE
+
+#endif /*QWAYLANDQUICKSHELLSURFACEITEM_H*/
diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h
new file mode 100644
index 000000000..561a50485
--- /dev/null
+++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** 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 QWAYLANDQUICKSHELLSURFACEITEM_P_H
+#define QWAYLANDQUICKSHELLSURFACEITEM_P_H
+
+#include <QtWaylandCompositor/private/qwaylandquickitem_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_COMPOSITOR_EXPORT QWaylandQuickShellSurfaceItemPrivate : public QWaylandQuickItemPrivate
+{
+public:
+ enum GrabberState {
+ DefaultState,
+ ResizeState,
+ MoveState
+ };
+
+ QWaylandQuickShellSurfaceItemPrivate()
+ : QWaylandQuickItemPrivate()
+ , shellSurface(Q_NULLPTR)
+ , moveItem(Q_NULLPTR)
+ , grabberState(DefaultState)
+ {}
+
+ QWaylandShellSurface *shellSurface;
+ QQuickItem *moveItem;
+
+ GrabberState grabberState;
+ struct {
+ QWaylandInputDevice *inputDevice;
+ QPointF initialOffset;
+ bool initialized;
+ } moveState;
+
+ struct {
+ QWaylandInputDevice *inputDevice;
+ QWaylandShellSurface::ResizeEdge resizeEdges;
+ QSizeF initialSize;
+ QPointF initialMousePos;
+ bool initialized;
+ } resizeState;
+};
+
+QT_END_NAMESPACE
+
+#endif /*QWAYLANDQUICKSHELLSURFACEITEM_P_H*/
diff --git a/src/compositor/extensions/qwaylandshell.cpp b/src/compositor/extensions/qwaylandshell.cpp
index cb8ccf778..8b724bb3e 100644
--- a/src/compositor/extensions/qwaylandshell.cpp
+++ b/src/compositor/extensions/qwaylandshell.cpp
@@ -267,6 +267,7 @@ void QWaylandShellSurface::initialize(QWaylandShell *shell, QWaylandSurface *sur
d->m_surface = surface;
d->init(client->client(), id, 1);
setExtensionContainer(surface);
+ emit surfaceChanged();
QWaylandExtension::initialize();
}
void QWaylandShellSurface::initialize()
@@ -284,6 +285,35 @@ QByteArray QWaylandShellSurface::interfaceName()
return QWaylandShellSurfacePrivate::interfaceName();
}
+QSize QWaylandShellSurface::sizeForResize(const QSizeF &size, const QPointF &delta, QWaylandShellSurface::ResizeEdge edge)
+{
+ qreal width = size.width();
+ qreal height = size.height();
+ if (edge & LeftEdge)
+ width -= delta.x();
+ else if (edge & RightEdge)
+ width += delta.x();
+
+ if (edge & TopEdge)
+ height -= delta.y();
+ else if (edge & BottomEdge)
+ height += delta.y();
+
+ return QSizeF(width, height).toSize();
+}
+
+void QWaylandShellSurface::sendConfigure(const QSize &size, ResizeEdge edges)
+{
+ Q_D(QWaylandShellSurface);
+ d->send_configure(edges, size.width(), size.height());
+}
+
+void QWaylandShellSurface::sendPopupDone()
+{
+ Q_D(QWaylandShellSurface);
+ d->send_popup_done();
+}
+
QWaylandSurface *QWaylandShellSurface::surface() const
{
Q_D(const QWaylandShellSurface);
diff --git a/src/compositor/extensions/qwaylandshell.h b/src/compositor/extensions/qwaylandshell.h
index 07a504855..ac014cf84 100644
--- a/src/compositor/extensions/qwaylandshell.h
+++ b/src/compositor/extensions/qwaylandshell.h
@@ -39,6 +39,8 @@
#include <QtWaylandCompositor/QWaylandExtension>
+#include <QtCore/QSize>
+
QT_BEGIN_NAMESPACE
class QWaylandShellPrivate;
@@ -69,6 +71,7 @@ class Q_COMPOSITOR_EXPORT QWaylandShellSurface : public QWaylandExtensionTemplat
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandShellSurface)
+ Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged)
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QString className READ className NOTIFY classNameChanged)
Q_PROPERTY(FocusPolicy focusPolicy READ focusPolicy NOTIFY focusPolicyChanged)
@@ -83,15 +86,15 @@ public:
Q_ENUM(FullScreenMethod);
enum ResizeEdge {
- DefaultEdge = 0x00,
- TopEdge = 0x01,
- BottomEdge = 0x02,
- LeftEdge = 0x04,
- TopLeftEdge = 0x05,
- BottomLeftEdge = 0x06,
- RightEdge = 0x08,
- TopRightEdge = 0x09,
- BottomRightEdge = 0x10
+ DefaultEdge = 0,
+ TopEdge = 1,
+ BottomEdge = 2,
+ LeftEdge = 4,
+ TopLeftEdge = 5,
+ BottomLeftEdge = 6,
+ RightEdge = 8,
+ TopRightEdge = 9,
+ BottomRightEdge = 10
};
Q_ENUM(ResizeEdge);
@@ -115,13 +118,18 @@ public:
static const struct wl_interface *interface();
static QByteArray interfaceName();
+
+ Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, ResizeEdge edges);
+ Q_INVOKABLE void sendConfigure(const QSize &size, ResizeEdge edges);
+ Q_INVOKABLE void sendPopupDone();
Q_SIGNALS:
+ void surfaceChanged();
void titleChanged();
void classNameChanged();
void focusPolicyChanged();
void pong();
void startMove(QWaylandInputDevice *inputDevice);
- void startResize(QWaylandInputDevice *inputDevice, ResizeEdge edge);
+ void startResize(QWaylandInputDevice *inputDevice, ResizeEdge edges);
void setDefaultToplevel();
void setTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, FocusPolicy focusPolicy);
diff --git a/src/imports/compositor/qwaylandquickcompositorplugin.cpp b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
index e83468e5c..9e3230abd 100644
--- a/src/imports/compositor/qwaylandquickcompositorplugin.cpp
+++ b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
@@ -48,6 +48,7 @@
#include <QtWaylandCompositor/QWaylandExtension>
#include <QtWaylandCompositor/QWaylandQuickExtension>
#include <QtWaylandCompositor/QWaylandInputDevice>
+#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem>
#include <QtWaylandCompositor/QWaylandShell>
@@ -135,10 +136,14 @@ public:
qmlRegisterUncreatableType<QWaylandInputDevice>(uri, 1, 0, "WaylandInputDevice", QObject::tr("Cannot create instance of WaylandInputDevice"));
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<QWaylandShellSurface>(uri, 1, 0, "ShellSurfaceBase", QObject::tr("Cannot create instance of ShellSurfaceBase, use ShellSurface instead"));
+
//This should probably be somewhere else
- qmlRegisterType<QWaylandShellQuickData>(uri, 1, 0, "DefaultShell");
- qmlRegisterType<QWaylandShellSurfaceQuickData>(uri, 1, 0, "DefaultShellSurface");
+ qmlRegisterType<QWaylandShellQuickData>(uri, 1, 0, "Shell");
+ qmlRegisterType<QWaylandShellSurfaceQuickData>(uri, 1, 0, "ShellSurface");
+ qmlRegisterType<QWaylandQuickShellSurfaceItem>(uri, 1, 0, "ShellSurfaceItem");
+
}
};
//![class decl]