diff options
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/compositor/plugins.qmltypes | 47 | ||||
-rw-r--r-- | src/imports/compositor/qwaylandmousetracker.cpp | 32 | ||||
-rw-r--r-- | src/imports/compositor/qwaylandmousetracker_p.h | 6 | ||||
-rw-r--r-- | src/imports/compositor/qwaylandquickcompositorplugin.cpp | 11 |
4 files changed, 65 insertions, 31 deletions
diff --git a/src/imports/compositor/plugins.qmltypes b/src/imports/compositor/plugins.qmltypes index f73f9660..54b3bfcc 100644 --- a/src/imports/compositor/plugins.qmltypes +++ b/src/imports/compositor/plugins.qmltypes @@ -80,7 +80,7 @@ Module { } } Component { - name: "QWaylandExtension" + name: "QWaylandCompositorExtension" prototype: "QObject" exports: ["QtWayland.Compositor/WaylandExtension 1.0"] isCreatable: false @@ -178,7 +178,7 @@ Module { prototype: "QWaylandQuickCompositor" exports: ["QtWayland.Compositor/WaylandCompositor 1.0"] exportMetaObjectRevisions: [0] - Property { name: "extensions"; type: "QWaylandExtension"; isList: true; isReadonly: true } + Property { name: "extensions"; type: "QWaylandCompositorExtension"; isList: true; isReadonly: true } Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } } Component { @@ -230,6 +230,14 @@ Module { Method { name: "updateStarted" } } Component { + name: "QWaylandQuickShellSurfaceItem" + defaultProperty: "data" + prototype: "QWaylandQuickItem" + exports: ["QtWayland.Compositor/ShellSurfaceItem 1.0"] + exportMetaObjectRevisions: [0] + Property { name: "shellSurface"; type: "QWaylandShellSurface"; isPointer: true } + } + Component { name: "QWaylandQuickSurface" prototype: "QWaylandSurface" exports: ["QtWayland.Compositor/WaylandSurface 1.0"] @@ -238,26 +246,15 @@ Module { Property { name: "clientRenderingEnabled"; type: "bool" } } Component { - name: "QWaylandQuickWlShellSurfaceItem" - defaultProperty: "data" - prototype: "QWaylandQuickItem" - exports: ["QtWayland.Compositor/WlShellSurfaceItem 1.0"] - exportMetaObjectRevisions: [0] - Property { name: "shellSurface"; type: "QWaylandWlShellSurface"; isPointer: true } - Property { name: "moveItem"; type: "QQuickItem"; isPointer: true } - } - Component { - name: "QWaylandQuickXdgSurfaceItem" - defaultProperty: "data" - prototype: "QWaylandQuickItem" - exports: ["QtWayland.Compositor/XdgSurfaceItem 1.0"] + name: "QWaylandResource" + exports: ["QtWayland.Compositor/WaylandResource 1.0"] + isCreatable: false exportMetaObjectRevisions: [0] - Property { name: "xdgSurface"; type: "QWaylandXdgSurface"; isPointer: true } - Property { name: "moveItem"; type: "QQuickItem"; isPointer: true } } Component { - name: "QWaylandResource" - exports: ["QtWayland.Compositor/WaylandResource 1.0"] + name: "QWaylandShellSurface" + prototype: "QWaylandCompositorExtension" + exports: ["QtWayland.Compositor/ShellSurface 1.0"] isCreatable: false exportMetaObjectRevisions: [0] } @@ -329,7 +326,7 @@ Module { Method { name: "frameStarted" } Method { name: "sendFrameCallbacks" } } - Component { name: "QWaylandTextInputManager"; prototype: "QWaylandExtension" } + Component { name: "QWaylandTextInputManager"; prototype: "QWaylandCompositorExtension" } Component { name: "QWaylandTextInputManagerQuickExtension" defaultProperty: "data" @@ -353,7 +350,7 @@ Module { } Component { name: "QWaylandWindowManagerExtension" - prototype: "QWaylandExtension" + prototype: "QWaylandCompositorExtension" Property { name: "showIsFullScreen"; type: "bool" } Signal { name: "openUrl" @@ -371,7 +368,7 @@ Module { } Component { name: "QWaylandWlShell" - prototype: "QWaylandExtension" + prototype: "QWaylandCompositorExtension" Signal { name: "createShellSurface" Parameter { name: "surface"; type: "QWaylandSurface"; isPointer: true } @@ -392,7 +389,7 @@ Module { } Component { name: "QWaylandWlShellSurface" - prototype: "QWaylandExtension" + prototype: "QWaylandShellSurface" exports: [ "QtWayland.Compositor/WlShellSurface 1.0", "QtWayland.Compositor/WlShellSurfaceBase 1.0" @@ -489,7 +486,7 @@ Module { } Component { name: "QWaylandXdgShell" - prototype: "QWaylandExtension" + prototype: "QWaylandCompositorExtension" Signal { name: "createXdgSurface" Parameter { name: "surface"; type: "QWaylandSurface"; isPointer: true } @@ -532,7 +529,7 @@ Module { } Component { name: "QWaylandXdgSurface" - prototype: "QWaylandExtension" + prototype: "QWaylandShellSurface" exports: [ "QtWayland.Compositor/XdgSurface 1.0", "QtWayland.Compositor/XdgSurfaceBase 1.0" diff --git a/src/imports/compositor/qwaylandmousetracker.cpp b/src/imports/compositor/qwaylandmousetracker.cpp index fd6a591e..a77d6b1a 100644 --- a/src/imports/compositor/qwaylandmousetracker.cpp +++ b/src/imports/compositor/qwaylandmousetracker.cpp @@ -46,6 +46,7 @@ class QWaylandMouseTrackerPrivate : public QQuickItemPrivate public: QWaylandMouseTrackerPrivate() : enableWSCursor(false) + , hovered(false) { QImage cursorImage(64,64,QImage::Format_ARGB32); cursorImage.fill(Qt::transparent); @@ -65,9 +66,19 @@ public: } } + void setHovered(bool hovered) + { + Q_Q(QWaylandMouseTracker); + if (this->hovered == hovered) + return; + this->hovered = hovered; + emit q->hoveredChanged(); + } + QPointF mousePos; bool enableWSCursor; QPixmap cursorPixmap; + bool hovered; }; QWaylandMouseTracker::QWaylandMouseTracker(QQuickItem *parent) @@ -76,6 +87,7 @@ QWaylandMouseTracker::QWaylandMouseTracker(QQuickItem *parent) Q_D(QWaylandMouseTracker); setFiltersChildMouseEvents(true); setAcceptHoverEvents(true); + setAcceptedMouseButtons(Qt::AllButtons); setCursor(QCursor(d->cursorPixmap)); } @@ -110,6 +122,12 @@ bool QWaylandMouseTracker::enableWSCursor() const return d->enableWSCursor; } +bool QWaylandMouseTracker::hovered() const +{ + Q_D(const QWaylandMouseTracker); + return d->hovered; +} + bool QWaylandMouseTracker::childMouseEventFilter(QQuickItem *item, QEvent *event) { Q_D(QWaylandMouseTracker); @@ -137,4 +155,18 @@ void QWaylandMouseTracker::hoverMoveEvent(QHoverEvent *event) d->handleMousePos(event->posF()); } +void QWaylandMouseTracker::hoverEnterEvent(QHoverEvent *event) +{ + Q_D(QWaylandMouseTracker); + Q_UNUSED(event); + d->setHovered(true); +} + +void QWaylandMouseTracker::hoverLeaveEvent(QHoverEvent *event) +{ + Q_D(QWaylandMouseTracker); + Q_UNUSED(event); + d->setHovered(false); +} + QT_END_NAMESPACE diff --git a/src/imports/compositor/qwaylandmousetracker_p.h b/src/imports/compositor/qwaylandmousetracker_p.h index 2cc8798b..1bc37a5e 100644 --- a/src/imports/compositor/qwaylandmousetracker_p.h +++ b/src/imports/compositor/qwaylandmousetracker_p.h @@ -51,6 +51,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandMouseTracker : public QQuickItem Q_DECLARE_PRIVATE(QWaylandMouseTracker) Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mouseXChanged) Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mouseYChanged) + Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged) Q_PROPERTY(bool enableWSCursor READ enableWSCursor WRITE setEnableWSCursor NOTIFY enableWSCursorChanged) public: @@ -61,15 +62,20 @@ public: void setEnableWSCursor(bool enable); bool enableWSCursor() const; + bool hovered() const; + signals: void mouseXChanged(); void mouseYChanged(); void enableWSCursorChanged(); + void hoveredChanged(); protected: bool childMouseEventFilter(QQuickItem *item, QEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; }; QT_END_NAMESPACE diff --git a/src/imports/compositor/qwaylandquickcompositorplugin.cpp b/src/imports/compositor/qwaylandquickcompositorplugin.cpp index ae4f874d..6f00351c 100644 --- a/src/imports/compositor/qwaylandquickcompositorplugin.cpp +++ b/src/imports/compositor/qwaylandquickcompositorplugin.cpp @@ -44,11 +44,10 @@ #include <QtWaylandCompositor/QWaylandQuickSurface> #include <QtWaylandCompositor/QWaylandClient> #include <QtWaylandCompositor/QWaylandQuickOutput> -#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtWaylandCompositor/QWaylandQuickExtension> #include <QtWaylandCompositor/QWaylandInputDevice> -#include <QtWaylandCompositor/QWaylandQuickWlShellSurfaceItem> -#include <QtWaylandCompositor/QWaylandQuickXdgSurfaceItem> +#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem> #include <QtWaylandCompositor/QWaylandResource> #include <QtWaylandCompositor/QWaylandWindowManagerExtension> @@ -135,12 +134,13 @@ public: 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<QWaylandCompositorExtension>(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, "ShellSurface", QObject::tr("Cannot create instance of ShellSurface")); 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")); @@ -149,10 +149,9 @@ public: qmlRegisterType<QWaylandWindowManagerExtensionQuickExtension>(uri, 1, 0, "WindowManager"); qmlRegisterType<QWaylandWlShellQuickExtension>(uri, 1, 0, "WlShell"); qmlRegisterType<QWaylandWlShellSurface>(uri, 1, 0, "WlShellSurface"); - qmlRegisterType<QWaylandQuickWlShellSurfaceItem>(uri, 1, 0, "WlShellSurfaceItem"); + qmlRegisterType<QWaylandQuickShellSurfaceItem>(uri, 1, 0, "ShellSurfaceItem"); qmlRegisterType<QWaylandXdgShellQuickExtension>(uri, 1, 0, "XdgShell"); qmlRegisterType<QWaylandXdgSurface>(uri, 1, 0, "XdgSurface"); - qmlRegisterType<QWaylandQuickXdgSurfaceItem>(uri, 1, 0, "XdgSurfaceItem"); qmlRegisterType<QWaylandTextInputManagerQuickExtension>(uri, 1, 0, "TextInputManager"); } }; |