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