Qt 6.x
The Qt SDK
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"
9#if QT_WAYLAND_TEXT_INPUT_V4_WIP
10#include "qwaylandtextinputv4.h"
11#endif // QT_WAYLAND_TEXT_INPUT_V4_WIP
13#include "qwaylandquickoutput.h"
14#include <QtWaylandCompositor/qwaylandcompositor.h>
15#include <QtWaylandCompositor/qwaylandseat.h>
16#include <QtWaylandCompositor/qwaylandbufferref.h>
17#if QT_CONFIG(draganddrop)
18#include <QtWaylandCompositor/QWaylandDrag>
19#endif
20#include <QtWaylandCompositor/private/qwlclientbufferintegration_p.h>
21#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
22
23#if QT_CONFIG(opengl)
24# include <QtOpenGL/QOpenGLTexture>
25# include <QtGui/QOpenGLFunctions>
26#endif
27
28#include <QtGui/QKeyEvent>
29#include <QtGui/QGuiApplication>
30#include <QtGui/QScreen>
31
32#include <QtQuick/QSGSimpleTextureNode>
33#include <QtQuick/QQuickWindow>
34#include <QtQuick/qsgtexture.h>
35
36#include <QtCore/QFile>
37#include <QtCore/QMutexLocker>
38#include <QtCore/QMutex>
39
40#include <wayland-server-core.h>
41#include <QThread>
42
43#if QT_CONFIG(opengl)
44#include <QtGui/private/qshaderdescription_p.h>
45#endif
46
47#ifndef GL_TEXTURE_EXTERNAL_OES
48#define GL_TEXTURE_EXTERNAL_OES 0x8D65
49#endif
50
52
53#if QT_CONFIG(opengl)
54static const struct {
55 const char * const vertexShaderSourceFile;
56 const char * const fragmentShaderSourceFile;
57 GLenum textureTarget;
58 int planeCount;
59 bool canProvideTexture;
60 QSGMaterial::Flags materialFlags;
61 QSGMaterialType materialType;
62} bufferTypes[] = {
63 // BufferFormatEgl_Null
64 { "", "", 0, 0, false, {}, {} },
65
66 // BufferFormatEgl_RGB
67 {
68 ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
69 ":/qt-project.org/wayland/compositor/shaders/surface_rgbx.frag.qsb",
70 GL_TEXTURE_2D, 1, true,
72 {}
73 },
74
75 // BufferFormatEgl_RGBA
76 {
77 ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
78 ":/qt-project.org/wayland/compositor/shaders/surface_rgba.frag.qsb",
79 GL_TEXTURE_2D, 1, true,
81 {}
82 },
83
84 // BufferFormatEgl_EXTERNAL_OES
85 {
86 ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
87 ":/qt-project.org/wayland/compositor/shaders/surface_oes_external.frag",
90 {}
91 },
92
93 // BufferFormatEgl_Y_U_V
94 {
95 ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
96 ":/qt-project.org/wayland/compositor/shaders/surface_y_u_v.frag.qsb",
97 GL_TEXTURE_2D, 3, false,
99 {}
100 },
101
102 // BufferFormatEgl_Y_UV
103 {
104 ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
105 ":/qt-project.org/wayland/compositor/shaders/surface_y_uv.frag.qsb",
106 GL_TEXTURE_2D, 2, false,
108 {}
109 },
110
111 // BufferFormatEgl_Y_XUXV
112 {
113 ":/qt-project.org/wayland/compositor/shaders/surface.vert.qsb",
114 ":/qt-project.org/wayland/compositor/shaders/surface_y_xuxv.frag.qsb",
115 GL_TEXTURE_2D, 2, false,
117 {}
118 }
119};
120
121QWaylandBufferMaterialShader::QWaylandBufferMaterialShader(QWaylandBufferRef::BufferFormatEgl format)
122{
124 setShaderFileName(VertexStage, QString::fromLatin1(bufferTypes[format].vertexShaderSourceFile));
125 auto fragmentShaderSourceFile = QString::fromLatin1(bufferTypes[format].fragmentShaderSourceFile);
126
128 setupExternalOESShader(fragmentShaderSourceFile);
129 else
130 setShaderFileName(FragmentStage, fragmentShaderSourceFile);
131}
132
133void QWaylandBufferMaterialShader::setupExternalOESShader(const QString &shaderFilename)
134{
135#if QT_CONFIG(opengl)
136 QFile shaderFile(shaderFilename);
137 if (!shaderFile.open(QIODevice::ReadOnly)) {
138 qCWarning(qLcWaylandCompositor) << "Cannot find external OES shader file:" << shaderFilename;
139 return;
140 }
141 QByteArray FS = shaderFile.readAll();
142
143 static const char *FS_GLES_PREAMBLE =
144 "#extension GL_OES_EGL_image_external : require\n"
145 "precision highp float;\n";
146 static const char *FS_GL_PREAMBLE =
147 "#version 120\n"
148 "#extension GL_OES_EGL_image_external : require\n";
149 QByteArray fsGLES = FS_GLES_PREAMBLE + FS;
150 QByteArray fsGL = FS_GL_PREAMBLE + FS;
151
154
156 texCoordInput.name = "v_texcoord";
157 texCoordInput.type = QShaderDescription::Vec2;
158 texCoordInput.location = 0;
159
160 descData->inVars = { texCoordInput };
161
162 QShaderDescription::InOutVariable fragColorOutput;
163 texCoordInput.name = "gl_FragColor";
164 texCoordInput.type = QShaderDescription::Vec4;
165 texCoordInput.location = 0;
166
167 descData->outVars = { fragColorOutput };
168
170 matrixBlockVar.name = "qt_Matrix";
171 matrixBlockVar.type = QShaderDescription::Mat4;
172 matrixBlockVar.offset = 0;
173 matrixBlockVar.size = 64;
174
175 QShaderDescription::BlockVariable opacityBlockVar;
176 opacityBlockVar.name = "qt_Opacity";
177 opacityBlockVar.type = QShaderDescription::Float;
178 opacityBlockVar.offset = 64;
179 opacityBlockVar.size = 4;
180
182 ubufStruct.blockName = "buf";
183 ubufStruct.structName = "ubuf";
184 ubufStruct.size = 64 + 4;
185 ubufStruct.binding = 0;
186 ubufStruct.members = { matrixBlockVar, opacityBlockVar };
187
188 descData->uniformBlocks = { ubufStruct };
189
191 samplerTex0.name = "tex0";
193 samplerTex0.binding = 1;
194
195 descData->combinedImageSamplers = { samplerTex0 };
196
197 QShader shaderPack;
199 shaderPack.setDescription(desc);
202
203 setShader(FragmentStage, shaderPack);
204#else
205 Q_UNUSED(shaderFilename);
206#endif
207}
208
209bool QWaylandBufferMaterialShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *)
210{
211 bool changed = false;
212 QByteArray *buf = state.uniformData();
213 Q_ASSERT(buf->size() >= 68);
214
215 if (state.isMatrixDirty()) {
216 const QMatrix4x4 m = state.combinedMatrix();
217 memcpy(buf->data(), m.constData(), 64);
218 changed = true;
219 }
220
221 if (state.isOpacityDirty()) {
222 const float opacity = state.opacity();
223 memcpy(buf->data() + 64, &opacity, 4);
224 changed = true;
225 }
226
227 return changed;
228}
229
230void QWaylandBufferMaterialShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
231 QSGMaterial *newMaterial, QSGMaterial *)
232{
234
235 QWaylandBufferMaterial *material = static_cast<QWaylandBufferMaterial *>(newMaterial);
236 switch (binding) {
237 case 1:
238 *texture = material->m_scenegraphTextures.at(0);
239 break;
240 case 2:
241 *texture = material->m_scenegraphTextures.at(1);
242 break;
243 case 3:
244 *texture = material->m_scenegraphTextures.at(2);
245 break;
246 default:
247 return;
248 }
249
250 // This is for the shared memory case, and is a no-op for others,
251 // this is where the upload from the QImage happens when not yet done.
252 // ### or is this too late? (if buffer.image() disappears in the meantime then this is the wrong...)
253 if (*texture)
254 (*texture)->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
255}
256
257QWaylandBufferMaterial::QWaylandBufferMaterial(QWaylandBufferRef::BufferFormatEgl format)
258 : m_format(format)
259{
260 setFlag(bufferTypes[m_format].materialFlags);
261}
262
263QWaylandBufferMaterial::~QWaylandBufferMaterial()
264{
265 qDeleteAll(m_scenegraphTextures);
266}
267
268void QWaylandBufferMaterial::setTextureForPlane(int plane,
270 QSGTexture *scenegraphTexture)
271{
272 if (plane < 0 || plane >= bufferTypes[m_format].planeCount) {
273 qWarning("plane index is out of range");
274 return;
275 }
276
277 texture->bind();
278 setTextureParameters(texture->target());
279
280 ensureTextures(plane - 1);
281
282 if (m_textures.size() <= plane) {
283 m_textures << texture;
284 m_scenegraphTextures << scenegraphTexture;
285 } else {
286 delete m_scenegraphTextures[plane];
287
288 m_textures[plane] = texture;
289 m_scenegraphTextures[plane] = scenegraphTexture;
290 }
291}
292
293void QWaylandBufferMaterial::bind()
294{
295 ensureTextures(bufferTypes[m_format].planeCount);
296
297 switch (m_textures.size()) {
298 case 3:
299 if (m_textures[2])
300 m_textures[2]->bind(2);
302 case 2:
303 if (m_textures[1])
304 m_textures[1]->bind(1);
306 case 1:
307 if (m_textures[0])
308 m_textures[0]->bind(0);
309 }
310}
311
312QSGMaterialType *QWaylandBufferMaterial::type() const
313{
314 return const_cast<QSGMaterialType *>(&bufferTypes[m_format].materialType);
315}
316
317QSGMaterialShader *QWaylandBufferMaterial::createShader(QSGRendererInterface::RenderMode renderMode) const
318{
319 Q_UNUSED(renderMode);
320 return new QWaylandBufferMaterialShader(m_format);
321}
322
323
324void QWaylandBufferMaterial::setTextureParameters(GLenum target)
325{
327 gl->glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
328 gl->glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
329 gl->glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
330 gl->glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
331}
332
333//TODO move this into a separate centralized texture management class
334void QWaylandBufferMaterial::ensureTextures(int count)
335{
336 for (int plane = m_textures.size(); plane < count; plane++) {
337 m_textures << nullptr;
338 m_scenegraphTextures << nullptr;
339 }
340}
341
342void QWaylandBufferMaterial::setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &ref)
343{
344 m_bufferRef = ref;
345 for (int plane = 0; plane < bufferTypes[ref.bufferFormatEgl()].planeCount; plane++) {
346 if (auto texture = ref.toOpenGLTexture(plane)) {
347 QQuickWindow::CreateTextureOptions opt;
348 QWaylandQuickSurface *waylandSurface = qobject_cast<QWaylandQuickSurface *>(surfaceItem->surface());
349 if (waylandSurface != nullptr && waylandSurface->useTextureAlpha() && !waylandSurface->isOpaque())
350 opt |= QQuickWindow::TextureHasAlphaChannel;
351 QSGTexture *scenegraphTexture;
352 if (ref.bufferFormatEgl() == QWaylandBufferRef::BufferFormatEgl_EXTERNAL_OES) {
353 scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNativeExternalOES(texture->textureId(),
354 surfaceItem->window(),
355 ref.size(),
356 opt);
357 } else {
358 scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNative(texture->textureId(),
359 surfaceItem->window(),
360 ref.size(),
361 opt);
362 }
363 scenegraphTexture->setFiltering(surfaceItem->smooth() ? QSGTexture::Linear : QSGTexture::Nearest);
364 setTextureForPlane(plane, texture, scenegraphTexture);
365 }
366 }
367
368 bind();
369}
370#endif // QT_CONFIG(opengl)
371
373
375{
376public:
378 {
379 }
380
382 {
383 delete m_sgTex;
384 }
385
387 {
389 m_ref = buffer;
390 delete m_sgTex;
391 m_sgTex = nullptr;
392 if (m_ref.hasBuffer()) {
393 if (buffer.isSharedMemory()) {
394 m_sgTex = surfaceItem->window()->createTextureFromImage(buffer.image());
395 } else {
396#if QT_CONFIG(opengl)
397 QQuickWindow::CreateTextureOptions opt;
398 QWaylandQuickSurface *surface = qobject_cast<QWaylandQuickSurface *>(surfaceItem->surface());
399 if (surface && surface->useTextureAlpha() && !surface->isOpaque()) {
400 opt |= QQuickWindow::TextureHasAlphaChannel;
401 }
402
403 auto texture = buffer.toOpenGLTexture();
404 GLuint textureId = texture->textureId();
405 auto size = surface->bufferSize();
406 m_sgTex = QNativeInterface::QSGOpenGLTexture::fromNative(textureId, surfaceItem->window(), size, opt);
407#else
408 qCWarning(qLcWaylandCompositor) << "Without OpenGL support only shared memory textures are supported";
409#endif
410 }
411 }
413 }
414
415 QSGTexture *texture() const override
416 {
417 if (m_sgTex)
419 return m_sgTex;
420 }
421
422 void setSmooth(bool smooth) { m_smooth = smooth; }
423private:
424 bool m_smooth = false;
425 QSGTexture *m_sgTex = nullptr;
426 QWaylandBufferRef m_ref;
427};
428
457{
458}
459
464 : QQuickItem(dd, parent)
465{
466 d_func()->init();
467 connect(this, &QQuickItem::activeFocusChanged, this, &QWaylandQuickItem::updateFocus);
468}
469
474{
476 disconnect(this, &QQuickItem::windowChanged, this, &QWaylandQuickItem::updateWindow);
477 disconnect(this, &QQuickItem::activeFocusChanged, this, &QWaylandQuickItem::updateFocus);
478 QMutexLocker locker(d->mutex);
479 if (d->provider) {
480 disconnect(d->texProviderConnection);
481 d->provider->deleteLater();
482 }
483}
484
497{
498 Q_D(const QWaylandQuickItem);
499 return d->view->surface() ? d->view->surface()->compositor() : nullptr;
500}
501
506{
507 Q_D(const QWaylandQuickItem);
508 return d->view.data();
509}
510
524{
525 Q_D(const QWaylandQuickItem);
526 return d->view->surface();
527}
528
530{
532 QWaylandSurface *oldSurf = d->view->surface();
533 QWaylandCompositor *oldComp = d->view->surface() ? d->view->surface()->compositor() : nullptr;
534 d->view->setSurface(surface);
535 QWaylandCompositor *newComp = d->view->surface() ? d->view->surface()->compositor() : nullptr;
536 if (oldComp != newComp)
538 if (oldSurf != surface)
540
541 updateFocus();
542 update();
543}
544
557{
558 Q_D(const QWaylandQuickItem);
559 return d->origin;
560}
561
563{
564 Q_D(const QWaylandQuickItem);
565 return QQuickItem::isTextureProvider() || d->provider;
566}
567
572{
573 Q_D(const QWaylandQuickItem);
574
577
578 return d->provider;
579}
580
585{
587 if (!d->shouldSendInputEvents()) {
588 event->ignore();
589 return;
590 }
591
592 if (!inputRegionContains(event->position())) {
593 event->ignore();
594 return;
595 }
596
597 QWaylandSeat *seat = compositor()->seatFor(event);
598
599 if (d->focusOnClick)
600 takeFocus(seat);
601
602 seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), event->scenePosition());
603 seat->sendMousePressEvent(event->button());
604 d->hoverPos = event->position();
605}
606
611{
613 if (d->shouldSendInputEvents()) {
614 QWaylandSeat *seat = compositor()->seatFor(event);
615#if QT_CONFIG(draganddrop)
616 if (d->isDragging) {
617 QWaylandQuickOutput *currentOutput = qobject_cast<QWaylandQuickOutput *>(view()->output());
618 //TODO: also check if dragging onto other outputs
619 QWaylandQuickItem *targetItem = qobject_cast<QWaylandQuickItem *>(currentOutput->pickClickableItem(mapToScene(event->position())));
620 QWaylandSurface *targetSurface = targetItem ? targetItem->surface() : nullptr;
621 if (targetSurface) {
622 QPointF position = mapToItem(targetItem, event->position());
623 QPointF surfacePosition = targetItem->mapToSurface(position);
624 seat->drag()->dragMove(targetSurface, surfacePosition);
625 }
626 } else
627#endif // QT_CONFIG(draganddrop)
628 {
629 seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), event->scenePosition());
630 d->hoverPos = event->position();
631 }
632 } else {
633 emit mouseMove(event->scenePosition());
634 event->ignore();
635 }
636}
637
642{
644 if (d->shouldSendInputEvents()) {
645 QWaylandSeat *seat = compositor()->seatFor(event);
646#if QT_CONFIG(draganddrop)
647 if (d->isDragging) {
648 d->isDragging = false;
649 seat->drag()->drop();
650 } else
651#endif
652 {
653 seat->sendMouseReleaseEvent(event->button());
654 }
655 } else {
657 event->ignore();
658 }
659}
660
665{
667 if (!inputRegionContains(event->position())) {
668 event->ignore();
669 return;
670 }
671 if (d->shouldSendInputEvents()) {
672 QWaylandSeat *seat = compositor()->seatFor(event);
673 seat->sendMouseMoveEvent(d->view.data(), event->position(), mapToScene(event->position()));
674 d->hoverPos = event->position();
675 } else {
676 event->ignore();
677 }
678}
679
684{
686 if (surface()) {
687 if (!inputRegionContains(event->position())) {
688 event->ignore();
689 return;
690 }
691 }
692 if (d->shouldSendInputEvents()) {
693 QWaylandSeat *seat = compositor()->seatFor(event);
694 if (event->position() != d->hoverPos) {
695 seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), mapToScene(event->position()));
696 d->hoverPos = event->position();
697 }
698 } else {
699 event->ignore();
700 }
701}
702
707{
709 if (d->shouldSendInputEvents()) {
710 QWaylandSeat *seat = compositor()->seatFor(event);
711 seat->setMouseFocus(nullptr);
712 } else {
713 event->ignore();
714 }
715}
716
717#if QT_CONFIG(wheelevent)
721void QWaylandQuickItem::wheelEvent(QWheelEvent *event)
722{
724 if (d->shouldSendInputEvents()) {
725 if (!inputRegionContains(event->position())) {
726 event->ignore();
727 return;
728 }
729
730 QWaylandSeat *seat = compositor()->seatFor(event);
731 // TODO: fix this to send a single event, when diagonal scrolling is supported
732 if (event->angleDelta().x() != 0)
733 seat->sendMouseWheelEvent(Qt::Horizontal, event->angleDelta().x());
734 if (event->angleDelta().y() != 0)
735 seat->sendMouseWheelEvent(Qt::Vertical, event->angleDelta().y());
736 } else {
737 event->ignore();
738 }
739}
740#endif
741
746{
748 if (d->shouldSendInputEvents()) {
749 QWaylandSeat *seat = compositor()->seatFor(event);
750 if (seat->setKeyboardFocus(d->view->surface()))
751 seat->sendFullKeyEvent(event);
752 else
753 qWarning() << "Unable to set keyboard focus, cannot send key press event";
754 } else {
755 event->ignore();
756 }
757}
758
763{
765 if (d->shouldSendInputEvents() && hasFocus()) {
766 QWaylandSeat *seat = compositor()->seatFor(event);
767 seat->sendFullKeyEvent(event);
768 } else {
769 event->ignore();
770 }
771}
772
777{
779 if (d->shouldSendInputEvents() && d->touchEventsEnabled) {
780 QWaylandSeat *seat = compositor()->seatFor(event);
781
782 QPointF pointPos;
783 const QList<QTouchEvent::TouchPoint> &points = event->points();
784 if (!points.isEmpty())
785 pointPos = points.at(0).position();
786
787 if (event->type() == QEvent::TouchBegin && !inputRegionContains(pointPos)) {
788 event->ignore();
789 return;
790 }
791
792 event->accept();
793 if (seat->mouseFocus() != d->view.data()) {
794 seat->sendMouseMoveEvent(d->view.data(), pointPos, mapToScene(pointPos));
795 }
797
798 if (event->type() == QEvent::TouchBegin) {
799 d->touchingSeats.append(seat);
800 } else if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) {
801 d->touchingSeats.removeOne(seat);
802 }
803
804 if (event->type() == QEvent::TouchBegin && d->focusOnClick)
805 takeFocus(seat);
806 } else {
807 event->ignore();
808 }
809}
810
812{
814
815 if (d->shouldSendInputEvents())
816 for (auto seat : d->touchingSeats)
818
819 d->touchingSeats.clear();
820}
821
822#if QT_CONFIG(im)
826void QWaylandQuickItem::inputMethodEvent(QInputMethodEvent *event)
827{
829 if (d->shouldSendInputEvents()) {
830 d->oldSurface->inputMethodControl()->inputMethodEvent(event);
831 } else {
832 event->ignore();
833 }
834}
835#endif
836
841{
842 Q_UNUSED(newSurface);
843 Q_UNUSED(oldSurface);
844}
845
846void QWaylandQuickItem::handleSubsurfaceAdded(QWaylandSurface *childSurface)
847{
849 if (d->subsurfaceHandler.isNull()) {
850 QWaylandQuickItem *childItem = new QWaylandQuickItem;
851 childItem->setSurface(childSurface);
852 childItem->setVisible(true);
853 childItem->setParentItem(this);
854 childItem->setParent(this);
855 connect(childSurface, &QWaylandSurface::subsurfacePositionChanged, childItem, &QWaylandQuickItem::handleSubsurfacePosition);
856 connect(childSurface, &QWaylandSurface::destroyed, childItem, &QObject::deleteLater);
857 } else {
858 bool success = QMetaObject::invokeMethod(d->subsurfaceHandler, "handleSubsurfaceAdded", Q_ARG(QWaylandSurface *, childSurface));
859 if (!success)
860 success = QMetaObject::invokeMethod(d->subsurfaceHandler, "handleSubsurfaceAdded",
861 Q_ARG(QVariant, QVariant::fromValue(childSurface)));
862
863 if (!success)
864 qWarning("QWaylandQuickItem: subsurfaceHandler does not implement handleSubsurfaceAdded()");
865 }
866}
867
868void QWaylandQuickItem::handlePlaceAbove(QWaylandSurface *referenceSurface)
869{
871 auto *parent = qobject_cast<QWaylandQuickItem*>(parentItem());
872 if (!parent)
873 return;
874
875 if (parent->surface() == referenceSurface) {
876 d->placeAboveParent();
877 } else if (auto *sibling = d->findSibling(referenceSurface)) {
878 d->placeAboveSibling(sibling);
879 } else {
880 qWarning() << "Couldn't find QWaylandQuickItem for surface" << referenceSurface
881 << "when handling wl_subsurface.place_above";
882 }
883}
884
885void QWaylandQuickItem::handlePlaceBelow(QWaylandSurface *referenceSurface)
886{
888 QWaylandQuickItem *parent = qobject_cast<QWaylandQuickItem*>(parentItem());
889 if (!parent)
890 return;
891
892 if (parent->surface() == referenceSurface) {
893 d->placeBelowParent();
894 } else if (auto *sibling = d->findSibling(referenceSurface)) {
895 d->placeBelowSibling(sibling);
896 } else {
897 qWarning() << "Couldn't find QWaylandQuickItem for surface" << referenceSurface
898 << "when handling wl_subsurface.place_below";
899 }
900}
901
902void QWaylandQuickItem::updateFocus()
903{
904 Q_D(const QWaylandQuickItem);
905 if (hasActiveFocus() && compositor())
906 compositor()->defaultSeat()->setKeyboardFocus(d->view->surface());
907}
908
934{
935 Q_D(const QWaylandQuickItem);
936 return d->subsurfaceHandler.data();
937}
938
940{
942 if (d->subsurfaceHandler.data() != handler) {
943 d->subsurfaceHandler = handler;
945 }
946}
947
954{
955 Q_D(const QWaylandQuickItem);
956 return d->view->output();
957}
958
960{
962 d->view->setOutput(output);
963}
964
982{
983 Q_D(const QWaylandQuickItem);
984 return d->view->isBufferLocked();
985}
986
988{
990 d->view->setBufferLocked(locked);
991
992 // Apply the latest surface size
993 if (!locked)
994 updateSize();
995}
996
1006{
1007 Q_D(const QWaylandQuickItem);
1008 return d->view->allowDiscardFrontBuffer();
1009}
1010
1012{
1013 Q_D(QWaylandQuickItem);
1014 d->view->setAllowDiscardFrontBuffer(discard);
1015}
1016
1029{
1030 Q_D(QWaylandQuickItem);
1031 d->view->setPrimary();
1032}
1033
1037void QWaylandQuickItem::handleSurfaceChanged()
1038{
1039 Q_D(QWaylandQuickItem);
1040 if (d->oldSurface) {
1041 disconnect(d->oldSurface.data(), &QWaylandSurface::hasContentChanged, this, &QWaylandQuickItem::surfaceMappedChanged);
1042 disconnect(d->oldSurface.data(), &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged);
1043 disconnect(d->oldSurface.data(), &QWaylandSurface::destinationSizeChanged, this, &QWaylandQuickItem::updateSize);
1044 disconnect(d->oldSurface.data(), &QWaylandSurface::bufferScaleChanged, this, &QWaylandQuickItem::updateSize);
1045 disconnect(d->oldSurface.data(), &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
1046 disconnect(d->oldSurface.data(), &QWaylandSurface::redraw, this, &QQuickItem::update);
1047 disconnect(d->oldSurface.data(), &QWaylandSurface::childAdded, this, &QWaylandQuickItem::handleSubsurfaceAdded);
1048 disconnect(d->oldSurface.data(), &QWaylandSurface::subsurfacePlaceAbove, this, &QWaylandQuickItem::handlePlaceAbove);
1049 disconnect(d->oldSurface.data(), &QWaylandSurface::subsurfacePlaceBelow, this, &QWaylandQuickItem::handlePlaceBelow);
1050#if QT_CONFIG(draganddrop)
1051 disconnect(d->oldSurface.data(), &QWaylandSurface::dragStarted, this, &QWaylandQuickItem::handleDragStarted);
1052#endif
1053#if QT_CONFIG(im)
1054 disconnect(d->oldSurface->inputMethodControl(), &QWaylandInputMethodControl::updateInputMethod, this, &QWaylandQuickItem::updateInputMethod);
1055#endif
1056 }
1057 if (QWaylandSurface *newSurface = d->view->surface()) {
1058 connect(newSurface, &QWaylandSurface::hasContentChanged, this, &QWaylandQuickItem::surfaceMappedChanged);
1059 connect(newSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged);
1060 connect(newSurface, &QWaylandSurface::destinationSizeChanged, this, &QWaylandQuickItem::updateSize);
1061 connect(newSurface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandQuickItem::updateSize);
1062 connect(newSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
1064 connect(newSurface, &QWaylandSurface::childAdded, this, &QWaylandQuickItem::handleSubsurfaceAdded);
1065 connect(newSurface, &QWaylandSurface::subsurfacePlaceAbove, this, &QWaylandQuickItem::handlePlaceAbove);
1066 connect(newSurface, &QWaylandSurface::subsurfacePlaceBelow, this, &QWaylandQuickItem::handlePlaceBelow);
1067#if QT_CONFIG(draganddrop)
1068 connect(newSurface, &QWaylandSurface::dragStarted, this, &QWaylandQuickItem::handleDragStarted);
1069#endif
1070#if QT_CONFIG(im)
1071 connect(newSurface->inputMethodControl(), &QWaylandInputMethodControl::updateInputMethod, this, &QWaylandQuickItem::updateInputMethod);
1072#endif
1073
1074 if (newSurface->origin() != d->origin) {
1075 d->origin = newSurface->origin();
1077 }
1078 if (window()) {
1079 QWaylandOutput *output = newSurface->compositor()->outputFor(window());
1080 d->view->setOutput(output);
1081 }
1082 for (auto subsurface : QWaylandSurfacePrivate::get(newSurface)->subsurfaceChildren) {
1083 if (!subsurface.isNull())
1084 handleSubsurfaceAdded(subsurface.data());
1085 }
1086
1087 updateSize();
1088 }
1089 surfaceChangedEvent(d->view->surface(), d->oldSurface);
1090 d->oldSurface = d->view->surface();
1091#if QT_CONFIG(im)
1092 updateInputMethod(Qt::ImQueryInput);
1093#endif
1094}
1095
1101{
1103
1104 if (!surface() || !surface()->client())
1105 return;
1106
1108 if (!target) {
1109 target = compositor()->defaultSeat();
1110 }
1111 target->setKeyboardFocus(surface());
1112
1113 qCDebug(qLcWaylandCompositorInputMethods) << Q_FUNC_INFO << " surface:" << surface()
1114 << ", client:" << surface()->client()
1115 << ", textinputprotocol:" << (int)(surface()->client()->textInputProtocols());
1118 if (textInput)
1119 textInput->setFocus(surface());
1120 }
1121
1122#if QT_WAYLAND_TEXT_INPUT_V4_WIP
1123 if (surface()->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV4)) {
1125 if (textInputV4)
1126 textInputV4->setFocus(surface());
1127 }
1128#endif // QT_WAYLAND_TEXT_INPUT_V4_WIP
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
@ TouchCancel
Definition qcoreevent.h:264
@ TouchBegin
Definition qcoreevent.h:241
\inmodule QtCore
Definition qfile.h:93
\inmodule QtGui
Definition qevent.h:245
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:624
The QKeyEvent class describes a key event.
Definition qevent.h:423
Definition qlist.h:74
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
\inmodule QtGui
Definition qevent.h:195
\inmodule QtCore
Definition qmutex.h:317
\inmodule QtCore
Definition qmutex.h:285
QObject * parent
Definition qobject.h:61
\inmodule QtCore
Definition qobject.h:90
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
void setParent(QObject *parent)
Makes the object a child of parent.
Definition qobject.cpp:2142
QThread * thread() const
Returns the thread in which the object lives.
Definition qobject.cpp:1561
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:2352
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
QOpenGLFunctions * functions() const
Get the QOpenGLFunctions instance for this context.
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:214
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:333
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:338
\inmodule QtCore\reentrant
Definition qpoint.h:23
QQuickWindow * window
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:64
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...
void setParentItem(QQuickItem *parent)
qreal z
\qmlproperty real QtQuick::Item::z
Definition qquickitem.h:75
bool hasActiveFocus() const
virtual QSGTextureProvider * textureProvider() const
Returns the texture provider for an item.
bool hasFocus() const
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:76
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:68
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:111
qreal height
This property holds the height of this item.
Definition qquickitem.h:77
void setPosition(const QPointF &)
bool enabled
\qmlproperty bool QtQuick::Item::enabled
Definition qquickitem.h:80
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:483
constexpr qreal y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:658
constexpr qreal height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:718
constexpr qreal width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:715
constexpr qreal x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:655
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
Definition qrect.h:652
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:762
The QSGGeometryNode class is used for all rendered content in the scene graph.
Definition qsgnode.h:191
QSGMaterial * material() const
Returns the material of the QSGGeometryNode.
Definition qsgnode.h:197
void setMaterial(QSGMaterial *material)
Sets the material of this geometry node to material.
Definition qsgnode.cpp:925
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:584
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.
void textureChanged()
This signal is emitted when the texture changes.
\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:174
\inmodule QtGui
Definition qshader.h:32
\inmodule QtGui
Definition qshader.h:81
void setShader(const QShaderKey &key, const QShaderCode &shader)
Stores the source or binary shader code for a given shader version specified by key.
Definition qshader.cpp:373
@ GlslShader
Definition qshader.h:94
void setDescription(const QShaderDescription &desc)
Sets the reflection metadata to desc.
Definition qshader.cpp:348
@ FragmentStage
Definition qshader.h:88
void setStage(Stage stage)
Sets the pipeline stage.
Definition qshader.cpp:329
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:132
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:129
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5710
static QThread * currentThread()
Definition qthread.cpp:966
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:916
\inmodule QtCore
Definition qvariant.h:64
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:531
\inmodule QtWaylandCompositor
bool hasBuffer() const
Returns true if this QWaylandBufferRef references a buffer.
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
This property holds the output on which this item is displayed.
~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)
QQuickItem * pickClickableItem(const QPointF &position)
\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:98
@ Vertical
Definition qnamespace.h:99
@ DirectConnection
#define Q_FALLTHROUGH()
#define Q_FUNC_INFO
static QDBusError::ErrorType get(const char *name)
#define qWarning
Definition qlogging.h:162
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_ARG(Type, data)
Definition qobjectdefs.h:62
const GLfloat * m
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
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 GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint ref
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
struct _cl_event * event
GLfixed GLfixed GLint GLint GLfixed points
GLenum query
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLdouble s
[6]
Definition qopenglext.h:235
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)
@ desc
double qreal
Definition qtypes.h:92
QT_BEGIN_NAMESPACE typedef uchar * output
#define GL_TEXTURE_EXTERNAL_OES
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
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent