Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwaylandquickitem.cpp
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#include "qwaylandquickitem.h"
8#include "qwaylandtextinput.h"
11#include "qwaylandquickoutput.h"
12#include <QtWaylandCompositor/qwaylandcompositor.h>
13#include <QtWaylandCompositor/qwaylandseat.h>
14#include <QtWaylandCompositor/qwaylandbufferref.h>
15#if QT_CONFIG(draganddrop)
16#include <QtWaylandCompositor/QWaylandDrag>
17#endif
18#include <QtWaylandCompositor/private/qwlclientbufferintegration_p.h>
19#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
20
21#if QT_CONFIG(opengl)
22# include <QtOpenGL/QOpenGLTexture>
23# include <QtGui/QOpenGLFunctions>
24#endif
25
26#include <QtGui/QKeyEvent>
27#include <QtGui/QGuiApplication>
28#include <QtGui/QScreen>
29
30#include <QtQuick/QSGSimpleTextureNode>
31#include <QtQuick/QQuickWindow>
32#include <QtQuick/qsgtexture.h>
33
34#include <QtCore/QFile>
35#include <QtCore/QMutexLocker>
36#include <QtCore/QMutex>
37
38#include <wayland-server-core.h>
39#include <QThread>
40
41#if QT_CONFIG(opengl)
42#include <QtGui/private/qshaderdescription_p.h>
43#endif
44
45#ifndef GL_TEXTURE_EXTERNAL_OES
46#define GL_TEXTURE_EXTERNAL_OES 0x8D65
47#endif
48
50
51#if QT_CONFIG(opengl)
52static const struct {
53 const char * const vertexShaderSourceFile;
54 const char * const fragmentShaderSourceFile;
55 int planeCount;
56 bool canProvideTexture;
57 QSGMaterial::Flags materialFlags;
58 QSGMaterialType materialType;
59} bufferTypes[] = {
60 // BufferFormatEgl_Null
61 { "", "", 0, false, {}, {} },
62
63 // BufferFormatEgl_RGB (GL_TEXTURE_2D)
64 {
65 ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
66 ":/qt-project.org/wayland/compositor/shaders/surface_rgbx.frag.qsb",
67 1, true,
69 {}
70 },
71
72 // BufferFormatEgl_RGBA (GL_TEXTURE_2D)
73 {
74 ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
75 ":/qt-project.org/wayland/compositor/shaders/surface_rgba.frag.qsb",
76 1, true,
78 {}
79 },
80
81 // BufferFormatEgl_EXTERNAL_OES (GL_TEXTURE_EXTERNAL_OES)
82 {
83 ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
84 ":/qt-project.org/wayland/compositor/shaders/surface_oes_external.frag",
85 1, false,
87 {}
88 },
89
90 // BufferFormatEgl_Y_U_V (GL_TEXTURE_2D)
91 {
92 ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
93 ":/qt-project.org/wayland/compositor/shaders/surface_y_u_v.frag.qsb",
94 3, false,
96 {}
97 },
98
99 // BufferFormatEgl_Y_UV (GL_TEXTURE_2D)
100 {
101 ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
102 ":/qt-project.org/wayland/compositor/shaders/surface_y_uv.frag.qsb",
103 2, false,
105 {}
106 },
107
108 // BufferFormatEgl_Y_XUXV (GL_TEXTURE_2D)
109 {
110 ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
111 ":/qt-project.org/wayland/compositor/shaders/surface_y_xuxv.frag.qsb",
112 2, false,
114 {}
115 }
116};
117
118QWaylandBufferMaterialShader::QWaylandBufferMaterialShader(QWaylandBufferRef::BufferFormatEgl format)
119{
121 setShaderFileName(VertexStage, QString::fromLatin1(bufferTypes[format].vertexShaderSourceFile));
122 auto fragmentShaderSourceFile = QString::fromLatin1(bufferTypes[format].fragmentShaderSourceFile);
123
125 setupExternalOESShader(fragmentShaderSourceFile);
126 else
127 setShaderFileName(FragmentStage, fragmentShaderSourceFile);
128}
129
130void QWaylandBufferMaterialShader::setupExternalOESShader(const QString &shaderFilename)
131{
132#if QT_CONFIG(opengl)
133 QFile shaderFile(shaderFilename);
134 if (!shaderFile.open(QIODevice::ReadOnly)) {
135 qCWarning(qLcWaylandCompositor) << "Cannot find external OES shader file:" << shaderFilename;
136 return;
137 }
138 QByteArray FS = shaderFile.readAll();
139
140 static const char *FS_GLES_PREAMBLE =
141 "#extension GL_OES_EGL_image_external : require\n"
142 "precision highp float;\n";
143 static const char *FS_GL_PREAMBLE =
144 "#version 120\n"
145 "#extension GL_OES_EGL_image_external : require\n";
146 QByteArray fsGLES = FS_GLES_PREAMBLE + FS;
147 QByteArray fsGL = FS_GL_PREAMBLE + FS;
148
151
153 texCoordInput.name = "v_texcoord";
154 texCoordInput.type = QShaderDescription::Vec2;
155 texCoordInput.location = 0;
156
157 descData->inVars = { texCoordInput };
158
159 QShaderDescription::InOutVariable fragColorOutput;
160 fragColorOutput.name = "gl_FragColor";
161 fragColorOutput.type = QShaderDescription::Vec4;
162 fragColorOutput.location = 0;
163
164 descData->outVars = { fragColorOutput };
165
167 matrixBlockVar.name = "qt_Matrix";
168 matrixBlockVar.type = QShaderDescription::Mat4;
169 matrixBlockVar.offset = 0;
170 matrixBlockVar.size = 64;
171
172 QShaderDescription::BlockVariable opacityBlockVar;
173 opacityBlockVar.name = "qt_Opacity";
174 opacityBlockVar.type = QShaderDescription::Float;
175 opacityBlockVar.offset = 64;
176 opacityBlockVar.size = 4;
177
179 ubufStruct.blockName = "buf";
180 ubufStruct.structName = "ubuf";
181 ubufStruct.size = 64 + 4;
182 ubufStruct.binding = 0;
183 ubufStruct.members = { matrixBlockVar, opacityBlockVar };
184
185 descData->uniformBlocks = { ubufStruct };
186
188 samplerTex0.name = "tex0";
190 samplerTex0.binding = 1;
191
192 descData->combinedImageSamplers = { samplerTex0 };
193
194 QShader shaderPack;
196 shaderPack.setDescription(desc);
198 shaderPack.setShader(QShaderKey(QShader::GlslShader, QShaderVersion(120)), QShaderCode(fsGL));
199
200 setShader(FragmentStage, shaderPack);
201#else
202 Q_UNUSED(shaderFilename);
203#endif
204}
205
206bool QWaylandBufferMaterialShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *)
207{
208 bool changed = false;
209 QByteArray *buf = state.uniformData();
210 Q_ASSERT(buf->size() >= 68);
211
212 if (state.isMatrixDirty()) {
213 const QMatrix4x4 m = state.combinedMatrix();
214 memcpy(buf->data(), m.constData(), 64);
215 changed = true;
216 }
217
218 if (state.isOpacityDirty()) {
219 const float opacity = state.opacity();
220 memcpy(buf->data() + 64, &opacity, 4);
221 changed = true;
222 }
223
224 return changed;
225}
226
227void QWaylandBufferMaterialShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
228 QSGMaterial *newMaterial, QSGMaterial *)
229{
231
232 QWaylandBufferMaterial *material = static_cast<QWaylandBufferMaterial *>(newMaterial);
233 switch (binding) {
234 case 1:
235 *texture = material->m_scenegraphTextures.at(0);
236 break;
237 case 2:
238 *texture = material->m_scenegraphTextures.at(1);
239 break;
240 case 3:
241 *texture = material->m_scenegraphTextures.at(2);
242 break;
243 default:
244 return;
245 }
246
247 // This is for the shared memory case, and is a no-op for others,
248 // this is where the upload from the QImage happens when not yet done.
249 // ### or is this too late? (if buffer.image() disappears in the meantime then this is the wrong...)
250 if (*texture)
251 (*texture)->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
252}
253
254QWaylandBufferMaterial::QWaylandBufferMaterial(QWaylandBufferRef::BufferFormatEgl format)
255 : m_format(format)
256{
257 setFlag(bufferTypes[m_format].materialFlags);
258}
259
260QWaylandBufferMaterial::~QWaylandBufferMaterial()
261{
262 qDeleteAll(m_scenegraphTextures);
263}
264
265void QWaylandBufferMaterial::setTextureForPlane(int plane,
267 QSGTexture *scenegraphTexture)
268{
269 if (plane < 0 || plane >= bufferTypes[m_format].planeCount) {
270 qWarning("plane index is out of range");
271 return;
272 }
273
274 texture->bind();
275 setTextureParameters(texture->target());
276
277 ensureTextures(plane - 1);
278
279 if (m_textures.size() <= plane) {
280 m_textures << texture;
281 m_scenegraphTextures << scenegraphTexture;
282 } else {
283 delete m_scenegraphTextures[plane];
284
285 m_textures[plane] = texture;
286 m_scenegraphTextures[plane] = scenegraphTexture;
287 }
288}
289
290void QWaylandBufferMaterial::bind()
291{
292 ensureTextures(bufferTypes[m_format].planeCount);
293
294 switch (m_textures.size()) {
295 case 3:
296 if (m_textures[2])
297 m_textures[2]->bind(2);
299 case 2:
300 if (m_textures[1])
301 m_textures[1]->bind(1);
303 case 1:
304 if (m_textures[0])
305 m_textures[0]->bind(0);
306 }
307}
308
309QSGMaterialType *QWaylandBufferMaterial::type() const
310{
311 return const_cast<QSGMaterialType *>(&bufferTypes[m_format].materialType);
312}
313
314QSGMaterialShader *QWaylandBufferMaterial::createShader(QSGRendererInterface::RenderMode renderMode) const
315{
316 Q_UNUSED(renderMode);
317 return new QWaylandBufferMaterialShader(m_format);
318}
319
320
321void QWaylandBufferMaterial::setTextureParameters(GLenum target)
322{
324 gl->glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
325 gl->glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
326 gl->glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
327 gl->glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
328}
329
330//TODO move this into a separate centralized texture management class
331void QWaylandBufferMaterial::ensureTextures(int count)
332{
333 for (int plane = m_textures.size(); plane < count; plane++) {
334 m_textures << nullptr;
335 m_scenegraphTextures << nullptr;
336 }
337}
338
339void QWaylandBufferMaterial::setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &ref)
340{
341 m_bufferRef = ref;
342 for (int plane = 0; plane < bufferTypes[ref.bufferFormatEgl()].planeCount; plane++) {
343 if (auto texture = ref.toOpenGLTexture(plane)) {
344 QQuickWindow::CreateTextureOptions opt;
345 QWaylandQuickSurface *waylandSurface = qobject_cast<QWaylandQuickSurface *>(surfaceItem->surface());
346 if (waylandSurface != nullptr && waylandSurface->useTextureAlpha() && !waylandSurface->isOpaque())
347 opt |= QQuickWindow::TextureHasAlphaChannel;
348 QSGTexture *scenegraphTexture;
349 if (ref.bufferFormatEgl() == QWaylandBufferRef::BufferFormatEgl_EXTERNAL_OES) {
350 scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNativeExternalOES(texture->textureId(),
351 surfaceItem->window(),
352 ref.size(),
353 opt);
354 } else {
355 scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNative(texture->textureId(),
356 surfaceItem->window(),
357 ref.size(),
358 opt);
359 }
360 scenegraphTexture->setFiltering(surfaceItem->smooth() ? QSGTexture::Linear : QSGTexture::Nearest);
361 setTextureForPlane(plane, texture, scenegraphTexture);
362 }
363 }
364
365 bind();
366}
367#endif // QT_CONFIG(opengl)
368
370
372{
373public:
377
379 {
380 delete m_sgTex;
381 }
382
384 {
385 Q_ASSERT(QThread::currentThread() == thread());
386 m_ref = buffer;
387 delete m_sgTex;
388 m_sgTex = nullptr;
389 if (m_ref.hasBuffer()) {
390 if (buffer.isSharedMemory()) {
391 m_sgTex = surfaceItem->window()->createTextureFromImage(buffer.image());
392 } else {
393#if QT_CONFIG(opengl)
394 QQuickWindow::CreateTextureOptions opt;
395 QWaylandQuickSurface *surface = qobject_cast<QWaylandQuickSurface *>(surfaceItem->surface());
396 if (surface && surface->useTextureAlpha() && !surface->isOpaque()) {
397 opt |= QQuickWindow::TextureHasAlphaChannel;
398 }
399
400 auto texture = buffer.toOpenGLTexture();
401 GLuint textureId = texture->textureId();
402 auto size = surface->bufferSize();
403 m_sgTex = QNativeInterface::QSGOpenGLTexture::fromNative(textureId, surfaceItem->window(), size, opt);
404#else
405 qCWarning(qLcWaylandCompositor) << "Without OpenGL support only shared memory textures are supported";
406#endif
407 }
408 }
409 emit textureChanged();
410 }
411
412 QSGTexture *texture() const override
413 {
414 if (m_sgTex)
416 return m_sgTex;
417 }
418
419 void setSmooth(bool smooth) { m_smooth = smooth; }
420private:
421 bool m_smooth = false;
422 QSGTexture *m_sgTex = nullptr;
423 QWaylandBufferRef m_ref;
424};
425
456
461 : QQuickItem(dd, parent)
462{
463 d_func()->init();
464 connect(this, &QQuickItem::activeFocusChanged, this, &QWaylandQuickItem::updateFocus);
465}
466
471{
473 disconnect(this, &QQuickItem::windowChanged, this, &QWaylandQuickItem::updateWindow);
474 disconnect(this, &QQuickItem::activeFocusChanged, this, &QWaylandQuickItem::updateFocus);
475 QMutexLocker locker(d->mutex);
476 if (d->provider) {
477 disconnect(d->texProviderConnection);
478 d->provider->deleteLater();
479 }
480}
481
494{
495 Q_D(const QWaylandQuickItem);
496 return d->view->surface() ? d->view->surface()->compositor() : nullptr;
497}
498
503{
504 Q_D(const QWaylandQuickItem);
505 return d->view.data();
506}
507
521{
522 Q_D(const QWaylandQuickItem);
523 return d->view->surface();
524}
525
527{
529 QWaylandSurface *oldSurf = d->view->surface();
530 QWaylandCompositor *oldComp = d->view->surface() ? d->view->surface()->compositor() : nullptr;
531 d->view->setSurface(surface);
532 QWaylandCompositor *newComp = d->view->surface() ? d->view->surface()->compositor() : nullptr;
533 if (oldComp != newComp)
535 if (oldSurf != surface)
537
538 updateFocus();
539 update();
540}
541
554{
555 Q_D(const QWaylandQuickItem);
556 return d->origin;
557}
558
560{
561 Q_D(const QWaylandQuickItem);
562 return QQuickItem::isTextureProvider() || d->provider;
563}
564
569{
570 Q_D(const QWaylandQuickItem);
571
574
575 return d->provider;
576}
577
582{
584 if (!d->shouldSendInputEvents()) {
585 event->ignore();
586 return;
587 }
588
589 if (!inputRegionContains(event->position())) {
590 event->ignore();
591 return;
592 }
593
594 QWaylandSeat *seat = compositor()->seatFor(event);
595
596 if (d->focusOnClick)
597 takeFocus(seat);
598
599 seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), event->scenePosition());
600 seat->sendMousePressEvent(event->button());
601 d->hoverPos = event->position();
602}
603
608{
610 if (d->shouldSendInputEvents()) {
611 QWaylandSeat *seat = compositor()->seatFor(event);
612#if QT_CONFIG(draganddrop)
613 if (d->isDragging) {
614 QWaylandQuickOutput *currentOutput = qobject_cast<QWaylandQuickOutput *>(view()->output());
615 //TODO: also check if dragging onto other outputs
616 QWaylandQuickItem *targetItem = qobject_cast<QWaylandQuickItem *>(currentOutput->pickClickableItem(mapToScene(event->position())));
617 QWaylandSurface *targetSurface = targetItem ? targetItem->surface() : nullptr;
618 if (targetSurface) {
619 QPointF position = mapToItem(targetItem, event->position());
620 QPointF surfacePosition = targetItem->mapToSurface(position);
621 seat->drag()->dragMove(targetSurface, surfacePosition);
622 }
623 } else
624#endif // QT_CONFIG(draganddrop)
625 {
626 seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), event->scenePosition());
627 d->hoverPos = event->position();
628 }
629 } else {
630 emit mouseMove(event->scenePosition());
631 event->ignore();
632 }
633}
634
639{
641 if (d->shouldSendInputEvents()) {
642 QWaylandSeat *seat = compositor()->seatFor(event);
643#if QT_CONFIG(draganddrop)
644 if (d->isDragging) {
645 d->isDragging = false;
646 seat->drag()->drop();
647 } else
648#endif
649 {
650 seat->sendMouseReleaseEvent(event->button());
651 }
652 } else {
654 event->ignore();
655 }
656}
657
662{
664 if (!inputRegionContains(event->position())) {
665 event->ignore();
666 return;
667 }
668 if (d->shouldSendInputEvents()) {
669 QWaylandSeat *seat = compositor()->seatFor(event);
670 seat->sendMouseMoveEvent(d->view.data(), event->position(), mapToScene(event->position()));
671 d->hoverPos = event->position();
672 } else {
673 event->ignore();
674 }
675}
676
681{
683 if (surface()) {
684 if (!inputRegionContains(event->position())) {
685 event->ignore();
686 return;
687 }
688 }
689 if (d->shouldSendInputEvents()) {
690 QWaylandSeat *seat = compositor()->seatFor(event);
691 if (event->position() != d->hoverPos) {
692 seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), mapToScene(event->position()));
693 d->hoverPos = event->position();
694 }
695 } else {
696 event->ignore();
697 }
698}
699
704{
706 if (d->shouldSendInputEvents()) {
707 QWaylandSeat *seat = compositor()->seatFor(event);
708 seat->setMouseFocus(nullptr);
709 } else {
710 event->ignore();
711 }
712}
713
714#if QT_CONFIG(wheelevent)
718void QWaylandQuickItem::wheelEvent(QWheelEvent *event)
719{
721 if (d->shouldSendInputEvents()) {
722 if (!inputRegionContains(event->position())) {
723 event->ignore();
724 return;
725 }
726
727 QWaylandSeat *seat = compositor()->seatFor(event);
728 // TODO: fix this to send a single event, when diagonal scrolling is supported
729 if (event->angleDelta().x() != 0)
730 seat->sendMouseWheelEvent(Qt::Horizontal, event->angleDelta().x());
731 if (event->angleDelta().y() != 0)
732 seat->sendMouseWheelEvent(Qt::Vertical, event->angleDelta().y());
733 } else {
734 event->ignore();
735 }
736}
737#endif
738
743{
745 if (d->shouldSendInputEvents()) {
746 QWaylandSeat *seat = compositor()->seatFor(event);
747 if (seat->setKeyboardFocus(d->view->surface()))
748 seat->sendFullKeyEvent(event);
749 else
750 qWarning() << "Unable to set keyboard focus, cannot send key press event";
751 } else {
752 event->ignore();
753 }
754}
755
760{
762 if (d->shouldSendInputEvents()) {
763 QWaylandSeat *seat = compositor()->seatFor(event);
764 seat->sendFullKeyEvent(event);
765 } else {
766 event->ignore();
767 }
768}
769
774{
776 if (d->shouldSendInputEvents() && d->touchEventsEnabled) {
777 QWaylandSeat *seat = compositor()->seatFor(event);
778
779 QPointF pointPos;
780 const QList<QTouchEvent::TouchPoint> &points = event->points();
781 if (!points.isEmpty())
782 pointPos = points.at(0).position();
783
784 if (event->type() == QEvent::TouchBegin && !inputRegionContains(pointPos)) {
785 event->ignore();
786 return;
787 }
788
789 event->accept();
790 if (seat->mouseFocus() != d->view.data()) {
791 seat->sendMouseMoveEvent(d->view.data(), pointPos, mapToScene(pointPos));
792 }
794
795 if (event->type() == QEvent::TouchBegin) {
796 d->touchingSeats.append(seat);
797 } else if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) {
798 d->touchingSeats.removeOne(seat);
799 }
800
801 if (event->type() == QEvent::TouchBegin && d->focusOnClick)
802 takeFocus(seat);
803 } else {
804 event->ignore();
805 }
806}
807
809{
811
812 if (d->shouldSendInputEvents())
813 for (auto seat : d->touchingSeats)
815
816 d->touchingSeats.clear();
817}
818
819#if QT_CONFIG(im)
823void QWaylandQuickItem::inputMethodEvent(QInputMethodEvent *event)
824{
826 if (d->shouldSendInputEvents()) {
827 d->oldSurface->inputMethodControl()->inputMethodEvent(event);
828 } else {
829 event->ignore();
830 }
831}
832#endif
833
838{
839 Q_UNUSED(newSurface);
840 Q_UNUSED(oldSurface);
841}
842
843void QWaylandQuickItem::handleSubsurfaceAdded(QWaylandSurface *childSurface)
844{
846 if (d->subsurfaceHandler.isNull()) {
847 QWaylandQuickItem *childItem = new QWaylandQuickItem;
848 childItem->setSurface(childSurface);
849 childItem->setVisible(true);
850 childItem->setParentItem(this);
851 childItem->setParent(this);
852 connect(childSurface, &QWaylandSurface::subsurfacePositionChanged, childItem, &QWaylandQuickItem::handleSubsurfacePosition);
853 connect(childSurface, &QWaylandSurface::destroyed, childItem, &QObject::deleteLater);
854 } else {
855 bool success = QMetaObject::invokeMethod(d->subsurfaceHandler, "handleSubsurfaceAdded", Q_ARG(QWaylandSurface *, childSurface));
856 if (!success)
857 success = QMetaObject::invokeMethod(d->subsurfaceHandler, "handleSubsurfaceAdded",
858 Q_ARG(QVariant, QVariant::fromValue(childSurface)));
859
860 if (!success)
861 qWarning("QWaylandQuickItem: subsurfaceHandler does not implement handleSubsurfaceAdded()");
862 }
863}
864
865void QWaylandQuickItem::handlePlaceAbove(QWaylandSurface *referenceSurface)
866{
868 auto *parent = qobject_cast<QWaylandQuickItem*>(parentItem());
869 if (!parent)
870 return;
871
872 if (parent->surface() == referenceSurface) {
873 d->placeAboveParent();
874 } else if (auto *sibling = d->findSibling(referenceSurface)) {
875 d->placeAboveSibling(sibling);
876 } else {
877 qWarning() << "Couldn't find QWaylandQuickItem for surface" << referenceSurface
878 << "when handling wl_subsurface.place_above";
879 }
880}
881
882void QWaylandQuickItem::handlePlaceBelow(QWaylandSurface *referenceSurface)
883{
885 QWaylandQuickItem *parent = qobject_cast<QWaylandQuickItem*>(parentItem());
886 if (!parent)
887 return;
888
889 if (parent->surface() == referenceSurface) {
890 d->placeBelowParent();
891 } else if (auto *sibling = d->findSibling(referenceSurface)) {
892 d->placeBelowSibling(sibling);
893 } else {
894 qWarning() << "Couldn't find QWaylandQuickItem for surface" << referenceSurface
895 << "when handling wl_subsurface.place_below";
896 }
897}
898
899void QWaylandQuickItem::updateFocus()
900{
901 Q_D(const QWaylandQuickItem);
902 if (hasActiveFocus() && compositor())
903 compositor()->defaultSeat()->setKeyboardFocus(d->view->surface());
904}
905
931{
932 Q_D(const QWaylandQuickItem);
933 return d->subsurfaceHandler.data();
934}
935
937{
939 if (d->subsurfaceHandler.data() != handler) {
940 d->subsurfaceHandler = handler;
942 }
943}
944
956{
957 Q_D(const QWaylandQuickItem);
958 return d->view->output();
959}
960
962{
964 d->view->setOutput(output);
965}
966
984{
985 Q_D(const QWaylandQuickItem);
986 return d->view->isBufferLocked();
987}
988
990{
992 d->view->setBufferLocked(locked);
993
994 // Apply the latest surface size
995 if (!locked)
996 updateSize();
997}
998
1008{
1009 Q_D(const QWaylandQuickItem);
1010 return d->view->allowDiscardFrontBuffer();
1011}
1012
1014{
1015 Q_D(QWaylandQuickItem);
1016 d->view->setAllowDiscardFrontBuffer(discard);
1017}
1018
1031{
1032 Q_D(QWaylandQuickItem);
1033 d->view->setPrimary();
1034}
1035
1039void QWaylandQuickItem::handleSurfaceChanged()
1040{
1041 Q_D(QWaylandQuickItem);
1042 if (d->oldSurface) {
1043 disconnect(d->oldSurface.data(), &QWaylandSurface::hasContentChanged, this, &QWaylandQuickItem::surfaceMappedChanged);
1044 disconnect(d->oldSurface.data(), &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged);
1045 disconnect(d->oldSurface.data(), &QWaylandSurface::destinationSizeChanged, this, &QWaylandQuickItem::updateSize);
1046 disconnect(d->oldSurface.data(), &QWaylandSurface::bufferScaleChanged, this, &QWaylandQuickItem::updateSize);
1047 disconnect(d->oldSurface.data(), &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
1048 disconnect(d->oldSurface.data(), &QWaylandSurface::redraw, this, &QQuickItem::update);
1049 disconnect(d->oldSurface.data(), &QWaylandSurface::childAdded, this, &QWaylandQuickItem::handleSubsurfaceAdded);
1050 disconnect(d->oldSurface.data(), &QWaylandSurface::subsurfacePlaceAbove, this, &QWaylandQuickItem::handlePlaceAbove);
1051 disconnect(d->oldSurface.data(), &QWaylandSurface::subsurfacePlaceBelow, this, &QWaylandQuickItem::handlePlaceBelow);
1052#if QT_CONFIG(draganddrop)
1053 disconnect(d->oldSurface.data(), &QWaylandSurface::dragStarted, this, &QWaylandQuickItem::handleDragStarted);
1054#endif
1055#if QT_CONFIG(im)
1056 disconnect(d->oldSurface->inputMethodControl(), &QWaylandInputMethodControl::updateInputMethod, this, &QWaylandQuickItem::updateInputMethod);
1057#endif
1058 }
1059 if (QWaylandSurface *newSurface = d->view->surface()) {
1060 connect(newSurface, &QWaylandSurface::hasContentChanged, this, &QWaylandQuickItem::surfaceMappedChanged);
1061 connect(newSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged);
1062 connect(newSurface, &QWaylandSurface::destinationSizeChanged, this, &QWaylandQuickItem::updateSize);
1063 connect(newSurface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandQuickItem::updateSize);
1064 connect(newSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
1066 connect(newSurface, &QWaylandSurface::childAdded, this, &QWaylandQuickItem::handleSubsurfaceAdded);
1067 connect(newSurface, &QWaylandSurface::subsurfacePlaceAbove, this, &QWaylandQuickItem::handlePlaceAbove);
1068 connect(newSurface, &QWaylandSurface::subsurfacePlaceBelow, this, &QWaylandQuickItem::handlePlaceBelow);
1069#if QT_CONFIG(draganddrop)
1070 connect(newSurface, &QWaylandSurface::dragStarted, this, &QWaylandQuickItem::handleDragStarted);
1071#endif
1072#if QT_CONFIG(im)
1073 connect(newSurface->inputMethodControl(), &QWaylandInputMethodControl::updateInputMethod, this, &QWaylandQuickItem::updateInputMethod);
1074#endif
1075
1076 if (newSurface->origin() != d->origin) {
1077 d->origin = newSurface->origin();
1079 }
1080 if (window()) {
1081 QWaylandOutput *output = newSurface->compositor()->outputFor(window());
1082 d->view->setOutput(output);
1083 }
1084 for (auto subsurface : QWaylandSurfacePrivate::get(newSurface)->subsurfaceChildren) {
1085 if (!subsurface.isNull())
1086 handleSubsurfaceAdded(subsurface.data());
1087 }
1088
1089 updateSize();
1090 }
1091 surfaceChangedEvent(d->view->surface(), d->oldSurface);
1092 d->oldSurface = d->view->surface();
1093#if QT_CONFIG(im)
1094 updateInputMethod(Qt::ImQueryInput);
1095#endif
1096}
1097
1103{
1105
1106 if (!surface() || !surface()->client())
1107 return;
1108
1110 if (!target) {
1111 target = compositor()->defaultSeat();
1112 }
1113 target->setKeyboardFocus(surface());
1114
1115 qCDebug(qLcWaylandCompositorInputMethods) << Q_FUNC_INFO << " surface:" << surface()
1116 << ", client:" << surface()->client()
1117 << ", textinputprotocol:" << (int)(surface()->client()->textInputProtocols());
1120 if (textInput)
1121 textInput->setFocus(surface());
1122 }
1123
1124 if (surface()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV3)) {
1126 if (textInputV3)
1127 textInputV3->setFocus(surface());
1128 }
1129
1130 if (surface()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1)) {
1132 if (textInputMethod)
1133 textInputMethod->setFocus(surface());
1134 }
1135}
1136
1140void QWaylandQuickItem::surfaceMappedChanged()
1141{
1142 update();
1143}
1144
1148void QWaylandQuickItem::parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent)
1149{
1150 Q_UNUSED(oldParent);
1151
1152 if (newParent) {
1153 setPaintEnabled(true);
1154 setVisible(true);
1155 setOpacity(1);
1156 setEnabled(true);
1157 }
1158}
1159
1163void QWaylandQuickItem::updateSize()
1164{
1165 Q_D(QWaylandQuickItem);
1166
1167 // No resize if buffer is locked
1168 if (isBufferLocked()) {
1169 qWarning() << "No update on item size as the buffer is currently locked";
1170 return;
1171 }
1172
1173 QSize size(0, 0);
1174 if (surface())
1175 size = surface()->destinationSize() * d->scaleFactor();
1176
1177 setImplicitSize(size.width(), size.height());
1178}
1179
1198{
1199 Q_D(const QWaylandQuickItem);
1200 return d->focusOnClick;
1201}
1202
1204{
1205 Q_D(QWaylandQuickItem);
1206 if (d->focusOnClick == focus)
1207 return;
1208
1209 d->focusOnClick = focus;
1211}
1212
1217bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition) const
1218{
1219 if (QWaylandSurface *s = surface())
1220 return s->inputRegionContains(mapToSurface(localPosition));
1221 return false;
1222}
1223
1238{
1239 Q_D(const QWaylandQuickItem);
1240 if (!surface() || surface()->destinationSize().isEmpty())
1241 return point / d->scaleFactor();
1242
1243 qreal xScale = width() / surface()->destinationSize().width();
1244 qreal yScale = height() / surface()->destinationSize().height();
1245
1246 return QPointF(point.x() / xScale, point.y() / yScale);
1247}
1248
1263QPointF QWaylandQuickItem::mapFromSurface(const QPointF &point) const
1264{
1265 Q_D(const QWaylandQuickItem);
1266 if (!surface() || surface()->destinationSize().isEmpty())
1267 return point * d->scaleFactor();
1268
1269 qreal xScale = width() / surface()->destinationSize().width();
1270 qreal yScale = height() / surface()->destinationSize().height();
1271
1272 return QPointF(point.x() * xScale, point.y() * yScale);
1273}
1274
1275#if QT_CONFIG(im)
1276QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query) const
1277{
1278 return inputMethodQuery(query, QVariant());
1279}
1280
1281QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const
1282{
1283 Q_D(const QWaylandQuickItem);
1284
1285 if (query == Qt::ImEnabled)
1286 return QVariant((flags() & ItemAcceptsInputMethod) != 0);
1287
1288 if (d->oldSurface)
1289 return d->oldSurface->inputMethodControl()->inputMethodQuery(query, argument);
1290
1291 return QVariant();
1292}
1293#endif
1294
1313{
1314 Q_D(const QWaylandQuickItem);
1315 return d->paintEnabled;
1316}
1317
1319{
1320 Q_D(QWaylandQuickItem);
1321
1322 if (enabled != d->paintEnabled) {
1323 d->paintEnabled = enabled;
1325 }
1326
1327 update();
1328}
1329
1344{
1345 Q_D(const QWaylandQuickItem);
1346 return d->touchEventsEnabled;
1347}
1348
1349void QWaylandQuickItem::updateBuffer(bool hasBuffer)
1350{
1351 Q_D(QWaylandQuickItem);
1352 Q_UNUSED(hasBuffer);
1353 if (d->origin != surface()->origin()) {
1354 d->origin = surface()->origin();
1356 }
1357}
1358
1359void QWaylandQuickItem::updateWindow()
1360{
1361 Q_D(QWaylandQuickItem);
1362
1363 QQuickWindow *newWindow = window();
1364 if (newWindow == d->connectedWindow)
1365 return;
1366
1367 if (d->connectedWindow) {
1368 disconnect(d->connectedWindow, &QQuickWindow::beforeSynchronizing, this, &QWaylandQuickItem::beforeSync);
1369 disconnect(d->connectedWindow, &QQuickWindow::screenChanged, this, &QWaylandQuickItem::updateSize);
1370 }
1371
1372 d->connectedWindow = newWindow;
1373
1374 if (d->connectedWindow) {
1375 connect(d->connectedWindow, &QQuickWindow::beforeSynchronizing, this, &QWaylandQuickItem::beforeSync, Qt::DirectConnection);
1376 connect(d->connectedWindow, &QQuickWindow::screenChanged, this, &QWaylandQuickItem::updateSize); // new screen may have new dpr
1377
1378 if (compositor()) {
1379 QWaylandOutput *output = compositor()->outputFor(d->connectedWindow);
1381 d->view->setOutput(output);
1382 }
1383
1384 updateSize(); // because scaleFactor depends on devicePixelRatio, which may be different for the new window
1385 }
1386}
1387
1388void QWaylandQuickItem::updateOutput()
1389{
1390 Q_D(QWaylandQuickItem);
1391 if (d->view->output() == d->connectedOutput)
1392 return;
1393
1394 if (d->connectedOutput)
1395 disconnect(d->connectedOutput, &QWaylandOutput::scaleFactorChanged, this, &QWaylandQuickItem::updateSize);
1396
1397 d->connectedOutput = d->view->output();
1398
1399 if (d->connectedOutput)
1400 connect(d->connectedOutput, &QWaylandOutput::scaleFactorChanged, this, &QWaylandQuickItem::updateSize);
1401
1402 updateSize();
1403}
1404
1405void QWaylandQuickItem::beforeSync()
1406{
1407 Q_D(QWaylandQuickItem);
1408 if (d->view->advance()) {
1409 d->newTexture = true;
1410 update();
1411 }
1412}
1413
1414#if QT_CONFIG(im)
1415void QWaylandQuickItem::updateInputMethod(Qt::InputMethodQueries queries)
1416{
1417 Q_D(QWaylandQuickItem);
1418
1419 setFlag(QQuickItem::ItemAcceptsInputMethod,
1420 d->oldSurface ? d->oldSurface->inputMethodControl()->enabled() : false);
1421 QQuickItem::updateInputMethod(queries | Qt::ImEnabled);
1422}
1423#endif
1424
1452{
1453 Q_D(QWaylandQuickItem);
1454 d->lastMatrix = data->transformNode->combinedMatrix();
1455 const bool bufferHasContent = d->view->currentBuffer().hasContent();
1456
1457 if (d->view->isBufferLocked() && d->paintEnabled)
1458 return oldNode;
1459
1460 if (!bufferHasContent || !d->paintEnabled || !surface()) {
1461 delete oldNode;
1462 return nullptr;
1463 }
1464
1465 QWaylandBufferRef ref = d->view->currentBuffer();
1466 const bool invertY = ref.origin() == QWaylandSurface::OriginBottomLeft;
1467 const QRectF rect = invertY ? QRectF(0, height(), width(), -height())
1468 : QRectF(0, 0, width(), height());
1469
1470 if (ref.isSharedMemory()
1471#if QT_CONFIG(opengl)
1472 || bufferTypes[ref.bufferFormatEgl()].canProvideTexture
1473#endif
1474 ) {
1475#if QT_CONFIG(opengl)
1476 if (oldNode && !d->paintByProvider) {
1477 // Need to re-create a node
1478 delete oldNode;
1479 oldNode = nullptr;
1480 }
1481 d->paintByProvider = true;
1482#endif
1483 // This case could covered by the more general path below, but this is more efficient (especially when using ShaderEffect items).
1484 QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode *>(oldNode);
1485
1486 if (!node) {
1487 node = new QSGSimpleTextureNode();
1488 if (smooth())
1490 d->newTexture = true;
1491 }
1492
1493 if (!d->provider) {
1494 d->provider = new QWaylandSurfaceTextureProvider();
1495 if (compositor()) {
1496 d->texProviderConnection =
1498 compositor(),
1500 this,
1501 [this](QObject*) {
1502 auto *itemPriv = QWaylandQuickItemPrivate::get(this);
1503 if (itemPriv->provider) {
1504 itemPriv->provider->deleteLater();
1505 itemPriv->provider = nullptr;
1506 }
1507 disconnect(itemPriv->texProviderConnection); }
1508 );
1509 }
1510 }
1511
1512 if (d->newTexture) {
1513 d->newTexture = false;
1514 d->provider->setBufferRef(this, ref);
1515 node->setTexture(d->provider->texture());
1516 }
1517
1518 d->provider->setSmooth(smooth());
1519 node->setRect(rect);
1520
1523 node->setSourceRect(QRectF(source.topLeft() * scale, source.size() * scale));
1524
1525 return node;
1526 }
1527
1528#if QT_CONFIG(opengl)
1529 Q_ASSERT(!d->provider);
1530
1531 if (oldNode && d->paintByProvider) {
1532 // Need to re-create a node
1533 delete oldNode;
1534 oldNode = nullptr;
1535 }
1536 d->paintByProvider = false;
1537
1538 QSGGeometryNode *node = static_cast<QSGGeometryNode *>(oldNode);
1539
1540 if (!node) {
1541 node = new QSGGeometryNode;
1542 d->newTexture = true;
1543 }
1544
1545 QSGGeometry *geometry = node->geometry();
1546 QWaylandBufferMaterial *material = static_cast<QWaylandBufferMaterial *>(node->material());
1547
1548 if (!geometry)
1550
1551 if (!material)
1552 material = new QWaylandBufferMaterial(ref.bufferFormatEgl());
1553
1554 if (d->newTexture) {
1555 d->newTexture = false;
1556 material->setBufferRef(this, ref);
1557 }
1558
1559 const QSize surfaceSize = ref.size() / surface()->bufferScale();
1560 const QRectF sourceGeometry = surface()->sourceGeometry();
1561 const QRectF normalizedCoordinates =
1562 sourceGeometry.isValid()
1563 ? QRectF(sourceGeometry.x() / surfaceSize.width(),
1564 sourceGeometry.y() / surfaceSize.height(),
1565 sourceGeometry.width() / surfaceSize.width(),
1566 sourceGeometry.height() / surfaceSize.height())
1567 : QRectF(0, 0, 1, 1);
1568
1569 QSGGeometry::updateTexturedRectGeometry(geometry, rect, normalizedCoordinates);
1570
1571 node->setGeometry(geometry);
1572 node->setFlag(QSGNode::OwnsGeometry, true);
1573
1574 node->setMaterial(material);
1575 node->setFlag(QSGNode::OwnsMaterial, true);
1576
1577 return node;
1578#else
1579 qCWarning(qLcWaylandCompositor) << "Without OpenGL support only shared memory textures are supported";
1580 return nullptr;
1581#endif // QT_CONFIG(opengl)
1582}
1583
1585{
1586 Q_D(QWaylandQuickItem);
1587 if (d->touchEventsEnabled != enabled) {
1588 d->touchEventsEnabled = enabled;
1590 }
1591}
1592
1594{
1595 Q_D(const QWaylandQuickItem);
1596 return d->inputEventsEnabled;
1597}
1598
1600{
1601 Q_D(QWaylandQuickItem);
1602 if (d->inputEventsEnabled != enabled) {
1603 if (enabled)
1604 setEnabled(true);
1605 d->setInputEventsEnabled(enabled);
1607 }
1608}
1609
1611{
1612 Q_D(QWaylandQuickItem);
1613 d->lower();
1614}
1615
1617{
1618 Q_Q(QWaylandQuickItem);
1619 QQuickItem *parent = q->parentItem();
1621 QQuickItem *bottom = parent->childItems().constFirst();
1622 if (q != bottom)
1623 q->stackBefore(bottom);
1624}
1625
1627{
1628 Q_D(QWaylandQuickItem);
1629 d->raise();
1630}
1631
1633{
1634 Q_Q(QWaylandQuickItem);
1635 QQuickItem *parent = q->parentItem();
1637 QQuickItem *top = parent->childItems().constLast();
1638 if (q != top)
1639 q->stackAfter(top);
1640}
1641
1643{
1644 if (seat == nullptr)
1645 seat = compositor()->defaultSeat();
1646
1647 if (!seat) {
1648 qWarning() << "No seat, can't send mouse event";
1649 return;
1650 }
1651
1653}
1654
1660void QWaylandQuickItem::handleSubsurfacePosition(const QPoint &pos)
1661{
1662 Q_D(QWaylandQuickItem);
1663 QQuickItem::setPosition(pos * d->scaleFactor());
1664}
1665
1666#if QT_CONFIG(draganddrop)
1667void QWaylandQuickItem::handleDragStarted(QWaylandDrag *drag)
1668{
1669 Q_D(QWaylandQuickItem);
1670 Q_ASSERT(drag->origin() == surface());
1671 drag->seat()->setMouseFocus(nullptr);
1672 d->isDragging = true;
1673}
1674#endif
1675
1677{
1678 qreal f = view->output() ? view->output()->scaleFactor() : 1;
1679#if !defined(Q_OS_MACOS)
1680 if (window)
1681 f /= window->devicePixelRatio();
1682#endif
1683 return f;
1684}
1685
1687{
1688 Q_Q(const QWaylandQuickItem);
1689 auto *parent = q->parentItem();
1690 if (!parent)
1691 return nullptr;
1692
1693 const auto siblings = q->parentItem()->childItems();
1694 for (auto *sibling : siblings) {
1695 auto *waylandItem = qobject_cast<QWaylandQuickItem *>(sibling);
1696 if (waylandItem && waylandItem->surface() == surface)
1697 return waylandItem;
1698 }
1699 return nullptr;
1700}
1701
1703{
1704 Q_Q(QWaylandQuickItem);
1705 q->stackAfter(sibling);
1706 q->setZ(sibling->z());
1707 belowParent = sibling->d_func()->belowParent;
1708}
1709
1711{
1712 Q_Q(QWaylandQuickItem);
1713 q->stackBefore(sibling);
1714 q->setZ(sibling->z());
1715 belowParent = sibling->d_func()->belowParent;
1716}
1717
1718//### does not handle changes in z value if parent is a subsurface
1720{
1721 Q_Q(QWaylandQuickItem);
1722 const auto siblings = q->parentItem()->childItems();
1723
1724 // Stack below first (bottom) sibling above parent
1725 bool foundSibling = false;
1726 for (auto it = siblings.cbegin(); it != siblings.cend(); ++it) {
1727 QWaylandQuickItem *sibling = qobject_cast<QWaylandQuickItem*>(*it);
1728 if (sibling && !sibling->d_func()->belowParent) {
1729 q->stackBefore(sibling);
1730 foundSibling = true;
1731 break;
1732 }
1733 }
1734
1735 // No other subsurfaces above parent
1736 if (!foundSibling && siblings.last() != q)
1737 q->stackAfter(siblings.last());
1738
1739 q->setZ(q->parentItem()->z());
1740 belowParent = false;
1741}
1742
1743//### does not handle changes in z value if parent is a subsurface
1745{
1746 Q_Q(QWaylandQuickItem);
1747 const auto siblings = q->parentItem()->childItems();
1748
1749 // Stack above last (top) sibling below parent
1750 bool foundSibling = false;
1751 for (auto it = siblings.crbegin(); it != siblings.crend(); ++it) {
1752 QWaylandQuickItem *sibling = qobject_cast<QWaylandQuickItem*>(*it);
1753 if (sibling && sibling->d_func()->belowParent) {
1754 q->stackAfter(sibling);
1755 foundSibling = true;
1756 break;
1757 }
1758 }
1759
1760 // No other subsurfaces below parent
1761 if (!foundSibling && siblings.first() != q)
1762 q->stackBefore(siblings.first());
1763
1764 q->setZ(q->parentItem()->z() - 1.0);
1765 belowParent = true;
1766}
1767
1769
1770#include "moc_qwaylandquickitem.cpp"
IOBluetoothDevice * device
\inmodule QtCore
Definition qbytearray.h:57
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
Definition qbytearray.h:494
@ TouchCancel
Definition qcoreevent.h:264
@ TouchBegin
Definition qcoreevent.h:241
\inmodule QtCore
Definition qfile.h:93
\inmodule QtGui
Definition qevent.h:246
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:625
The QKeyEvent class describes a key event.
Definition qevent.h:424
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qmutex.h:313
\inmodule QtCore
Definition qmutex.h:281
QObject * parent
Definition qobject.h:73
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
void deleteLater()
\threadsafe
Definition qobject.cpp:2435
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
The QOpenGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
void glTexParameteri(GLenum target, GLenum pname, GLint param)
Convenience function that calls glTexParameteri(target, pname, param).
\inmodule QtGui
\inmodule QtCore\reentrant
Definition qpoint.h:217
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:343
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:348
\inmodule QtCore\reentrant
Definition qpoint.h:25
QQuickWindow * window
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
QPointF mapToScene(const QPointF &point) const
Maps the given point in this item's coordinate system to the equivalent point within the scene's coor...
Flags flags() const
Returns the item flags for this item.
void activeFocusChanged(bool)
void setOpacity(qreal)
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
Q_INVOKABLE QPointF mapToItem(const QQuickItem *item, const QPointF &point) const
Maps the given point in this item's coordinate system to the equivalent point within item's coordinat...
qreal z
\qmlproperty real QtQuick::Item::z
Definition qquickitem.h:74
bool hasActiveFocus() const
virtual QSGTextureProvider * textureProvider() const
Returns the texture provider for an item.
void setEnabled(bool)
QSizeF size() const
QQuickWindow * window() const
Returns the window in which this item is rendered.
qreal width
This property holds the width of this item.
Definition qquickitem.h:75
QQuickItem * parentItem() const
void setVisible(bool)
QQuickItem * parent
\qmlproperty Item QtQuick::Item::parent This property holds the visual parent of the item.
Definition qquickitem.h:67
QPointF position() const
Q_INVOKABLE void forceActiveFocus()
\qmlmethod point QtQuick::Item::mapToItem(Item item, real x, real y) \qmlmethod point QtQuick::Item::...
bool smooth
\qmlproperty bool QtQuick::Item::smooth
Definition qquickitem.h:112
qreal height
This property holds the height of this item.
Definition qquickitem.h:76
void setPosition(const QPointF &)
bool enabled
\qmlproperty bool QtQuick::Item::enabled
Definition qquickitem.h:79
void update()
Schedules a call to updatePaintNode() for this item.
virtual bool isTextureProvider() const
Returns true if this item is a texture provider.
void setImplicitSize(qreal, qreal)
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
void beforeSynchronizing()
This signal is emitted before the scene graph is synchronized with the QML state.
\inmodule QtCore\reentrant
Definition qrect.h:484
constexpr qreal y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:672
constexpr qreal height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:732
constexpr qreal width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:729
constexpr qreal x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:669
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
Definition qrect.h:666
const QSGGeometry * geometry() const
Returns this node's geometry.
Definition qsgnode.h:160
void setGeometry(QSGGeometry *geometry)
Sets the geometry of this node to geometry.
Definition qsgnode.cpp:764
The QSGGeometryNode class is used for all rendered content in the scene graph.
Definition qsgnode.h:188
QSGMaterial * material() const
Returns the material of the QSGGeometryNode.
Definition qsgnode.h:194
void setMaterial(QSGMaterial *material)
Sets the material of this geometry node to material.
Definition qsgnode.cpp:927
The QSGGeometry class provides low-level storage for graphics primitives in the \l{Qt Quick Scene Gra...
Definition qsggeometry.h:15
static const AttributeSet & defaultAttributes_TexturedPoint2D()
Convenience function which returns attributes to be used for textured 2D drawing.
static void updateTexturedRectGeometry(QSGGeometry *g, const QRectF &rect, const QRectF &sourceRect)
Updates the geometry g with the coordinates in rect and texture coordinates from textureRect.
The QSGMaterialShader class represents a graphics API independent shader program.
The QSGMaterial class encapsulates rendering state for a shader program.
Definition qsgmaterial.h:15
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
@ OwnsMaterial
Definition qsgnode.h:58
@ OwnsGeometry
Definition qsgnode.h:57
void setFlag(Flag, bool=true)
Sets the flag f on this node if enabled is true; otherwise clears the flag.
Definition qsgnode.cpp:586
RenderMode
\value RenderMode2D Normal 2D rendering \value RenderMode2DNoDepthBuffer Normal 2D rendering with dep...
The QSGSimpleTextureNode class is provided for convenience to easily draw textured content using the ...
void setRect(const QRectF &rect)
Sets the target rect of this texture node to r.
void setFiltering(QSGTexture::Filtering filtering)
Sets the filtering to be used for this texture node to filtering.
void setTexture(QSGTexture *texture)
Sets the texture of this texture node to texture.
void setSourceRect(const QRectF &r)
Sets the source rect of this texture node to r.
The QSGTextureProvider class encapsulates texture based entities in QML.
\inmodule QtQuick
Definition qsgtexture.h:20
void setFiltering(Filtering filter)
Sets the sampling mode to filter.
const_iterator cend() const noexcept
Definition qset.h:142
const_iterator cbegin() const noexcept
Definition qset.h:138
\inmodule QtGui
Definition qshader.h:60
\inmodule QtGui
Definition qshader.h:178
\inmodule QtGui
Definition qshader.h:32
\inmodule QtGui
Definition qshader.h:81
@ GlslShader
Definition qshader.h:94
@ FragmentStage
Definition qshader.h:88
void setStage(Stage stage)
Sets the pipeline stage.
Definition qshader.cpp:359
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5871
static QThread * currentThread()
Definition qthread.cpp:1039
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:917
\inmodule QtCore
Definition qvariant.h:65
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:536
\inmodule QtWaylandCompositor
TextInputProtocols textInputProtocols() const
static QWaylandTextInput * findIn(QWaylandObject *container)
If any instance of the interface has been registered with container, this is returned.
\qmltype WaylandCompositor \instantiates QWaylandCompositor \inqmlmodule QtWayland....
QWaylandSeat * seat() const
QWaylandSurface * origin() const
void updateInputMethod(Qt::InputMethodQueries queries)
\qmltype WaylandOutput \instantiates QWaylandOutput \inqmlmodule QtWayland.Compositor
void scaleFactorChanged()
int scaleFactor
\qmlproperty int QtWayland.Compositor::WaylandOutput::scaleFactor
QWaylandCompositor * compositor
void setFocus(QWaylandSurface *surface)
QWaylandQuickItem * findSibling(QWaylandSurface *surface) const
QScopedPointer< QWaylandView > view
void placeBelowSibling(QWaylandQuickItem *sibling)
void placeAboveSibling(QWaylandQuickItem *sibling)
static const QWaylandQuickItemPrivate * get(const QWaylandQuickItem *item)
\qmltype WaylandQuickItem \instantiates QWaylandQuickItem \inqmlmodule QtWayland.Compositor
void keyPressEvent(QKeyEvent *event) override
Q_INVOKABLE void setPrimary()
\qmlmethod WaylandQuickItem::setPrimary()
Q_INVOKABLE QPointF mapToSurface(const QPointF &point) const
\qmlmethod point WaylandQuickItem::mapToSurface(point point)
void mousePressEvent(QMouseEvent *event) override
void compositorChanged()
void setAllowDiscardFrontBuffer(bool discard)
void setInputEventsEnabled(bool enabled)
void hoverEnterEvent(QHoverEvent *event) override
virtual void takeFocus(QWaylandSeat *device=nullptr)
Calling this function causes the item to take the focus of the input device.
void setPaintEnabled(bool paintEnabled)
void touchEventsEnabledChanged()
QSGTextureProvider * textureProvider() const override
Returns the texture provider of this QWaylandQuickItem.
QWaylandOutput * output
\qmlproperty WaylandOutput QtWayland.Compositor::WaylandQuickItem::output
~QWaylandQuickItem() override
Destroy the QWaylandQuickItem.
bool isTextureProvider() const override
Returns true if this item is a texture provider.
bool touchEventsEnabled
\qmlproperty bool QtWayland.Compositor::WaylandQuickItem::touchEventsEnabled
bool focusOnClick
\qmlproperty bool QtWayland.Compositor::WaylandQuickItem::focusOnClick
void inputEventsEnabledChanged()
void sendMouseMoveEvent(const QPointF &position, QWaylandSeat *seat=nullptr)
void setFocusOnClick(bool focus)
void hoverLeaveEvent(QHoverEvent *event) override
void paintEnabledChanged()
virtual void surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface)
void mouseReleaseEvent(QMouseEvent *event) override
void subsurfaceHandlerChanged()
void touchEvent(QTouchEvent *event) override
QWaylandView * view() const
Returns the view rendered by this QWaylandQuickItem.
void setTouchEventsEnabled(bool enabled)
QWaylandSurface::Origin origin
\qmlproperty enum QtWayland.Compositor::WaylandQuickItem::origin
QWaylandQuickItem(QQuickItem *parent=nullptr)
Constructs a QWaylandQuickItem with the given parent.
bool inputRegionContains(const QPointF &localPosition) const
Returns true if the input region of this item's surface contains the position given by localPosition.
void setSurface(QWaylandSurface *surface)
void setSubsurfaceHandler(QObject *)
void hoverMoveEvent(QHoverEvent *event) override
void focusOnClickChanged()
void setBufferLocked(bool locked)
QWaylandCompositor * compositor
\qmlproperty WaylandCompositor QtWayland.Compositor::WaylandQuickItem::compositor
void keyReleaseEvent(QKeyEvent *event) override
QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override
Called on the render thread when it is time to sync the state of the item with the scene graph.
void mouseMoveEvent(QMouseEvent *event) override
bool allowDiscardFrontBuffer
By default, the item locks the current buffer until a new buffer is available and updatePaintNode() i...
void mouseMove(const QPointF &windowPosition)
QWaylandSurface * surface
\qmlproperty WaylandSurface QtWayland.Compositor::WaylandQuickItem::surface
void touchUngrabEvent() override
This event handler can be reimplemented in a subclass to be notified when a touch ungrab event has oc...
void setOutput(QWaylandOutput *output)
\qmltype WaylandSeat \instantiates QWaylandSeat \inqmlmodule QtWayland.Compositor
void sendMouseMoveEvent(QWaylandView *surface, const QPointF &localPos, const QPointF &outputSpacePos=QPointF())
Sets the mouse focus to view and sends a mouse move event to the pointer device with the local positi...
void sendMouseReleaseEvent(Qt::MouseButton button)
Sends a mouse release event for button to the QWaylandSeat's pointer device.
void setMouseFocus(QWaylandView *view)
Sets the current mouse focus to view.
void sendFullTouchEvent(QWaylandSurface *surface, QTouchEvent *event)
Sends the event to the specified surface on the touch device.
void sendMousePressEvent(Qt::MouseButton button)
Sends a mouse press event for button to the QWaylandSeat's pointer device.
void sendFullKeyEvent(QKeyEvent *event)
Sends the event to the keyboard device.
QWaylandView * mouseFocus() const
Returns the view that currently has mouse focus.
bool setKeyboardFocus(QWaylandSurface *surface)
Sets the current keyboard focus to surface.
void sendMouseWheelEvent(Qt::Orientation orientation, int delta)
Sends a mouse wheel event to the QWaylandSeat's pointer device with the given orientation and delta.
Q_INVOKABLE void sendTouchCancelEvent(QWaylandClient *client)
\qmlmethod void QtWayland.Compositor::WaylandSeat::sendTouchCancelEvent(WaylandClient client)
QSGTexture * texture() const override
Returns a pointer to the texture object.
void setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &buffer)
\qmltype WaylandSurface \instantiates QWaylandSurface \inqmlmodule QtWayland.Compositor
QSize destinationSize
\qmlproperty size QtWayland.Compositor::WaylandSurface::destinationSize
QWaylandSurface::Origin origin
\qmlproperty enum QtWayland.Compositor::WaylandSurface::origin
void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent)
void dragStarted(QWaylandDrag *drag)
\qmlsignal void QtWayland.Compositor::WaylandSurface::dragStarted(WaylandDrag drag)
void subsurfacePlaceAbove(QWaylandSurface *sibling)
void childAdded(QWaylandSurface *child)
\qmlsignal QtWayland.Compositor::WaylandSurface::childAdded(WaylandSurface child)
void hasContentChanged()
void configure(bool hasBuffer)
int bufferScale
\qmlproperty size QtWayland.Compositor::WaylandSurface::bufferScale
void subsurfacePositionChanged(const QPoint &position)
QSize bufferSize
\qmlproperty size QtWayland.Compositor::WaylandSurface::bufferSize
QWaylandClient * client
\qmlproperty WaylandClient QtWayland.Compositor::WaylandSurface::client
Origin
This enum type is used to specify the origin of a QWaylandSurface's buffer.
bool isOpaque
\qmlproperty bool QtWayland.Compositor::WaylandSurface::isOpaque
void subsurfacePlaceBelow(QWaylandSurface *sibling)
QRectF sourceGeometry
\qmlproperty rect QtWayland.Compositor::WaylandSurface::sourceGeometry
void bufferScaleChanged()
void setFocus(QWaylandSurface *surface)
void setFocus(QWaylandSurface *surface)
\qmltype WaylandView \instantiates QWaylandView \inqmlmodule QtWayland.Compositor
QWaylandOutput * output
\qmlproperty WaylandOutput QtWayland.Compositor::WaylandView::output
void screenChanged(QScreen *screen)
This signal is emitted when a window's screen changes, either by being set explicitly with setScreen(...
bool focus
[0]
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
rect
[4]
QStyleOptionButton opt
else opt state
[0]
Combined button and popup list for selecting options.
InputMethodQuery
@ ImQueryInput
@ ImEnabled
@ Horizontal
Definition qnamespace.h:99
@ Vertical
Definition qnamespace.h:100
@ DirectConnection
#define Q_FALLTHROUGH()
#define Q_FUNC_INFO
static QDBusError::ErrorType get(const char *name)
#define qWarning
Definition qlogging.h:166
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_ARG(Type, data)
Definition qobjectdefs.h:63
const GLfloat * m
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat f
GLenum GLuint buffer
GLint GLint bottom
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum target
GLenum GLuint texture
GLint ref
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
struct _cl_event * event
GLfixed GLfixed GLint GLint GLfixed points
GLdouble s
[6]
Definition qopenglext.h:235
GLenum query
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLenum GLenum GLenum GLenum GLenum scale
#define GL_CLAMP_TO_EDGE
Definition qopenglext.h:100
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define GLuint
#define QT_CONFIG(feature)
#define emit
#define Q_UNUSED(x)
double qreal
Definition qtypes.h:187
QT_BEGIN_NAMESPACE typedef uchar * output
bool testFlag(MaskType mask, FlagType flag)
myObject disconnect()
[26]
socketLayer bind(QHostAddress::Any, 4000)
QDBusArgument argument
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(nullptr), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
\threadsafe This is an overloaded member function, provided for convenience. It differs from the abov...
The QSGMaterialType class is used as a unique type token in combination with QSGMaterial.
QList< QShaderDescription::InOutVariable > inVars
static QShaderDescriptionPrivate * get(QShaderDescription *desc)
QList< QShaderDescription::InOutVariable > combinedImageSamplers
QList< QShaderDescription::InOutVariable > outVars
QList< QShaderDescription::UniformBlock > uniformBlocks
\variable QShaderDescription::InOutVariable::name
\variable QShaderDescription::BlockVariable::name