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_p.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 QWAYLANDQUICKITEM_P_H
6#define QWAYLANDQUICKITEM_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuick/private/qquickitem_p.h>
20#include <QtQuick/QSGMaterialShader>
21#include <QtQuick/QSGMaterial>
22
23#include <QtWaylandCompositor/QWaylandQuickItem>
24#include <QtWaylandCompositor/QWaylandOutput>
25
26#include <QtCore/qpointer.h>
27
29
31class QMutex;
32class QOpenGLTexture;
33
34#if QT_CONFIG(opengl)
35class QWaylandBufferMaterialShader : public QSGMaterialShader
36{
37public:
38 QWaylandBufferMaterialShader(QWaylandBufferRef::BufferFormatEgl format);
39
40 bool updateUniformData(RenderState &state,
41 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
42 void updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
43 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
44 void setupExternalOESShader(const QString &shaderFilename);
45};
46
47class QWaylandBufferMaterial : public QSGMaterial
48{
49public:
50 QWaylandBufferMaterial(QWaylandBufferRef::BufferFormatEgl format);
51 ~QWaylandBufferMaterial() override;
52
53 void setTextureForPlane(int plane, QOpenGLTexture *texture, QSGTexture *scenegraphTexture);
54 void setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &ref);
55
56 void bind();
57 void updateScenegraphTextures(QRhi *rhi);
58
59 QSGMaterialType *type() const override;
60 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
61
62private:
63 friend QWaylandBufferMaterialShader;
64
65 void setTextureParameters(GLenum target);
66 void ensureTextures(int count);
67
68 const QWaylandBufferRef::BufferFormatEgl m_format;
69 QVarLengthArray<QOpenGLTexture*, 3> m_textures;
70 QVarLengthArray<QSGTexture*, 3> m_scenegraphTextures;
71 QWaylandBufferRef m_bufferRef;
72};
73#endif // QT_CONFIG(opengl)
74
76{
77 Q_DECLARE_PUBLIC(QWaylandQuickItem)
78public:
80
81 void init()
82 {
83 Q_Q(QWaylandQuickItem);
84 if (!mutex)
85 mutex = new QMutex;
86
87 view.reset(new QWaylandView(q));
88 q->setFlag(QQuickItem::ItemHasContents);
89
90 q->update();
91
92 q->setSmooth(true);
93
95 QObject::connect(q, &QQuickItem::windowChanged, q, &QWaylandQuickItem::updateWindow);
96 QObject::connect(view.data(), &QWaylandView::surfaceChanged, q, &QWaylandQuickItem::surfaceChanged);
97 QObject::connect(view.data(), &QWaylandView::surfaceChanged, q, &QWaylandQuickItem::handleSurfaceChanged);
98 QObject::connect(view.data(), &QWaylandView::surfaceDestroyed, q, &QWaylandQuickItem::surfaceDestroyed);
99 QObject::connect(view.data(), &QWaylandView::outputChanged, q, &QWaylandQuickItem::outputChanged);
100 QObject::connect(view.data(), &QWaylandView::outputChanged, q, &QWaylandQuickItem::updateOutput);
101 QObject::connect(view.data(), &QWaylandView::bufferLockedChanged, q, &QWaylandQuickItem::bufferLockedChanged);
102 QObject::connect(view.data(), &QWaylandView::bufferLockedChanged, q, &QWaylandQuickItem::handleBufferLockedChanged);
103 QObject::connect(view.data(), &QWaylandView::allowDiscardFrontBufferChanged, q, &QWaylandQuickItem::allowDiscardFrontBufferChanged);
104
105 q->updateWindow();
106 }
107
108 static const QWaylandQuickItemPrivate* get(const QWaylandQuickItem *item) { return item->d_func(); }
109
110 void setInputEventsEnabled(bool enable)
111 {
112 Q_Q(QWaylandQuickItem);
113 q->setAcceptedMouseButtons(enable ? (Qt::LeftButton | Qt::MiddleButton | Qt::RightButton |
114 Qt::ExtraButton1 | Qt::ExtraButton2 | Qt::ExtraButton3 | Qt::ExtraButton4 |
115 Qt::ExtraButton5 | Qt::ExtraButton6 | Qt::ExtraButton7 | Qt::ExtraButton8 |
116 Qt::ExtraButton9 | Qt::ExtraButton10 | Qt::ExtraButton11 |
117 Qt::ExtraButton12 | Qt::ExtraButton13) : Qt::NoButton);
118 q->setAcceptTouchEvents(enable);
119 q->setAcceptHoverEvents(enable);
120 inputEventsEnabled = enable;
121 }
122
123 void handleDragEnded(QWaylandSeat *seat);
124 void handleDragUpdate(QWaylandSeat *seat, const QPointF &globalPosition);
125
126 bool shouldSendInputEvents() const { return view->surface() && inputEventsEnabled; }
127 qreal scaleFactor() const;
128
129 QWaylandQuickItem *findSibling(QWaylandSurface *surface) const;
130 void placeAboveSibling(QWaylandQuickItem *sibling);
131 void placeBelowSibling(QWaylandQuickItem *sibling);
132 void placeAboveParent();
133 void placeBelowParent();
134
135 virtual void raise();
136 virtual void lower();
137
138 static QMutex *mutex;
139
144 bool paintEnabled = true;
147 bool isDragging = false;
148 bool newTexture = false;
149 bool focusOnClick = true;
150 bool belowParent = false;
151#if QT_CONFIG(opengl)
152 bool paintByProvider = false;
153#endif
156
162};
163
164QT_END_NAMESPACE
165
166#endif /*QWAYLANDQUICKITEM_P_H*/
QWaylandQuickItem * findSibling(QWaylandSurface *surface) const
void setInputEventsEnabled(bool enable)
QWaylandSurface::Origin origin
QScopedPointer< QWaylandView > view
QPointer< QObject > subsurfaceHandler
QMetaObject::Connection texProviderConnection
void placeBelowSibling(QWaylandQuickItem *sibling)
void placeAboveSibling(QWaylandQuickItem *sibling)
QWaylandSurfaceTextureProvider * provider
QList< QWaylandSeat * > touchingSeats
static const QWaylandQuickItemPrivate * get(const QWaylandQuickItem *item)
QPointer< QWaylandSurface > oldSurface
QSGTexture * texture() const override
Returns a pointer to the texture object.
void setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &buffer)
Combined button and popup list for selecting options.