diff options
Diffstat (limited to 'src/imports/compositor')
-rw-r--r-- | src/imports/compositor/WaylandCursorItem.qml | 60 | ||||
-rw-r--r-- | src/imports/compositor/WaylandOutputWindow.qml | 55 | ||||
-rw-r--r-- | src/imports/compositor/compositor.pro | 45 | ||||
-rw-r--r-- | src/imports/compositor/plugins.qmltypes | 231 | ||||
-rw-r--r-- | src/imports/compositor/qmldir | 3 | ||||
-rw-r--r-- | src/imports/compositor/qwaylandmousetracker.cpp | 140 | ||||
-rw-r--r-- | src/imports/compositor/qwaylandmousetracker_p.h | 77 | ||||
-rw-r--r-- | src/imports/compositor/qwaylandquickcompositorplugin.cpp | 151 |
8 files changed, 762 insertions, 0 deletions
diff --git a/src/imports/compositor/WaylandCursorItem.qml b/src/imports/compositor/WaylandCursorItem.qml new file mode 100644 index 000000000..9eacff9be --- /dev/null +++ b/src/imports/compositor/WaylandCursorItem.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt-project.org/legal +** +** 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$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtWayland.Compositor 1.0 + +WaylandQuickItem { + id: cursorItem + property QtObject inputDevice + property int hotspotX: 0 + property int hotspotY: 0 + + visible: cursorItem.surface != null + inputEventsEnabled: false + + onInputDeviceChanged: { + if (!inputDevice) + return; + inputDevice.cursorSurfaceRequest.connect(setCursorSurface); + } + + function setCursorSurface(surface, hotspotX, hotspotY) { + cursorItem.surface = surface; + cursorItem.hotspotX = hotspotX; + cursorItem.hotspotY = hotspotY; + } +} diff --git a/src/imports/compositor/WaylandOutputWindow.qml b/src/imports/compositor/WaylandOutputWindow.qml new file mode 100644 index 000000000..439f52af4 --- /dev/null +++ b/src/imports/compositor/WaylandOutputWindow.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt-project.org/legal +** +** 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$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.2 + +Window { + id: window + property QtObject compositor + property QtObject output + property bool automaticFrameCallback: false + + Component.onCompleted: { + if (!compositor) { + console.warn("WaylandOutputWindow initiated without compositor. This leads to undefined behavior"); + return; + } + output = compositor.addOutput(window); + output.automaticFrameCallbacks = window.automaticFrameCallback; + } +} + diff --git a/src/imports/compositor/compositor.pro b/src/imports/compositor/compositor.pro new file mode 100644 index 000000000..a97f90f48 --- /dev/null +++ b/src/imports/compositor/compositor.pro @@ -0,0 +1,45 @@ +CXX_MODULE = qml +TARGET = qwaylandcompositorplugin +TARGETPATH = QtWayland/Compositor +IMPORT_VERSION = 1.0 + +HEADERS += \ + qwaylandmousetracker_p.h + +SOURCES += \ + qwaylandquickcompositorplugin.cpp \ + qwaylandmousetracker.cpp + +COMPOSITOR_QML_FILES += \ + WaylandOutputWindow.qml \ + WaylandCursorItem.qml \ + qmldir + +# Create the resource file +GENERATED_RESOURCE_FILE = $$OUT_PWD/compositor.qrc + +RESOURCE_CONTENT = \ + "<RCC>" \ + "<qresource prefix=\"/QtWayland/Compositor\">" + +for(resourcefile, COMPOSITOR_QML_FILES) { + resourcefileabsolutepath = $$absolute_path($$resourcefile) + relativepath_in = $$relative_path($$resourcefileabsolutepath, $$_PRO_FILE_PWD_) + relativepath_out = $$relative_path($$resourcefileabsolutepath, $$OUT_PWD) + RESOURCE_CONTENT += "<file alias=\"$$relativepath_in\">$$relativepath_out</file>" +} + +RESOURCE_CONTENT += \ + "</qresource>" \ + "</RCC>" + +write_file($$GENERATED_RESOURCE_FILE, RESOURCE_CONTENT)|error("Aborting.") + +RESOURCES += $$GENERATED_RESOURCE_FILE + +# In case of a debug build, deploy the QML files too +CONFIG(debug, debug|release): QML_FILES += $$COMPOSITOR_QML_FILES + +QT += quick-private qml-private gui-private core-private waylandcompositor waylandcompositor-private + +load(qml_plugin) diff --git a/src/imports/compositor/plugins.qmltypes b/src/imports/compositor/plugins.qmltypes new file mode 100644 index 000000000..caf9ee0a7 --- /dev/null +++ b/src/imports/compositor/plugins.qmltypes @@ -0,0 +1,231 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable QtWayland.Compositor 1.0' + +Module { + Component { + name: "QWaylandClient" + prototype: "QObject" + exports: ["QtWayland.Compositor/WaylandClient 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "userId"; type: "qlonglong"; isReadonly: true } + Property { name: "groupId"; type: "qlonglong"; isReadonly: true } + Property { name: "processId"; type: "qlonglong"; isReadonly: true } + Method { name: "close" } + Method { + name: "kill" + Parameter { name: "sig"; type: "int" } + } + Method { name: "kill" } + } + Component { + name: "QWaylandCompositor" + prototype: "QObject" + Property { name: "socketName"; type: "QByteArray" } + Property { name: "extensionFlags"; type: "QWaylandCompositor::ExtensionFlags" } + Property { name: "retainedSelection"; type: "bool" } + Property { name: "primaryOutput"; type: "QWaylandOutput"; isPointer: true } + Signal { + name: "surfaceCreated" + Parameter { name: "surface"; type: "QWaylandSurface"; isPointer: true } + } + Signal { + name: "surfaceAboutToBeDestroyed" + Parameter { name: "surface"; type: "QWaylandSurface"; isPointer: true } + } + Method { name: "addDefaultShell" } + Method { + name: "destroyClientForSurface" + Parameter { name: "surface"; type: "QWaylandSurface"; isPointer: true } + } + Method { + name: "destroyClient" + Parameter { name: "client"; type: "QWaylandClient"; isPointer: true } + } + Method { name: "outputs"; type: "QList<QWaylandOutput*>" } + Method { + name: "output" + type: "QWaylandOutput*" + Parameter { name: "outputWindow"; type: "QWindow"; isPointer: true } + } + Method { + name: "addOutput" + type: "QWaylandOutput*" + Parameter { name: "outputWindow"; type: "QWindow"; isPointer: true } + } + Method { + name: "pickView" + type: "QWaylandSurfaceView*" + Parameter { name: "globalPosition"; type: "QPointF" } + } + Method { + name: "mapToView" + type: "QPointF" + Parameter { name: "view"; type: "QWaylandSurfaceView"; isPointer: true } + Parameter { name: "surfacePosition"; type: "QPointF" } + } + } + Component { + name: "QWaylandOutput" + prototype: "QObject" + exports: ["QtWayland.Compositor/WaylandOutput 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "compositor"; type: "QWaylandCompositor"; isReadonly: true; isPointer: true } + Property { name: "window"; type: "QWindow"; isReadonly: true; isPointer: true } + Property { name: "geometry"; type: "QRect" } + Property { name: "x"; type: "int" } + Property { name: "y"; type: "int" } + Property { name: "width"; type: "int" } + Property { name: "height"; type: "int" } + Property { name: "physicalWidth"; type: "int" } + Property { name: "physicalHeight"; type: "int" } + Property { name: "refreshRate"; type: "int" } + } + Component { + name: "QWaylandQuickCompositor" + prototype: "QWaylandCompositor" + Property { name: "initializeLegazyQmlNames"; type: "bool" } + } + Component { + name: "QWaylandQuickCompositorImpl" + prototype: "QWaylandQuickCompositor" + exports: ["QtWayland.Compositor/WaylandCompositor 1.0"] + exportMetaObjectRevisions: [0] + } + Component { + name: "QWaylandQuickSurface" + prototype: "QWaylandSurface" + exports: ["QtWayland.Compositor/WaylandQuickSurface 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "useTextureAlpha"; type: "bool" } + Property { name: "clientRenderingEnabled"; type: "bool" } + Property { name: "windowProperties"; type: "QObject"; isReadonly: true; isPointer: true } + Property { name: "shellView"; type: "QWaylandSurfaceItem"; isReadonly: true; isPointer: true } + Signal { name: "shellViewCreated" } + } + Component { + name: "QWaylandSurface" + prototype: "QObject" + Enum { + name: "WindowFlag" + values: { + "OverridesSystemGestures": 1, + "StaysOnTop": 2, + "BypassWindowManager": 4 + } + } + Enum { + name: "WindowFlags" + values: { + "OverridesSystemGestures": 1, + "StaysOnTop": 2, + "BypassWindowManager": 4 + } + } + Enum { + name: "WindowType" + values: { + "None": 0, + "Toplevel": 1, + "Transient": 2, + "Popup": 3 + } + } + Property { name: "client"; type: "QWaylandClient"; isReadonly: true; isPointer: true } + Property { name: "size"; type: "QSize"; isReadonly: true } + Property { name: "windowFlags"; type: "QWaylandSurface::WindowFlags"; isReadonly: true } + Property { name: "windowType"; type: "QWaylandSurface::WindowType"; isReadonly: true } + Property { name: "contentOrientation"; type: "Qt::ScreenOrientation"; isReadonly: true } + Property { name: "className"; type: "string"; isReadonly: true } + Property { name: "title"; type: "string"; isReadonly: true } + Property { name: "orientationUpdateMask"; type: "Qt::ScreenOrientations"; isReadonly: true } + Property { name: "visibility"; type: "QWindow::Visibility" } + Property { name: "transientParent"; type: "QWaylandSurface"; isReadonly: true; isPointer: true } + Property { name: "transientOffset"; type: "QPointF"; isReadonly: true } + Property { name: "output"; type: "QWaylandOutput"; isReadonly: true; isPointer: true } + Signal { name: "mapped" } + Signal { name: "unmapped" } + Signal { + name: "damaged" + Parameter { name: "rect"; type: "QRegion" } + } + Signal { + name: "parentChanged" + Parameter { name: "newParent"; type: "QWaylandSurface"; isPointer: true } + Parameter { name: "oldParent"; type: "QWaylandSurface"; isPointer: true } + } + Signal { + name: "windowPropertyChanged" + Parameter { name: "name"; type: "string" } + Parameter { name: "value"; type: "QVariant" } + } + Signal { + name: "windowFlagsChanged" + Parameter { name: "flags"; type: "WindowFlags" } + } + Signal { + name: "windowTypeChanged" + Parameter { name: "type"; type: "WindowType" } + } + Signal { name: "extendedSurfaceReady" } + Signal { name: "raiseRequested" } + Signal { name: "lowerRequested" } + Signal { name: "pong" } + Signal { name: "surfaceDestroyed" } + Signal { name: "shellViewCreated" } + Signal { + name: "outputChanged" + Parameter { name: "newOutput"; type: "QWaylandOutput"; isPointer: true } + Parameter { name: "oldOutput"; type: "QWaylandOutput"; isPointer: true } + } + Signal { + name: "configure" + Parameter { name: "hasBuffer"; type: "bool" } + } + Signal { name: "redraw" } + Method { name: "updateSelection" } + Method { + name: "requestSize" + Parameter { name: "size"; type: "QSize" } + } + Method { + name: "sendOnScreenVisibilityChange" + Parameter { name: "visible"; type: "bool" } + } + Method { name: "destroy" } + Method { name: "destroySurface" } + Method { name: "ping" } + } + Component { + name: "QWaylandSurfaceItem" + defaultProperty: "data" + prototype: "QQuickItem" + exports: ["QtWayland.Compositor/WaylandSurfaceItem 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "surface"; type: "QWaylandSurface"; isReadonly: true; isPointer: true } + Property { name: "paintEnabled"; type: "bool" } + Property { name: "touchEventsEnabled"; type: "bool" } + Property { name: "isYInverted"; type: "bool"; isReadonly: true } + Property { name: "resizeSurfaceToItem"; type: "bool" } + Signal { name: "yInvertedChanged" } + Signal { name: "surfaceDestroyed" } + Method { + name: "takeFocus" + Parameter { name: "device"; type: "QWaylandInputDevice"; isPointer: true } + } + Method { name: "takeFocus" } + Method { + name: "setPaintEnabled" + Parameter { name: "paintEnabled"; type: "bool" } + } + Method { name: "isYInverted"; type: "bool" } + } +} diff --git a/src/imports/compositor/qmldir b/src/imports/compositor/qmldir new file mode 100644 index 000000000..6307e1a80 --- /dev/null +++ b/src/imports/compositor/qmldir @@ -0,0 +1,3 @@ +module QtWayland.Compositor +plugin qwaylandcompositorplugin +classname QWaylandCompositorPlugin diff --git a/src/imports/compositor/qwaylandmousetracker.cpp b/src/imports/compositor/qwaylandmousetracker.cpp new file mode 100644 index 000000000..fd6a591ee --- /dev/null +++ b/src/imports/compositor/qwaylandmousetracker.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 "qwaylandmousetracker_p.h" + +#include <QtQuick/private/qquickitem_p.h> + +QT_BEGIN_NAMESPACE + +class QWaylandMouseTrackerPrivate : public QQuickItemPrivate +{ + Q_DECLARE_PUBLIC(QWaylandMouseTracker) +public: + QWaylandMouseTrackerPrivate() + : enableWSCursor(false) + { + QImage cursorImage(64,64,QImage::Format_ARGB32); + cursorImage.fill(Qt::transparent); + cursorPixmap = QPixmap::fromImage(cursorImage); + } + void handleMousePos(const QPointF &mousePos) + { + Q_Q(QWaylandMouseTracker); + bool xChanged = mousePos.x() != this->mousePos.x(); + bool yChanged = mousePos.y() != this->mousePos.y(); + if (xChanged || yChanged) { + this->mousePos = mousePos; + if (xChanged) + emit q->mouseXChanged(); + if (yChanged) + emit q->mouseYChanged(); + } + } + + QPointF mousePos; + bool enableWSCursor; + QPixmap cursorPixmap; +}; + +QWaylandMouseTracker::QWaylandMouseTracker(QQuickItem *parent) + : QQuickItem(*(new QWaylandMouseTrackerPrivate), parent) +{ + Q_D(QWaylandMouseTracker); + setFiltersChildMouseEvents(true); + setAcceptHoverEvents(true); + setCursor(QCursor(d->cursorPixmap)); +} + +qreal QWaylandMouseTracker::mouseX() const +{ + Q_D(const QWaylandMouseTracker); + return d->mousePos.x(); +} +qreal QWaylandMouseTracker::mouseY() const +{ + Q_D(const QWaylandMouseTracker); + return d->mousePos.y(); +} + +void QWaylandMouseTracker::setEnableWSCursor(bool enable) +{ + Q_D(QWaylandMouseTracker); + if (d->enableWSCursor != enable) { + d->enableWSCursor = enable; + if (enable) { + unsetCursor(); + } else { + setCursor(QCursor(d->cursorPixmap)); + } + emit enableWSCursorChanged(); + } +} + +bool QWaylandMouseTracker::enableWSCursor() const +{ + Q_D(const QWaylandMouseTracker); + return d->enableWSCursor; +} + +bool QWaylandMouseTracker::childMouseEventFilter(QQuickItem *item, QEvent *event) +{ + Q_D(QWaylandMouseTracker); + if (event->type() == QEvent::MouseMove) { + QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + d->handleMousePos(mapFromItem(item, mouseEvent->localPos())); + } else if (event->type() == QEvent::HoverMove) { + QHoverEvent *hoverEvent = static_cast<QHoverEvent *>(event); + d->handleMousePos(mapFromItem(item, hoverEvent->posF())); + } + return false; +} + +void QWaylandMouseTracker::mouseMoveEvent(QMouseEvent *event) +{ + Q_D(QWaylandMouseTracker); + QQuickItem::mouseMoveEvent(event); + d->handleMousePos(event->localPos()); +} + +void QWaylandMouseTracker::hoverMoveEvent(QHoverEvent *event) +{ + Q_D(QWaylandMouseTracker); + QQuickItem::hoverMoveEvent(event); + d->handleMousePos(event->posF()); +} + +QT_END_NAMESPACE diff --git a/src/imports/compositor/qwaylandmousetracker_p.h b/src/imports/compositor/qwaylandmousetracker_p.h new file mode 100644 index 000000000..00c33de97 --- /dev/null +++ b/src/imports/compositor/qwaylandmousetracker_p.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 QWAYLANDMOUSETRACKER_P_H +#define QWAYLANDMOUSETRACKER_P_H + +#include <QtQuick/private/qquickmousearea_p.h> + +#include <QtWaylandCompositor/qwaylandexport.h> + +QT_BEGIN_NAMESPACE + +class QWaylandMouseTrackerPrivate; + +class Q_COMPOSITOR_EXPORT QWaylandMouseTracker : public QQuickItem +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandMouseTracker) + Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mouseXChanged) + Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mouseYChanged) + + Q_PROPERTY(bool enableWSCursor READ enableWSCursor WRITE setEnableWSCursor NOTIFY enableWSCursorChanged) +public: + QWaylandMouseTracker(QQuickItem *parent = 0); + + qreal mouseX() const; + qreal mouseY() const; + + void setEnableWSCursor(bool enable); + bool enableWSCursor() const; +signals: + void mouseXChanged(); + void mouseYChanged(); + void enableWSCursorChanged(); + +protected: + bool childMouseEventFilter(QQuickItem *item, QEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; +}; + +QT_END_NAMESPACE + +#endif /*QWAYLANDMOUSETRACKER_P_H*/ diff --git a/src/imports/compositor/qwaylandquickcompositorplugin.cpp b/src/imports/compositor/qwaylandquickcompositorplugin.cpp new file mode 100644 index 000000000..b380f575c --- /dev/null +++ b/src/imports/compositor/qwaylandquickcompositorplugin.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 <QtCore/QDir> + +#include <QtQml/qqmlextensionplugin.h> + +#include <QtQuick/QQuickItem> + +#include <QtWaylandCompositor/QWaylandQuickCompositor> +#include <QtWaylandCompositor/QWaylandQuickItem> +#include <QtWaylandCompositor/QWaylandQuickSurface> +#include <QtWaylandCompositor/QWaylandClient> +#include <QtWaylandCompositor/QWaylandQuickOutput> +#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandQuickExtension> +#include <QtWaylandCompositor/QWaylandInputDevice> +#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem> + +#include <QtWaylandCompositor/QWaylandShell> + +#include <QtWaylandCompositor/qwaylandexport.h> +#include "qwaylandmousetracker_p.h" + +QT_BEGIN_NAMESPACE + +Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandQuickCompositor) +Q_COMPOSITOR_DECLARE_QUICK_DATA_CLASS(QWaylandShell) +Q_COMPOSITOR_DECLARE_QUICK_DATA_CLASS(QWaylandShellSurface) + +class QmlUrlResolver +{ +public: + QmlUrlResolver(bool useResource, const QDir &qmlDir, const QString &qrcPath) + : m_useResource(useResource) + , m_qmlDir(qmlDir) + , m_qrcPath(qrcPath) + { } + + QUrl get(const QString &fileName) + { + return m_useResource ? QUrl(m_qrcPath + fileName) : + QUrl::fromLocalFile(m_qmlDir.filePath(fileName)); + } +private: + bool m_useResource; + const QDir &m_qmlDir; + const QString &m_qrcPath; +}; + + +/*! + \qmlmodule QtWayland.Compositor 1.0 + \title Qt Wayland Compositor QML Types + \ingroup qmlmodules + \brief Provides QML types for creating Wayland compositors + + This QML module contains types for creating Wayland compositors. + + To use the types in this module, import the module with the following line: + + \code + import QtWayland.Compositor 1.0 + \endcode +*/ + + + +//![class decl] +class QWaylandCompositorPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") +public: + virtual void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWayland.Compositor")); + defineModule(uri); + + bool useResource = true; + QDir qmlDir(baseUrl().toLocalFile()); + if (qmlDir.exists(QStringLiteral("WaylandCursorItem.qml"))) + useResource = false; + + QmlUrlResolver resolver(useResource, qmlDir, QStringLiteral("qrc:/QtWayland/Compositor/")); + + qmlRegisterType(resolver.get(QStringLiteral("WaylandOutputWindow.qml")), uri, 1, 0, "WaylandOutputWindow"); + qmlRegisterType(resolver.get(QStringLiteral("WaylandCursorItem.qml")), uri, 1, 0, "WaylandCursorItem"); + } + + static void defineModule(const char *uri) + { + qmlRegisterType<QWaylandQuickCompositorQuickExtension>(uri, 1, 0, "WaylandCompositor"); + qmlRegisterType<QWaylandQuickItem>(uri, 1, 0, "WaylandQuickItem"); + qmlRegisterType<QWaylandMouseTracker>(uri, 1, 0, "WaylandMouseTracker"); + qmlRegisterType<QWaylandQuickOutput>(uri, 1, 0, "WaylandOutput"); + qmlRegisterType<QWaylandQuickSurface>(uri, 1, 0, "WaylandSurface"); + + qmlRegisterUncreatableType<QWaylandExtension>(uri, 1, 0, "WaylandExtension", QObject::tr("Cannot create instance of WaylandExtension")); + qmlRegisterUncreatableType<QWaylandClient>(uri, 1, 0, "WaylandClient", QObject::tr("Cannot create instance of WaylandClient")); + qmlRegisterUncreatableType<QWaylandView>(uri, 1, 0, "WaylandView", QObject::tr("Cannot create instance of WaylandView, it can be retrieved by accessor on WaylandQuickItem")); + 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, "Shell"); + qmlRegisterType<QWaylandShellSurfaceQuickData>(uri, 1, 0, "ShellSurface"); + qmlRegisterType<QWaylandQuickShellSurfaceItem>(uri, 1, 0, "ShellSurfaceItem"); + + } +}; +//![class decl] + +QT_END_NAMESPACE + +#include "qwaylandquickcompositorplugin.moc" |