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