OpenCoverage

qquickwindow_p.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickwindow_p.h
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQuick module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#ifndef QQUICKWINDOW_P_H-
41#define QQUICKWINDOW_P_H-
42-
43//-
44// W A R N I N G-
45// --------------
46//-
47// This file is not part of the Qt API. It exists purely as an-
48// implementation detail. This header file may change from version to-
49// version without notice, or even be removed.-
50//-
51// We mean it.-
52//-
53-
54#include "qquickitem.h"-
55#include "qquickwindow.h"-
56#include "qquickevents_p_p.h"-
57-
58#include <QtQuick/private/qsgcontext_p.h>-
59-
60#include <QtCore/qthread.h>-
61#include <QtCore/qmutex.h>-
62#include <QtCore/qwaitcondition.h>-
63#include <QtCore/qrunnable.h>-
64#include <private/qwindow_p.h>-
65#include <private/qopengl_p.h>-
66#include <qopenglcontext.h>-
67#include <QtGui/qopenglframebufferobject.h>-
68#include <QtGui/qevent.h>-
69#include <QtGui/qstylehints.h>-
70#include <QtGui/qguiapplication.h>-
71-
72QT_BEGIN_NAMESPACE-
73-
74class QOpenGLVertexArrayObjectHelper;-
75class QQuickAnimatorController;-
76class QQuickDragGrabber;-
77class QQuickItemPrivate;-
78class QQuickPointerDevice;-
79class QQuickRenderControl;-
80class QQuickWindowIncubationController;-
81class QQuickWindowPrivate;-
82class QQuickWindowRenderLoop;-
83class QSGRenderLoop;-
84class QTouchEvent;-
85-
86//Make it easy to identify and customize the root item if needed-
87class QQuickRootItem : public QQuickItem-
88{-
89 Q_OBJECT-
90public:-
91 QQuickRootItem();-
92public Q_SLOTS:-
93 void setWidth(int w) {QQuickItem::setWidth(qreal(w));}
never executed: end of block
0
94 void setHeight(int h) {QQuickItem::setHeight(qreal(h));}
never executed: end of block
0
95};-
96-
97class Q_QUICK_PRIVATE_EXPORT QQuickCustomRenderStage-
98{-
99public:-
100 virtual ~QQuickCustomRenderStage() {}-
101 virtual bool render() = 0;-
102 virtual bool swap() = 0;-
103};-
104-
105class Q_QUICK_PRIVATE_EXPORT QQuickWindowPrivate : public QWindowPrivate-
106{-
107public:-
108 Q_DECLARE_PUBLIC(QQuickWindow)-
109-
110 enum CustomEvents {-
111 FullUpdateRequest = QEvent::User + 1-
112 };-
113-
114 static inline QQuickWindowPrivate *get(QQuickWindow *c) { return c->d_func(); }
executed 4720632 times by 91 tests: return c->d_func();
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • tst_qquickdroparea
  • ...
4720632
115-
116 QQuickWindowPrivate();-
117 ~QQuickWindowPrivate() override;-
118-
119 void init(QQuickWindow *, QQuickRenderControl *control = nullptr);-
120-
121 QQuickRootItem *contentItem;-
122 QSet<QQuickItem *> parentlessItems;-
123 QQmlListProperty<QObject> data();-
124-
125 QQuickItem *activeFocusItem;-
126-
127 void deliverKeyEvent(QKeyEvent *e);-
128-
129 // Keeps track of the item currently receiving mouse events-
130#if QT_CONFIG(cursor)-
131 QQuickItem *cursorItem;-
132#endif-
133#if QT_CONFIG(draganddrop)-
134 QQuickDragGrabber *dragGrabber;-
135#endif-
136 int touchMouseId;-
137 QQuickPointerDevice *touchMouseDevice;-
138 bool checkIfDoubleClicked(ulong newPressEventTimestamp);-
139 ulong touchMousePressTimestamp;-
140-
141 // Mouse positions are saved in widget coordinates-
142 QPointF lastMousePosition;-
143 bool deliverTouchAsMouse(QQuickItem *item, QQuickPointerEvent *pointerEvent);-
144 bool isDeliveringTouchAsMouse() const { return touchMouseId != -1 && touchMouseDevice; }
executed 480365 times by 91 tests: return touchMouseId != -1 && touchMouseDevice;
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • tst_qquickdroparea
  • ...
480365
145 void translateTouchEvent(QTouchEvent *touchEvent);-
146 void grabTouchPoints(QObject *grabber, const QVector<int> &ids);-
147 void removeGrabber(QQuickItem *grabber, bool mouse = true, bool touch = true);-
148 void sendUngrabEvent(QQuickItem *grabber, bool touch);-
149 static QMouseEvent *cloneMouseEvent(QMouseEvent *event, QPointF *transformedLocalPos = nullptr);-
150 void deliverToPassiveGrabbers(const QVector<QPointer <QQuickPointerHandler> > &passiveGrabbers, QQuickPointerEvent *pointerEvent);-
151 void deliverMouseEvent(QQuickPointerMouseEvent *pointerEvent);-
152 bool sendFilteredMouseEvent(QEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);-
153 bool sendFilteredPointerEvent(QQuickPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent = nullptr);-
154 bool sendFilteredPointerEventImpl(QQuickPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);-
155 bool deliverSinglePointEventUntilAccepted(QQuickPointerEvent *);-
156-
157 // entry point of events to the window-
158 void handleTouchEvent(QTouchEvent *);-
159 void handleMouseEvent(QMouseEvent *);-
160 bool compressTouchEvent(QTouchEvent *);-
161 void flushFrameSynchronousEvents();-
162 void deliverDelayedTouchEvent();-
163-
164 // the device-specific event instances which are reused during event delivery-
165 mutable QVector<QQuickPointerEvent *> pointerEventInstances;-
166 QQuickPointerEvent *queryPointerEventInstance(QQuickPointerDevice *device, QEvent::Type eventType = QEvent::None) const;-
167 QQuickPointerEvent *pointerEventInstance(QQuickPointerDevice *device, QEvent::Type eventType = QEvent::None) const;-
168-
169 // delivery of pointer events:-
170 QQuickPointerEvent *pointerEventInstance(QEvent *ev) const;-
171 void deliverPointerEvent(QQuickPointerEvent *);-
172 void deliverTouchEvent(QQuickPointerTouchEvent *);-
173 bool deliverTouchCancelEvent(QTouchEvent *);-
174 bool deliverPressOrReleaseEvent(QQuickPointerEvent *, bool handlersOnly = false);-
175 void deliverUpdatedTouchPoints(QQuickPointerTouchEvent *event);-
176 void deliverMatchingPointsToItem(QQuickItem *item, QQuickPointerEvent *pointerEvent, bool handlersOnly = false);-
177-
178 QVector<QQuickItem *> pointerTargets(QQuickItem *, QQuickEventPoint *point, bool checkMouseButtons, bool checkAcceptsTouch) const;-
179 QVector<QQuickItem *> mergePointerTargets(const QVector<QQuickItem *> &list1, const QVector<QQuickItem *> &list2) const;-
180-
181 // hover delivery-
182 bool deliverHoverEvent(QQuickItem *, const QPointF &scenePos, const QPointF &lastScenePos, Qt::KeyboardModifiers modifiers, ulong timestamp, bool &accepted);-
183 bool sendHoverEvent(QEvent::Type, QQuickItem *, const QPointF &scenePos, const QPointF &lastScenePos,-
184 Qt::KeyboardModifiers modifiers, ulong timestamp, bool accepted);-
185 bool clearHover(ulong timestamp = 0);-
186-
187#if QT_CONFIG(draganddrop)-
188 void deliverDragEvent(QQuickDragGrabber *, QEvent *);-
189 bool deliverDragEvent(QQuickDragGrabber *, QQuickItem *, QDragMoveEvent *);-
190#endif-
191#if QT_CONFIG(cursor)-
192 void updateCursor(const QPointF &scenePos);-
193 QQuickItem *findCursorItem(QQuickItem *item, const QPointF &scenePos);-
194#endif-
195-
196 QList<QQuickItem*> hoverItems;-
197 enum FocusOption {-
198 DontChangeFocusProperty = 0x01,-
199 DontChangeSubFocusItem = 0x02-
200 };-
201 Q_DECLARE_FLAGS(FocusOptions, FocusOption)-
202-
203 void setFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = nullptr);-
204 void clearFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = nullptr);-
205 static void notifyFocusChangesRecur(QQuickItem **item, int remaining);-
206 void clearFocusObject() override;-
207-
208 void updateFocusItemTransform();-
209-
210 void dirtyItem(QQuickItem *);-
211 void cleanup(QSGNode *);-
212-
213 void polishItems();-
214 void forcePolish();-
215 void syncSceneGraph();-
216 void renderSceneGraph(const QSize &size);-
217-
218 bool isRenderable() const;-
219-
220 bool emitError(QQuickWindow::SceneGraphError error, const QString &msg);-
221-
222 QQuickItem::UpdatePaintNodeData updatePaintNodeData;-
223-
224 QQuickItem *dirtyItemList;-
225 QList<QSGNode *> cleanupNodeList;-
226-
227 QVector<QQuickItem *> itemsToPolish;-
228 QVector<QQuickItem *> hasFiltered; // during event delivery to a single receiver, the filtering parents for which childMouseEventFilter was already called-
229 QVector<QQuickItem *> skipDelivery; // during delivery of one event to all receivers, Items to which we know delivery is no longer necessary-
230-
231 qreal devicePixelRatio;-
232 QMetaObject::Connection physicalDpiChangedConnection;-
233-
234 void updateDirtyNodes();-
235 void cleanupNodes();-
236 void cleanupNodesOnShutdown();-
237 bool updateEffectiveOpacity(QQuickItem *);-
238 void updateEffectiveOpacityRoot(QQuickItem *, qreal);-
239 void updateDirtyNode(QQuickItem *);-
240-
241 void fireFrameSwapped() { Q_EMIT q_func()->frameSwapped(); }
executed 49429 times by 76 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • ...
49429
242 void fireOpenGLContextCreated(QOpenGLContext *context) { Q_EMIT q_func()->openglContextCreated(context); }
executed 3102 times by 75 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • ...
3102
243 void fireAboutToStop() { Q_EMIT q_func()->sceneGraphAboutToStop(); }
executed 5722 times by 91 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • tst_qquickdroparea
  • ...
5722
244-
245 QSGRenderContext *context;-
246 QSGRenderer *renderer;-
247 QByteArray customRenderMode; // Default renderer supports "clip", "overdraw", "changes", "batches" and blank.-
248-
249 QSGRenderLoop *windowManager;-
250 QQuickRenderControl *renderControl;-
251 QQuickAnimatorController *animationController;-
252 QScopedPointer<QTouchEvent> delayedTouch;-
253-
254 int pointerEventRecursionGuard;-
255 QQuickCustomRenderStage *customRenderStage;-
256-
257 QColor clearColor;-
258-
259 uint clearBeforeRendering : 1;-
260-
261 uint persistentGLContext : 1;-
262 uint persistentSceneGraph : 1;-
263-
264 uint lastWheelEventAccepted : 1;-
265 bool componentCompleted : 1;-
266-
267 bool allowChildEventFiltering : 1;-
268 bool allowDoubleClick : 1;-
269-
270 Qt::FocusReason lastFocusReason;-
271-
272 QOpenGLFramebufferObject *renderTarget;-
273 uint renderTargetId;-
274 QSize renderTargetSize;-
275-
276 QOpenGLVertexArrayObjectHelper *vaoHelper;-
277-
278 mutable QQuickWindowIncubationController *incubationController;-
279-
280 static bool defaultAlphaBuffer;-
281 static QQuickWindow::TextRenderType textRenderType;-
282-
283 static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold = -1);-
284-
285 template <typename TEventPoint>-
286 static bool dragOverThreshold(qreal d, Qt::Axis axis, const TEventPoint *p, int startDragThreshold = -1)-
287 {-
288 QStyleHints *styleHints = qApp->styleHints();-
289 bool overThreshold = qAbs(d) > (startDragThreshold >= 0 ? startDragThreshold : styleHints->startDragDistance());-
290 const bool dragVelocityLimitAvailable = (styleHints->startDragVelocity() > 0);-
291 if (!overThreshold && dragVelocityLimitAvailable) {
!overThresholdDescription
TRUEevaluated 4456 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 552 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
dragVelocityLimitAvailableDescription
TRUEnever evaluated
FALSEevaluated 4456 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
0-4456
292 qreal velocity = axis == Qt::XAxis ? p->velocity().x() : p->velocity().y();
axis == Qt::XAxisDescription
TRUEnever evaluated
FALSEnever evaluated
0
293 overThreshold |= qAbs(velocity) > styleHints->startDragVelocity();-
294 }
never executed: end of block
0
295 return overThreshold;
executed 5008 times by 4 tests: return overThreshold;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
5008
296 }-
297-
298 static bool dragOverThreshold(const QQuickEventPoint *point)-
299 {-
300 QPointF delta = point->scenePosition() - point->scenePressPosition();-
301 return (QQuickWindowPrivate::dragOverThreshold(delta.x(), Qt::XAxis, point) ||
executed 4 times by 1 test: return (QQuickWindowPrivate::dragOverThreshold(delta.x(), Qt::XAxis, point) || QQuickWindowPrivate::dragOverThreshold(delta.y(), Qt::YAxis, point));
Executed by:
  • tst_multipointtoucharea_interop
4
302 QQuickWindowPrivate::dragOverThreshold(delta.y(), Qt::YAxis, point));
executed 4 times by 1 test: return (QQuickWindowPrivate::dragOverThreshold(delta.x(), Qt::XAxis, point) || QQuickWindowPrivate::dragOverThreshold(delta.y(), Qt::YAxis, point));
Executed by:
  • tst_multipointtoucharea_interop
4
303 }-
304-
305-
306 // data property-
307 static void data_append(QQmlListProperty<QObject> *, QObject *);-
308 static int data_count(QQmlListProperty<QObject> *);-
309 static QObject *data_at(QQmlListProperty<QObject> *, int);-
310 static void data_clear(QQmlListProperty<QObject> *);-
311-
312 static void contextCreationFailureMessage(const QSurfaceFormat &format,-
313 QString *translatedMessage,-
314 QString *untranslatedMessage,-
315 bool isEs);-
316-
317 QMutex renderJobMutex;-
318 QList<QRunnable *> beforeSynchronizingJobs;-
319 QList<QRunnable *> afterSynchronizingJobs;-
320 QList<QRunnable *> beforeRenderingJobs;-
321 QList<QRunnable *> afterRenderingJobs;-
322 QList<QRunnable *> afterSwapJobs;-
323-
324 void runAndClearJobs(QList<QRunnable *> *jobs);-
325-
326private:-
327 static void cleanupNodesOnShutdown(QQuickItem *);-
328};-
329-
330class QQuickWindowQObjectCleanupJob : public QRunnable-
331{-
332public:-
333 QQuickWindowQObjectCleanupJob(QObject *o) : object(o) { }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshadereffect
2
334 void run() override { delete object; }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshadereffect
2
335 QObject *object;-
336 static void schedule(QQuickWindow *window, QObject *object) {-
337 Q_ASSERT(window);-
338 Q_ASSERT(object);-
339 window->scheduleRenderJob(new QQuickWindowQObjectCleanupJob(object), QQuickWindow::AfterSynchronizingStage);-
340 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshadereffect
2
341};-
342-
343Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickWindowPrivate::FocusOptions)-
344-
345QT_END_NAMESPACE-
346-
347#endif // QQUICKWINDOW_P_H-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0