Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandquickitem.h
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QWAYLANDSURFACEITEM_H
6#define QWAYLANDSURFACEITEM_H
7
8#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
9
10#include <QtQuick/QQuickItem>
11#include <QtQuick/qsgtexture.h>
12
13#include <QtQuick/qsgtextureprovider.h>
14
15#include <QtWaylandCompositor/qwaylandview.h>
16#include <QtWaylandCompositor/qwaylandquicksurface.h>
17
18Q_DECLARE_METATYPE(QWaylandQuickSurface*)
19
20QT_REQUIRE_CONFIG(wayland_compositor_quick);
21
22QT_BEGIN_NAMESPACE
23
24class QWaylandSeat;
26
27class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem
28{
29 Q_OBJECT
30 Q_DECLARE_PRIVATE(QWaylandQuickItem)
31 Q_PROPERTY(QWaylandCompositor *compositor READ compositor NOTIFY compositorChanged)
32 Q_PROPERTY(QWaylandSurface *surface READ surface WRITE setSurface NOTIFY surfaceChanged)
33 Q_PROPERTY(bool paintEnabled READ isPaintEnabled WRITE setPaintEnabled NOTIFY paintEnabledChanged)
34 Q_PROPERTY(bool touchEventsEnabled READ touchEventsEnabled WRITE setTouchEventsEnabled NOTIFY touchEventsEnabledChanged)
35 Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged)
36 Q_PROPERTY(bool inputEventsEnabled READ inputEventsEnabled WRITE setInputEventsEnabled NOTIFY inputEventsEnabledChanged)
37 Q_PROPERTY(bool focusOnClick READ focusOnClick WRITE setFocusOnClick NOTIFY focusOnClickChanged)
38 Q_PROPERTY(QObject *subsurfaceHandler READ subsurfaceHandler WRITE setSubsurfaceHandler NOTIFY subsurfaceHandlerChanged)
39 Q_PROPERTY(QWaylandOutput *output READ output WRITE setOutput NOTIFY outputChanged)
40 Q_PROPERTY(bool bufferLocked READ isBufferLocked WRITE setBufferLocked NOTIFY bufferLockedChanged)
41 Q_PROPERTY(bool allowDiscardFrontBuffer READ allowDiscardFrontBuffer WRITE setAllowDiscardFrontBuffer NOTIFY allowDiscardFrontBufferChanged)
42 Q_MOC_INCLUDE("qwaylandcompositor.h")
43 Q_MOC_INCLUDE("qwaylandseat.h")
44 Q_MOC_INCLUDE("qwaylanddrag.h")
45 QML_NAMED_ELEMENT(WaylandQuickItem)
46 QML_ADDED_IN_VERSION(1, 0)
47public:
48 QWaylandQuickItem(QQuickItem *parent = nullptr);
49 ~QWaylandQuickItem() override;
50
51 QWaylandCompositor *compositor() const;
52 QWaylandView *view() const;
53
54 QWaylandSurface *surface() const;
55 void setSurface(QWaylandSurface *surface);
56
57 QWaylandSurface::Origin origin() const;
58
59 bool isTextureProvider() const override;
60 QSGTextureProvider *textureProvider() const override;
61
62 bool isPaintEnabled() const;
63 bool touchEventsEnabled() const;
64
65 void setTouchEventsEnabled(bool enabled);
66
67 bool inputEventsEnabled() const;
68 void setInputEventsEnabled(bool enabled);
69
70 bool focusOnClick() const;
71 void setFocusOnClick(bool focus);
72
73 bool inputRegionContains(const QPointF &localPosition) const;
74 Q_INVOKABLE QPointF mapToSurface(const QPointF &point) const;
75 Q_REVISION(1, 13) Q_INVOKABLE QPointF mapFromSurface(const QPointF &point) const;
76
77#if QT_CONFIG(im)
78 QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
79 Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
80#endif
81
82 QObject *subsurfaceHandler() const;
83 void setSubsurfaceHandler(QObject*);
84
85 QWaylandOutput *output() const;
86 void setOutput(QWaylandOutput *output);
87
88 bool isBufferLocked() const;
89 void setBufferLocked(bool locked);
90
91 bool allowDiscardFrontBuffer() const;
92 void setAllowDiscardFrontBuffer(bool discard);
93
94 Q_INVOKABLE void setPrimary();
95
96protected:
97 void mousePressEvent(QMouseEvent *event) override;
98 void mouseMoveEvent(QMouseEvent *event) override;
99 void mouseReleaseEvent(QMouseEvent *event) override;
100 void hoverEnterEvent(QHoverEvent *event) override;
101 void hoverMoveEvent(QHoverEvent *event) override;
102 void hoverLeaveEvent(QHoverEvent *event) override;
103#if QT_CONFIG(wheelevent)
104 void wheelEvent(QWheelEvent *event) override;
105#endif
106
107 void keyPressEvent(QKeyEvent *event) override;
108 void keyReleaseEvent(QKeyEvent *event) override;
109
110 void touchEvent(QTouchEvent *event) override;
111 void touchUngrabEvent() override;
112
113#if QT_CONFIG(im)
114 void inputMethodEvent(QInputMethodEvent *event) override;
115#endif
116
117 virtual void surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface);
118public Q_SLOTS:
119 virtual void takeFocus(QWaylandSeat *device = nullptr);
120 void setPaintEnabled(bool paintEnabled);
121 void raise();
122 void lower();
123 void sendMouseMoveEvent(const QPointF &position, QWaylandSeat *seat = nullptr);
124
125#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
126private Q_SLOTS:
127 void surfaceMappedChanged();
128#else
129private:
130#endif
131 void handleSurfaceChanged();
132 void handleBufferLockedChanged();
133 void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent);
134 void updateSize();
135 void updateBuffer(bool hasBuffer);
136 void updateWindow();
137 void updateOutput();
138 void beforeSync();
139 void handleSubsurfaceAdded(QWaylandSurface *childSurface);
140 void handleSubsurfacePosition(const QPoint &pos);
141 void handlePlaceAbove(QWaylandSurface *referenceSurface);
142 void handlePlaceBelow(QWaylandSurface *referenceSurface);
143#if QT_CONFIG(draganddrop)
144 void handleDragStarted(QWaylandDrag *drag);
145#endif
146#if QT_CONFIG(im)
147 void updateInputMethod(Qt::InputMethodQueries queries);
148#endif
149 void updateFocus();
150
151Q_SIGNALS:
152 void surfaceChanged();
153 void compositorChanged();
154 void paintEnabledChanged();
155 void touchEventsEnabledChanged();
156 void originChanged();
157 void surfaceDestroyed();
158 void inputEventsEnabledChanged();
159 void focusOnClickChanged();
160 void mouseMove(const QPointF &windowPosition);
161 void mouseRelease();
162 void subsurfaceHandlerChanged();
163 void outputChanged();
164 void bufferLockedChanged();
165 void allowDiscardFrontBufferChanged();
166protected:
167 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override;
168
169 QWaylandQuickItem(QWaylandQuickItemPrivate &dd, QQuickItem *parent = nullptr);
170};
171
172QT_END_NAMESPACE
173
174#endif
QWaylandSurface * createDefaultSurface() override
QWaylandQuickCompositorPrivate(QWaylandCompositor *compositor)
\qmltype WaylandQuickItem \nativetype QWaylandQuickItem \inqmlmodule QtWayland.Compositor
Combined button and popup list for selecting options.
QT_REQUIRE_CONFIG(animation)
QT_REQUIRE_CONFIG(liburing)
QT_END_NAMESPACE Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::kit::ShareKit::systemShare::SelectionMode))
QT_REQUIRE_CONFIG(wayland_compositor_quick)