qwindow.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qwindow.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://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 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qwindow.h"-
35-
36#include <qpa/qplatformwindow.h>-
37#include <qpa/qplatformintegration.h>-
38#include "qsurfaceformat.h"-
39#ifndef QT_NO_OPENGL-
40#include <qpa/qplatformopenglcontext.h>-
41#include "qopenglcontext.h"-
42#endif-
43#include "qscreen.h"-
44-
45#include "qwindow_p.h"-
46#include "qguiapplication_p.h"-
47#ifndef QT_NO_ACCESSIBILITY-
48# include "qaccessible.h"-
49#endif-
50#include "qhighdpiscaling_p.h"-
51-
52#include <private/qevent_p.h>-
53-
54#include <QtCore/QTimer>-
55#include <QtCore/QDebug>-
56-
57#include <QStyleHints>-
58#include <qpa/qplatformcursor.h>-
59-
60QT_BEGIN_NAMESPACE-
61-
62/*!-
63 \class QWindow-
64 \inmodule QtGui-
65 \since 5.0-
66 \brief The QWindow class represents a window in the underlying windowing system.-
67-
68 A window that is supplied a parent becomes a native child window of-
69 their parent window.-
70-
71 An application will typically use QWidget or QQuickView for its UI, and not-
72 QWindow directly. Still, it is possible to render directly to a QWindow-
73 with QBackingStore or QOpenGLContext, when wanting to keep dependencies to-
74 a minimum or when wanting to use OpenGL directly. The-
75 \l{Raster Window Example} and \l{OpenGL Window Example}-
76 are useful reference examples for how to render to a QWindow using-
77 either approach.-
78-
79 \section1 Resource Management-
80-
81 Windows can potentially use a lot of memory. A usual measurement is-
82 width times height times color depth. A window might also include multiple-
83 buffers to support double and triple buffering, as well as depth and stencil-
84 buffers. To release a window's memory resources, call the destroy() function.-
85-
86 \section1 Content Orientation-
87-
88 QWindow has reportContentOrientationChange() that can be used to specify-
89 the layout of the window contents in relation to the screen. The content-
90 orientation is simply a hint to the windowing system about which-
91 orientation the window contents are in. It's useful when you wish to keep-
92 the same window size, but rotate the contents instead, especially when-
93 doing rotation animations between different orientations. The windowing-
94 system might use this value to determine the layout of system popups or-
95 dialogs.-
96-
97 \section1 Visibility and Windowing System Exposure-
98-
99 By default, the window is not visible, and you must call setVisible(true),-
100 or show() or similar to make it visible. To make a window hidden again,-
101 call setVisible(false) or hide(). The visible property describes the state-
102 the application wants the window to be in. Depending on the underlying-
103 system, a visible window might still not be shown on the screen. It could,-
104 for instance, be covered by other opaque windows or moved outside the-
105 physical area of the screen. On windowing systems that have exposure-
106 notifications, the isExposed() accessor describes whether the window should-
107 be treated as directly visible on screen. The exposeEvent() function is-
108 called whenever the windows exposure in the windowing system changes. On-
109 windowing systems that do not make this information visible to the-
110 application, isExposed() will simply return the same value as isVisible().-
111-
112 QWindow::Visibility queried through visibility() is a convenience API-
113 combining the functions of visible() and windowState().-
114-
115 \section1 Rendering-
116-
117 There are two Qt APIs that can be used to render content into a window,-
118 QBackingStore for rendering with a QPainter and flushing the contents-
119 to a window with type QSurface::RasterSurface, and QOpenGLContext for-
120 rendering with OpenGL to a window with type QSurface::OpenGLSurface.-
121-
122 The application can start rendering as soon as isExposed() returns \c true,-
123 and can keep rendering until it isExposed() returns \c false. To find out when-
124 isExposed() changes, reimplement exposeEvent(). The window will always get-
125 a resize event before the first expose event.-
126-
127 \section1 Initial Geometry-
128-
129 If the window's width and height are left uninitialized, the window will-
130 get a reasonable default geometry from the platform window. If the position-
131 is left uninitialized, then the platform window will allow the windowing-
132 system to position the window. For example on X11, the window manager-
133 usually does some kind of smart positioning to try to avoid having new-
134 windows completely obscure existing windows. However setGeometry()-
135 initializes both the position and the size, so if you want a fixed size but-
136 an automatic position, you should call resize() or setWidth() and-
137 setHeight() instead.-
138*/-
139-
140/*!-
141 Creates a window as a top level on the \a targetScreen.-
142-
143 The window is not shown until setVisible(true), show(), or similar is called.-
144-
145 \sa setScreen()-
146*/-
147QWindow::QWindow(QScreen *targetScreen)-
148 : QObject(*new QWindowPrivate(), 0)-
149 , QSurface(QSurface::Window)-
150{-
151 Q_D(QWindow);-
152 d->connectToScreen(targetScreen ? targetScreen : QGuiApplication::primaryScreen());-
153 d->init();-
154}
never executed: end of block
0
155-
156/*!-
157 Creates a window as a child of the given \a parent window.-
158-
159 The window will be embedded inside the parent window, its coordinates-
160 relative to the parent.-
161-
162 The screen is inherited from the parent.-
163-
164 \sa setParent()-
165*/-
166QWindow::QWindow(QWindow *parent)-
167 : QObject(*new QWindowPrivate(), parent)-
168 , QSurface(QSurface::Window)-
169{-
170 Q_D(QWindow);-
171 d->parentWindow = parent;-
172 if (!parent)
!parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
173 d->connectToScreen(QGuiApplication::primaryScreen());
never executed: d->connectToScreen(QGuiApplication::primaryScreen());
0
174 d->init();-
175}
never executed: end of block
0
176-
177/*!-
178 Creates a window as a child of the given \a parent window with the \a dd-
179 private implementation.-
180-
181 The window will be embedded inside the parent window, its coordinates-
182 relative to the parent.-
183-
184 The screen is inherited from the parent.-
185-
186 \internal-
187 \sa setParent()-
188*/-
189QWindow::QWindow(QWindowPrivate &dd, QWindow *parent)-
190 : QObject(dd, parent)-
191 , QSurface(QSurface::Window)-
192{-
193 Q_D(QWindow);-
194 d->parentWindow = parent;-
195 if (!parent)
!parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
196 d->connectToScreen(QGuiApplication::primaryScreen());
never executed: d->connectToScreen(QGuiApplication::primaryScreen());
0
197 d->init();-
198}
never executed: end of block
0
199-
200/*!-
201 Destroys the window.-
202*/-
203QWindow::~QWindow()-
204{-
205 destroy();-
206 QGuiApplicationPrivate::window_list.removeAll(this);-
207 if (!QGuiApplicationPrivate::is_app_closing)
!QGuiApplicati...is_app_closingDescription
TRUEnever evaluated
FALSEnever evaluated
0
208 QGuiApplicationPrivate::instance()->modalWindowList.removeOne(this);
never executed: QGuiApplicationPrivate::instance()->modalWindowList.removeOne(this);
0
209}
never executed: end of block
0
210-
211void QWindowPrivate::init()-
212{-
213 Q_Q(QWindow);-
214-
215 // If your application aborts here, you are probably creating a QWindow-
216 // before the screen list is populated.-
217 if (!parentWindow && !topLevelScreen) {
!parentWindowDescription
TRUEnever evaluated
FALSEnever evaluated
!topLevelScreenDescription
TRUEnever evaluated
FALSEnever evaluated
0
218 qFatal("Cannot create window: no screens available");-
219 exit(1);
never executed: exit(1);
0
220 }-
221 QGuiApplicationPrivate::window_list.prepend(q);-
222-
223 requestedFormat = QSurfaceFormat::defaultFormat();-
224}
never executed: end of block
0
225-
226/*!-
227 \enum QWindow::Visibility-
228 \since 5.1-
229-
230 This enum describes what part of the screen the window occupies or should-
231 occupy.-
232-
233 \value Windowed The window occupies part of the screen, but not necessarily-
234 the entire screen. This state will occur only on windowing systems which-
235 support showing multiple windows simultaneously. In this state it is-
236 possible for the user to move and resize the window manually, if-
237 WindowFlags permit it and if it is supported by the windowing system.-
238-
239 \value Minimized The window is reduced to an entry or icon on the task bar,-
240 dock, task list or desktop, depending on how the windowing system handles-
241 minimized windows.-
242-
243 \value Maximized The window occupies one entire screen, and the titlebar is-
244 still visible. On most windowing systems this is the state achieved by-
245 clicking the maximize button on the toolbar.-
246-
247 \value FullScreen The window occupies one entire screen, is not resizable,-
248 and there is no titlebar. On some platforms which do not support showing-
249 multiple simultaneous windows, this can be the usual visibility when the-
250 window is not hidden.-
251-
252 \value AutomaticVisibility This means to give the window a default visible-
253 state, which might be fullscreen or windowed depending on the platform.-
254 It can be given as a parameter to setVisibility but will never be-
255 read back from the visibility accessor.-
256-
257 \value Hidden The window is not visible in any way, however it may remember-
258 a latent visibility which can be restored by setting AutomaticVisibility.-
259*/-
260-
261/*!-
262 \property QWindow::visibility-
263 \brief the screen-occupation state of the window-
264 \since 5.1-
265-
266 Visibility is whether the window should appear in the windowing system as-
267 normal, minimized, maximized, fullscreen or hidden.-
268-
269 To set the visibility to AutomaticVisibility means to give the window-
270 a default visible state, which might be fullscreen or windowed depending on-
271 the platform.-
272 When reading the visibility property you will always get the actual state,-
273 never AutomaticVisibility.-
274*/-
275QWindow::Visibility QWindow::visibility() const-
276{-
277 Q_D(const QWindow);-
278 return d->visibility;
never executed: return d->visibility;
0
279}-
280-
281void QWindow::setVisibility(Visibility v)-
282{-
283 switch (v) {-
284 case Hidden:
never executed: case Hidden:
0
285 hide();-
286 break;
never executed: break;
0
287 case AutomaticVisibility:
never executed: case AutomaticVisibility:
0
288 show();-
289 break;
never executed: break;
0
290 case Windowed:
never executed: case Windowed:
0
291 showNormal();-
292 break;
never executed: break;
0
293 case Minimized:
never executed: case Minimized:
0
294 showMinimized();-
295 break;
never executed: break;
0
296 case Maximized:
never executed: case Maximized:
0
297 showMaximized();-
298 break;
never executed: break;
0
299 case FullScreen:
never executed: case FullScreen:
0
300 showFullScreen();-
301 break;
never executed: break;
0
302 default:
never executed: default:
0
303 Q_ASSERT(false);-
304 break;
never executed: break;
0
305 }-
306}-
307-
308void QWindowPrivate::updateVisibility()-
309{-
310 Q_Q(QWindow);-
311-
312 QWindow::Visibility old = visibility;-
313-
314 if (visible) {
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
315 switch (windowState) {-
316 case Qt::WindowMinimized:
never executed: case Qt::WindowMinimized:
0
317 visibility = QWindow::Minimized;-
318 break;
never executed: break;
0
319 case Qt::WindowMaximized:
never executed: case Qt::WindowMaximized:
0
320 visibility = QWindow::Maximized;-
321 break;
never executed: break;
0
322 case Qt::WindowFullScreen:
never executed: case Qt::WindowFullScreen:
0
323 visibility = QWindow::FullScreen;-
324 break;
never executed: break;
0
325 case Qt::WindowNoState:
never executed: case Qt::WindowNoState:
0
326 visibility = QWindow::Windowed;-
327 break;
never executed: break;
0
328 default:
never executed: default:
0
329 Q_ASSERT(false);-
330 break;
never executed: break;
0
331 }-
332 } else {-
333 visibility = QWindow::Hidden;-
334 }
never executed: end of block
0
335-
336 if (visibility != old)
visibility != oldDescription
TRUEnever evaluated
FALSEnever evaluated
0
337 emit q->visibilityChanged(visibility);
never executed: q->visibilityChanged(visibility);
0
338}
never executed: end of block
0
339-
340inline bool QWindowPrivate::windowRecreationRequired(QScreen *newScreen) const-
341{-
342 Q_Q(const QWindow);-
343 const QScreen *oldScreen = q->screen();-
344 return oldScreen != newScreen && (platformWindow || !oldScreen)
never executed: return oldScreen != newScreen && (platformWindow || !oldScreen) && !(oldScreen && oldScreen->virtualSiblings().contains(newScreen));
oldScreen != newScreenDescription
TRUEnever evaluated
FALSEnever evaluated
platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
!oldScreenDescription
TRUEnever evaluated
FALSEnever evaluated
0
345 && !(oldScreen && oldScreen->virtualSiblings().contains(newScreen));
never executed: return oldScreen != newScreen && (platformWindow || !oldScreen) && !(oldScreen && oldScreen->virtualSiblings().contains(newScreen));
oldScreenDescription
TRUEnever evaluated
FALSEnever evaluated
oldScreen->vir...ins(newScreen)Description
TRUEnever evaluated
FALSEnever evaluated
0
346}-
347-
348inline void QWindowPrivate::disconnectFromScreen()-
349{-
350 if (topLevelScreen)
topLevelScreenDescription
TRUEnever evaluated
FALSEnever evaluated
0
351 topLevelScreen = 0;
never executed: topLevelScreen = 0;
0
352}
never executed: end of block
0
353-
354void QWindowPrivate::connectToScreen(QScreen *screen)-
355{-
356 disconnectFromScreen();-
357 topLevelScreen = screen;-
358}
never executed: end of block
0
359-
360void QWindowPrivate::emitScreenChangedRecursion(QScreen *newScreen)-
361{-
362 Q_Q(QWindow);-
363 emit q->screenChanged(newScreen);-
364 foreach (QObject *child, q->children()) {-
365 if (child->isWindowType())
child->isWindowType()Description
TRUEnever evaluated
FALSEnever evaluated
0
366 static_cast<QWindow *>(child)->d_func()->emitScreenChangedRecursion(newScreen);
never executed: static_cast<QWindow *>(child)->d_func()->emitScreenChangedRecursion(newScreen);
0
367 }
never executed: end of block
0
368}
never executed: end of block
0
369-
370void QWindowPrivate::setTopLevelScreen(QScreen *newScreen, bool recreate)-
371{-
372 Q_Q(QWindow);-
373 if (parentWindow) {
parentWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
374 qWarning() << q << '(' << newScreen << "): Attempt to set a screen on a child window.";-
375 return;
never executed: return;
0
376 }-
377 if (newScreen != topLevelScreen) {
newScreen != topLevelScreenDescription
TRUEnever evaluated
FALSEnever evaluated
0
378 const bool shouldRecreate = recreate && windowRecreationRequired(newScreen);
recreateDescription
TRUEnever evaluated
FALSEnever evaluated
windowRecreati...red(newScreen)Description
TRUEnever evaluated
FALSEnever evaluated
0
379 const bool shouldShow = visibilityOnDestroy && !topLevelScreen;
visibilityOnDestroyDescription
TRUEnever evaluated
FALSEnever evaluated
!topLevelScreenDescription
TRUEnever evaluated
FALSEnever evaluated
0
380 if (shouldRecreate && platformWindow)
shouldRecreateDescription
TRUEnever evaluated
FALSEnever evaluated
platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
381 q->destroy();
never executed: q->destroy();
0
382 connectToScreen(newScreen);-
383 if (shouldShow)
shouldShowDescription
TRUEnever evaluated
FALSEnever evaluated
0
384 q->setVisible(true);
never executed: q->setVisible(true);
0
385 else if (newScreen && shouldRecreate)
newScreenDescription
TRUEnever evaluated
FALSEnever evaluated
shouldRecreateDescription
TRUEnever evaluated
FALSEnever evaluated
0
386 create(true);
never executed: create(true);
0
387 emitScreenChangedRecursion(newScreen);-
388 }
never executed: end of block
0
389}
never executed: end of block
0
390-
391void QWindowPrivate::create(bool recursive)-
392{-
393 Q_Q(QWindow);-
394 if (platformWindow)
platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
395 return;
never executed: return;
0
396-
397 platformWindow = QGuiApplicationPrivate::platformIntegration()->createPlatformWindow(q);-
398 Q_ASSERT(platformWindow);-
399-
400 if (!platformWindow) {
!platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
401 qWarning() << "Failed to create platform window for" << q << "with flags" << q->flags();-
402 return;
never executed: return;
0
403 }-
404-
405 QObjectList childObjects = q->children();-
406 for (int i = 0; i < childObjects.size(); i ++) {
i < childObjects.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
407 QObject *object = childObjects.at(i);-
408 if (object->isWindowType()) {
object->isWindowType()Description
TRUEnever evaluated
FALSEnever evaluated
0
409 QWindow *window = static_cast<QWindow *>(object);-
410 if (recursive)
recursiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
411 window->d_func()->create(true);
never executed: window->d_func()->create(true);
0
412 if (window->d_func()->platformWindow)
window->d_func...platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
413 window->d_func()->platformWindow->setParent(platformWindow);
never executed: window->d_func()->platformWindow->setParent(platformWindow);
0
414 }
never executed: end of block
0
415 }
never executed: end of block
0
416-
417 QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceCreated);-
418 QGuiApplication::sendEvent(q, &e);-
419}
never executed: end of block
0
420-
421void QWindowPrivate::clearFocusObject()-
422{-
423}-
424-
425// Allows for manipulating the suggested geometry before a resize/move-
426// event in derived classes for platforms that support it, for example to-
427// implement heightForWidth().-
428QRectF QWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const-
429{-
430 Q_UNUSED(rect)-
431 return QRectF();
never executed: return QRectF();
0
432}-
433-
434/*!-
435 Sets the \a surfaceType of the window.-
436-
437 Specifies whether the window is meant for raster rendering with-
438 QBackingStore, or OpenGL rendering with QOpenGLContext.-
439-
440 The surfaceType will be used when the native surface is created-
441 in the create() function. Calling this function after the native-
442 surface has been created requires calling destroy() and create()-
443 to release the old native surface and create a new one.-
444-
445 \sa QBackingStore, QOpenGLContext, create(), destroy()-
446*/-
447void QWindow::setSurfaceType(SurfaceType surfaceType)-
448{-
449 Q_D(QWindow);-
450 d->surfaceType = surfaceType;-
451}
never executed: end of block
0
452-
453/*!-
454 Returns the surface type of the window.-
455-
456 \sa setSurfaceType()-
457*/-
458QWindow::SurfaceType QWindow::surfaceType() const-
459{-
460 Q_D(const QWindow);-
461 return d->surfaceType;
never executed: return d->surfaceType;
0
462}-
463-
464/*!-
465 \property QWindow::visible-
466 \brief whether the window is visible or not-
467-
468 This property controls the visibility of the window in the windowing system.-
469-
470 By default, the window is not visible, you must call setVisible(true), or-
471 show() or similar to make it visible.-
472-
473 \sa show()-
474*/-
475void QWindow::setVisible(bool visible)-
476{-
477 Q_D(QWindow);-
478-
479 if (d->visible == visible)
d->visible == visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
480 return;
never executed: return;
0
481 d->visible = visible;-
482 emit visibleChanged(visible);-
483 d->updateVisibility();-
484-
485 if (!d->platformWindow)
!d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
486 create();
never executed: create();
0
487-
488 if (visible) {
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
489 // remove posted quit events when showing a new window-
490 QCoreApplication::removePostedEvents(qApp, QEvent::Quit);-
491-
492 if (type() == Qt::Window) {
type() == Qt::WindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
493 QGuiApplicationPrivate *app_priv = QGuiApplicationPrivate::instance();-
494 QString &firstWindowTitle = app_priv->firstWindowTitle;-
495 if (!firstWindowTitle.isEmpty()) {
!firstWindowTitle.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
496 setTitle(firstWindowTitle);-
497 firstWindowTitle = QString();-
498 }
never executed: end of block
0
499 if (!app_priv->forcedWindowIcon.isNull())
!app_priv->for...wIcon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
500 setIcon(app_priv->forcedWindowIcon);
never executed: setIcon(app_priv->forcedWindowIcon);
0
501-
502 // Handling of the -qwindowgeometry, -geometry command line arguments-
503 static bool geometryApplied = false;-
504 if (!geometryApplied) {
!geometryAppliedDescription
TRUEnever evaluated
FALSEnever evaluated
0
505 geometryApplied = true;-
506 QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(this);-
507 }
never executed: end of block
0
508 }
never executed: end of block
0
509-
510 QShowEvent showEvent;-
511 QGuiApplication::sendEvent(this, &showEvent);-
512 }
never executed: end of block
0
513-
514 if (isModal()) {
isModal()Description
TRUEnever evaluated
FALSEnever evaluated
0
515 if (visible)
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
516 QGuiApplicationPrivate::showModalWindow(this);
never executed: QGuiApplicationPrivate::showModalWindow(this);
0
517 else-
518 QGuiApplicationPrivate::hideModalWindow(this);
never executed: QGuiApplicationPrivate::hideModalWindow(this);
0
519 }-
520-
521#ifndef QT_NO_CURSOR-
522 if (visible && (d->hasCursor || QGuiApplication::overrideCursor()))
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
d->hasCursorDescription
TRUEnever evaluated
FALSEnever evaluated
QGuiApplicatio...errideCursor()Description
TRUEnever evaluated
FALSEnever evaluated
0
523 d->applyCursor();
never executed: d->applyCursor();
0
524#endif-
525 d->platformWindow->setVisible(visible);-
526-
527 if (!visible) {
!visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
528 QHideEvent hideEvent;-
529 QGuiApplication::sendEvent(this, &hideEvent);-
530 }
never executed: end of block
0
531}
never executed: end of block
0
532-
533bool QWindow::isVisible() const-
534{-
535 Q_D(const QWindow);-
536-
537 return d->visible;
never executed: return d->visible;
0
538}-
539-
540/*!-
541 Allocates the platform resources associated with the window.-
542-
543 It is at this point that the surface format set using setFormat() gets resolved-
544 into an actual native surface. However, the window remains hidden until setVisible() is called.-
545-
546 Note that it is not usually necessary to call this function directly, as it will be implicitly-
547 called by show(), setVisible(), and other functions that require access to the platform-
548 resources.-
549-
550 Call destroy() to free the platform resources if necessary.-
551-
552 \sa destroy()-
553*/-
554void QWindow::create()-
555{-
556 Q_D(QWindow);-
557 d->create(false);-
558}
never executed: end of block
0
559-
560/*!-
561 Returns the window's platform id.-
562-
563 For platforms where this id might be useful, the value returned-
564 will uniquely represent the window inside the corresponding screen.-
565-
566 \sa screen()-
567*/-
568WId QWindow::winId() const-
569{-
570 Q_D(const QWindow);-
571-
572 if (type() == Qt::ForeignWindow)
type() == Qt::ForeignWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
573 return WId(property("_q_foreignWinId").value<WId>());
never executed: return WId(property("_q_foreignWinId").value<WId>());
0
574-
575 if(!d->platformWindow)
!d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
576 const_cast<QWindow *>(this)->create();
never executed: const_cast<QWindow *>(this)->create();
0
577-
578 return d->platformWindow->winId();
never executed: return d->platformWindow->winId();
0
579}-
580-
581/*!-
582 Returns the parent window, if any.-
583-
584 A window without a parent is known as a top level window.-
585*/-
586QWindow *QWindow::parent() const-
587{-
588 Q_D(const QWindow);-
589 return d->parentWindow;
never executed: return d->parentWindow;
0
590}-
591-
592/*!-
593 Sets the \a parent Window. This will lead to the windowing system managing-
594 the clip of the window, so it will be clipped to the \a parent window.-
595-
596 Setting \a parent to be 0 will make the window become a top level window.-
597-
598 If \a parent is a window created by fromWinId(), then the current window-
599 will be embedded inside \a parent, if the platform supports it.-
600*/-
601void QWindow::setParent(QWindow *parent)-
602{-
603 Q_D(QWindow);-
604 if (d->parentWindow == parent)
d->parentWindow == parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
605 return;
never executed: return;
0
606-
607 QScreen *newScreen = parent ? parent->screen() : screen();
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
608 if (d->windowRecreationRequired(newScreen)) {
d->windowRecre...red(newScreen)Description
TRUEnever evaluated
FALSEnever evaluated
0
609 qWarning() << this << '(' << parent << "): Cannot change screens (" << screen() << newScreen << ')';-
610 return;
never executed: return;
0
611 }-
612-
613 QObject::setParent(parent);-
614 d->parentWindow = parent;-
615-
616 if (parent)
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
617 d->disconnectFromScreen();
never executed: d->disconnectFromScreen();
0
618 else-
619 d->connectToScreen(newScreen);
never executed: d->connectToScreen(newScreen);
0
620-
621 if (d->platformWindow) {
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
622 if (parent && parent->d_func()->platformWindow) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
parent->d_func...platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
623 d->platformWindow->setParent(parent->d_func()->platformWindow);-
624 } else {
never executed: end of block
0
625 d->platformWindow->setParent(0);-
626 }
never executed: end of block
0
627 }-
628-
629 QGuiApplicationPrivate::updateBlockedStatus(this);-
630}
never executed: end of block
0
631-
632/*!-
633 Returns whether the window is top level, i.e. has no parent window.-
634*/-
635bool QWindow::isTopLevel() const-
636{-
637 Q_D(const QWindow);-
638 return d->parentWindow == 0;
never executed: return d->parentWindow == 0;
0
639}-
640-
641/*!-
642 Returns whether the window is modal.-
643-
644 A modal window prevents other windows from getting any input.-
645-
646 \sa QWindow::modality-
647*/-
648bool QWindow::isModal() const-
649{-
650 Q_D(const QWindow);-
651 return d->modality != Qt::NonModal;
never executed: return d->modality != Qt::NonModal;
0
652}-
653-
654/*! \property QWindow::modality-
655 \brief the modality of the window-
656-
657 A modal window prevents other windows from receiving input events. Qt-
658 supports two types of modality: Qt::WindowModal and Qt::ApplicationModal.-
659-
660 By default, this property is Qt::NonModal-
661-
662 \sa Qt::WindowModality-
663*/-
664-
665Qt::WindowModality QWindow::modality() const-
666{-
667 Q_D(const QWindow);-
668 return d->modality;
never executed: return d->modality;
0
669}-
670-
671void QWindow::setModality(Qt::WindowModality modality)-
672{-
673 Q_D(QWindow);-
674 if (d->modality == modality)
d->modality == modalityDescription
TRUEnever evaluated
FALSEnever evaluated
0
675 return;
never executed: return;
0
676 d->modality = modality;-
677 emit modalityChanged(modality);-
678}
never executed: end of block
0
679-
680/*! \fn void QWindow::modalityChanged(Qt::WindowModality modality)-
681-
682 This signal is emitted when the Qwindow::modality property changes to \a modality.-
683*/-
684-
685/*!-
686 Sets the window's surface \a format.-
687-
688 The format determines properties such as color depth, alpha, depth and-
689 stencil buffer size, etc. For example, to give a window a transparent-
690 background (provided that the window system supports compositing, and-
691 provided that other content in the window does not make it opaque again):-
692-
693 \code-
694 QSurfaceFormat format;-
695 format.setAlphaBufferSize(8);-
696 window.setFormat(format);-
697 \endcode-
698-
699 The surface format will be resolved in the create() function. Calling-
700 this function after create() has been called will not re-resolve the-
701 surface format of the native surface.-
702-
703 When the format is not explicitly set via this function, the format returned-
704 by QSurfaceFormat::defaultFormat() will be used. This means that when having-
705 multiple windows, individual calls to this function can be replaced by one-
706 single call to QSurfaceFormat::setDefaultFormat() before creating the first-
707 window.-
708-
709 \sa create(), destroy(), QSurfaceFormat::setDefaultFormat()-
710*/-
711void QWindow::setFormat(const QSurfaceFormat &format)-
712{-
713 Q_D(QWindow);-
714 d->requestedFormat = format;-
715}
never executed: end of block
0
716-
717/*!-
718 Returns the requested surface format of this window.-
719-
720 If the requested format was not supported by the platform implementation,-
721 the requestedFormat will differ from the actual window format.-
722-
723 This is the value set with setFormat().-
724-
725 \sa setFormat(), format()-
726 */-
727QSurfaceFormat QWindow::requestedFormat() const-
728{-
729 Q_D(const QWindow);-
730 return d->requestedFormat;
never executed: return d->requestedFormat;
0
731}-
732-
733/*!-
734 Returns the actual format of this window.-
735-
736 After the window has been created, this function will return the actual surface format-
737 of the window. It might differ from the requested format if the requested format could-
738 not be fulfilled by the platform. It might also be a superset, for example certain-
739 buffer sizes may be larger than requested.-
740-
741 \note Depending on the platform, certain values in this surface format may still-
742 contain the requested values, that is, the values that have been passed to-
743 setFormat(). Typical examples are the OpenGL version, profile and options. These may-
744 not get updated during create() since these are context specific and a single window-
745 may be used together with multiple contexts over its lifetime. Use the-
746 QOpenGLContext's format() instead to query such values.-
747-
748 \sa create(), requestedFormat(), QOpenGLContext::format()-
749*/-
750QSurfaceFormat QWindow::format() const-
751{-
752 Q_D(const QWindow);-
753 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
754 return d->platformWindow->format();
never executed: return d->platformWindow->format();
0
755 return d->requestedFormat;
never executed: return d->requestedFormat;
0
756}-
757-
758/*!-
759 \property QWindow::flags-
760 \brief the window flags of the window-
761-
762 The window flags control the window's appearance in the windowing system,-
763 whether it's a dialog, popup, or a regular window, and whether it should-
764 have a title bar, etc.-
765-
766 The actual window flags might differ from the flags set with setFlags()-
767 if the requested flags could not be fulfilled.-
768*/-
769void QWindow::setFlags(Qt::WindowFlags flags)-
770{-
771 Q_D(QWindow);-
772 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
773 d->platformWindow->setWindowFlags(flags);
never executed: d->platformWindow->setWindowFlags(flags);
0
774 d->windowFlags = flags;-
775}
never executed: end of block
0
776-
777Qt::WindowFlags QWindow::flags() const-
778{-
779 Q_D(const QWindow);-
780 return d->windowFlags;
never executed: return d->windowFlags;
0
781}-
782-
783/*!-
784 Returns the type of the window.-
785-
786 This returns the part of the window flags that represents-
787 whether the window is a dialog, tooltip, popup, regular window, etc.-
788-
789 \sa flags(), setFlags()-
790*/-
791Qt::WindowType QWindow::type() const-
792{-
793 Q_D(const QWindow);-
794 return static_cast<Qt::WindowType>(int(d->windowFlags & Qt::WindowType_Mask));
never executed: return static_cast<Qt::WindowType>(int(d->windowFlags & Qt::WindowType_Mask));
0
795}-
796-
797/*!-
798 \property QWindow::title-
799 \brief the window's title in the windowing system-
800-
801 The window title might appear in the title area of the window decorations,-
802 depending on the windowing system and the window flags. It might also-
803 be used by the windowing system to identify the window in other contexts,-
804 such as in the task switcher.-
805-
806 \sa flags()-
807*/-
808void QWindow::setTitle(const QString &title)-
809{-
810 Q_D(QWindow);-
811 bool changed = false;-
812 if (d->windowTitle != title) {
d->windowTitle != titleDescription
TRUEnever evaluated
FALSEnever evaluated
0
813 d->windowTitle = title;-
814 changed = true;-
815 }
never executed: end of block
0
816 if (d->platformWindow && type() != Qt::Desktop)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
type() != Qt::DesktopDescription
TRUEnever evaluated
FALSEnever evaluated
0
817 d->platformWindow->setWindowTitle(title);
never executed: d->platformWindow->setWindowTitle(title);
0
818 if (changed)
changedDescription
TRUEnever evaluated
FALSEnever evaluated
0
819 emit windowTitleChanged(title);
never executed: windowTitleChanged(title);
0
820}
never executed: end of block
0
821-
822QString QWindow::title() const-
823{-
824 Q_D(const QWindow);-
825 return d->windowTitle;
never executed: return d->windowTitle;
0
826}-
827-
828/*!-
829 \brief set the file name this window is representing.-
830-
831 The windowing system might use \a filePath to display the-
832 path of the document this window is representing in the tile bar.-
833-
834*/-
835void QWindow::setFilePath(const QString &filePath)-
836{-
837 Q_D(QWindow);-
838 d->windowFilePath = filePath;-
839 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
840 d->platformWindow->setWindowFilePath(filePath);
never executed: d->platformWindow->setWindowFilePath(filePath);
0
841}
never executed: end of block
0
842-
843/*!-
844 \brief the file name this window is representing.-
845-
846 \sa setFilePath()-
847*/-
848QString QWindow::filePath() const-
849{-
850 Q_D(const QWindow);-
851 return d->windowFilePath;
never executed: return d->windowFilePath;
0
852}-
853-
854/*!-
855 \brief Sets the window's \a icon in the windowing system-
856-
857 The window icon might be used by the windowing system for example to-
858 decorate the window, and/or in the task switcher.-
859*/-
860void QWindow::setIcon(const QIcon &icon)-
861{-
862 Q_D(QWindow);-
863 d->windowIcon = icon;-
864 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
865 d->platformWindow->setWindowIcon(icon);
never executed: d->platformWindow->setWindowIcon(icon);
0
866 QEvent e(QEvent::WindowIconChange);-
867 QCoreApplication::sendEvent(this, &e);-
868}
never executed: end of block
0
869-
870/*!-
871 \brief Sets the window's icon in the windowing system-
872-
873 \sa setIcon()-
874*/-
875QIcon QWindow::icon() const-
876{-
877 Q_D(const QWindow);-
878 if (d->windowIcon.isNull())
d->windowIcon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
879 return QGuiApplication::windowIcon();
never executed: return QGuiApplication::windowIcon();
0
880 return d->windowIcon;
never executed: return d->windowIcon;
0
881}-
882-
883/*!-
884 Raise the window in the windowing system.-
885-
886 Requests that the window be raised to appear above other windows.-
887*/-
888void QWindow::raise()-
889{-
890 Q_D(QWindow);-
891 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
892 d->platformWindow->raise();
never executed: d->platformWindow->raise();
0
893}
never executed: end of block
0
894-
895/*!-
896 Lower the window in the windowing system.-
897-
898 Requests that the window be lowered to appear below other windows.-
899*/-
900void QWindow::lower()-
901{-
902 Q_D(QWindow);-
903 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
904 d->platformWindow->lower();
never executed: d->platformWindow->lower();
0
905}
never executed: end of block
0
906-
907/*!-
908 \property QWindow::opacity-
909 \brief The opacity of the window in the windowing system.-
910 \since 5.1-
911-
912 If the windowing system supports window opacity, this can be used to fade the-
913 window in and out, or to make it semitransparent.-
914-
915 A value of 1.0 or above is treated as fully opaque, whereas a value of 0.0 or below-
916 is treated as fully transparent. Values inbetween represent varying levels of-
917 translucency between the two extremes.-
918-
919 The default value is 1.0.-
920*/-
921void QWindow::setOpacity(qreal level)-
922{-
923 Q_D(QWindow);-
924 if (level == d->opacity)
level == d->opacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
925 return;
never executed: return;
0
926 d->opacity = level;-
927 if (d->platformWindow) {
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
928 d->platformWindow->setOpacity(level);-
929 emit opacityChanged(level);-
930 }
never executed: end of block
0
931}
never executed: end of block
0
932-
933qreal QWindow::opacity() const-
934{-
935 Q_D(const QWindow);-
936 return d->opacity;
never executed: return d->opacity;
0
937}-
938-
939/*!-
940 Sets the mask of the window.-
941-
942 The mask is a hint to the windowing system that the application does not-
943 want to receive mouse or touch input outside the given \a region.-
944-
945 The window manager may or may not choose to display any areas of the window-
946 not included in the mask, thus it is the application's responsibility to-
947 clear to transparent the areas that are not part of the mask.-
948-
949 Setting the mask before the window has been created has no effect.-
950*/-
951void QWindow::setMask(const QRegion &region)-
952{-
953 Q_D(QWindow);-
954 if (!d->platformWindow)
!d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
955 return;
never executed: return;
0
956 d->platformWindow->setMask(QHighDpi::toNativeLocalRegion(region, this));-
957 d->mask = region;-
958}
never executed: end of block
0
959-
960/*!-
961 Returns the mask set on the window.-
962-
963 The mask is a hint to the windowing system that the application does not-
964 want to receive mouse or touch input outside the given region.-
965*/-
966QRegion QWindow::mask() const-
967{-
968 Q_D(const QWindow);-
969 return d->mask;
never executed: return d->mask;
0
970}-
971-
972/*!-
973 Requests the window to be activated, i.e. receive keyboard focus.-
974-
975 \sa isActive(), QGuiApplication::focusWindow()-
976*/-
977void QWindow::requestActivate()-
978{-
979 Q_D(QWindow);-
980 if (flags() & Qt::WindowDoesNotAcceptFocus) {
flags() & Qt::...NotAcceptFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
981 qWarning() << "requestActivate() called for " << this << " which has Qt::WindowDoesNotAcceptFocus set.";-
982 return;
never executed: return;
0
983 }-
984 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
985 d->platformWindow->requestActivateWindow();
never executed: d->platformWindow->requestActivateWindow();
0
986}
never executed: end of block
0
987-
988/*!-
989 Returns if this window is exposed in the windowing system.-
990-
991 When the window is not exposed, it is shown by the application-
992 but it is still not showing in the windowing system, so the application-
993 should minimize rendering and other graphical activities.-
994-
995 An exposeEvent() is sent every time this value changes.-
996-
997 \sa exposeEvent()-
998*/-
999bool QWindow::isExposed() const-
1000{-
1001 Q_D(const QWindow);-
1002 return d->exposed;
never executed: return d->exposed;
0
1003}-
1004-
1005/*!-
1006 \property QWindow::active-
1007 \brief the active status of the window-
1008 \since 5.1-
1009-
1010 \sa requestActivate()-
1011*/-
1012-
1013/*!-
1014 Returns \c true if the window should appear active from a style perspective.-
1015-
1016 This is the case for the window that has input focus as well as windows-
1017 that are in the same parent / transient parent chain as the focus window.-
1018-
1019 To get the window that currently has focus, use QGuiApplication::focusWindow().-
1020*/-
1021bool QWindow::isActive() const-
1022{-
1023 Q_D(const QWindow);-
1024 if (!d->platformWindow)
!d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1025 return false;
never executed: return false;
0
1026-
1027 QWindow *focus = QGuiApplication::focusWindow();-
1028-
1029 // Means the whole application lost the focus-
1030 if (!focus)
!focusDescription
TRUEnever evaluated
FALSEnever evaluated
0
1031 return false;
never executed: return false;
0
1032-
1033 if (focus == this)
focus == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1034 return true;
never executed: return true;
0
1035-
1036 if (!parent() && !transientParent()) {
!parent()Description
TRUEnever evaluated
FALSEnever evaluated
!transientParent()Description
TRUEnever evaluated
FALSEnever evaluated
0
1037 return isAncestorOf(focus);
never executed: return isAncestorOf(focus);
0
1038 } else {-
1039 return (parent() && parent()->isActive()) || (transientParent() && transientParent()->isActive());
never executed: return (parent() && parent()->isActive()) || (transientParent() && transientParent()->isActive());
parent()Description
TRUEnever evaluated
FALSEnever evaluated
parent()->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
transientParent()Description
TRUEnever evaluated
FALSEnever evaluated
transientParent()->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1040 }-
1041}-
1042-
1043/*!-
1044 \property QWindow::contentOrientation-
1045 \brief the orientation of the window's contents-
1046-
1047 This is a hint to the window manager in case it needs to display-
1048 additional content like popups, dialogs, status bars, or similar-
1049 in relation to the window.-
1050-
1051 The recommended orientation is QScreen::orientation() but-
1052 an application doesn't have to support all possible orientations,-
1053 and thus can opt to ignore the current screen orientation.-
1054-
1055 The difference between the window and the content orientation-
1056 determines how much to rotate the content by. QScreen::angleBetween(),-
1057 QScreen::transformBetween(), and QScreen::mapBetween() can be used-
1058 to compute the necessary transform.-
1059-
1060 The default value is Qt::PrimaryOrientation-
1061*/-
1062void QWindow::reportContentOrientationChange(Qt::ScreenOrientation orientation)-
1063{-
1064 Q_D(QWindow);-
1065 if (d->contentOrientation == orientation)
d->contentOrie...== orientationDescription
TRUEnever evaluated
FALSEnever evaluated
0
1066 return;
never executed: return;
0
1067 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1068 d->platformWindow->handleContentOrientationChange(orientation);
never executed: d->platformWindow->handleContentOrientationChange(orientation);
0
1069 d->contentOrientation = orientation;-
1070 emit contentOrientationChanged(orientation);-
1071}
never executed: end of block
0
1072-
1073Qt::ScreenOrientation QWindow::contentOrientation() const-
1074{-
1075 Q_D(const QWindow);-
1076 return d->contentOrientation;
never executed: return d->contentOrientation;
0
1077}-
1078-
1079/*!-
1080 Returns the ratio between physical pixels and device-independent pixels-
1081 for the window. This value is dependent on the screen the window is on,-
1082 and may change when the window is moved.-
1083-
1084 Common values are 1.0 on normal displays and 2.0 on Apple "retina" displays.-
1085-
1086 \note For windows not backed by a platform window, meaning that create() was not-
1087 called, the function will fall back to QGuiApplication::devicePixelRatio() which in-
1088 turn returns the highest screen device pixel ratio found on the system.-
1089-
1090 \sa QScreen::devicePixelRatio(), QGuiApplication::devicePixelRatio()-
1091*/-
1092qreal QWindow::devicePixelRatio() const-
1093{-
1094 Q_D(const QWindow);-
1095-
1096 // If there is no platform window use the app global devicePixelRatio,-
1097 // which is the the highest devicePixelRatio found on the system-
1098 // screens, and will be correct for single-display systems (a very common case).-
1099 if (!d->platformWindow)
!d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1100 return qApp->devicePixelRatio();
never executed: return (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio();
0
1101-
1102 return d->platformWindow->devicePixelRatio() * QHighDpiScaling::factor(this);
never executed: return d->platformWindow->devicePixelRatio() * QHighDpiScaling::factor(this);
0
1103}-
1104-
1105/*!-
1106 \brief set the screen-occupation state of the window-
1107-
1108 The window \a state represents whether the window appears in the-
1109 windowing system as maximized, minimized, fullscreen, or normal.-
1110-
1111 The enum value Qt::WindowActive is not an accepted parameter.-
1112-
1113 \sa showNormal(), showFullScreen(), showMinimized(), showMaximized()-
1114*/-
1115void QWindow::setWindowState(Qt::WindowState state)-
1116{-
1117 if (state == Qt::WindowActive) {
state == Qt::WindowActiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
1118 qWarning() << "QWindow::setWindowState does not accept Qt::WindowActive";-
1119 return;
never executed: return;
0
1120 }-
1121-
1122 Q_D(QWindow);-
1123 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1124 d->platformWindow->setWindowState(state);
never executed: d->platformWindow->setWindowState(state);
0
1125 d->windowState = state;-
1126 emit windowStateChanged(d->windowState);-
1127 d->updateVisibility();-
1128}
never executed: end of block
0
1129-
1130/*!-
1131 \brief the screen-occupation state of the window-
1132-
1133 \sa setWindowState()-
1134*/-
1135Qt::WindowState QWindow::windowState() const-
1136{-
1137 Q_D(const QWindow);-
1138 return d->windowState;
never executed: return d->windowState;
0
1139}-
1140-
1141/*!-
1142 \fn QWindow::windowStateChanged(Qt::WindowState windowState)-
1143-
1144 This signal is emitted when the \a windowState changes, either-
1145 by being set explicitly with setWindowState(), or automatically when-
1146 the user clicks one of the titlebar buttons or by other means.-
1147*/-
1148-
1149/*!-
1150 Sets the transient \a parent-
1151-
1152 This is a hint to the window manager that this window is a dialog or pop-up-
1153 on behalf of the given window.-
1154-
1155 In order to cause the window to be centered above its transient parent by-
1156 default, depending on the window manager, it may also be necessary to call-
1157 setFlags() with a suitable \l Qt::WindowType (such as \c Qt::Dialog).-
1158-
1159 \sa transientParent(), parent()-
1160*/-
1161void QWindow::setTransientParent(QWindow *parent)-
1162{-
1163 Q_D(QWindow);-
1164 if (parent && !parent->isTopLevel()) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
!parent->isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
0
1165 qWarning() << parent << "must be a top level window.";-
1166 return;
never executed: return;
0
1167 }-
1168-
1169 d->transientParent = parent;-
1170-
1171 QGuiApplicationPrivate::updateBlockedStatus(this);-
1172}
never executed: end of block
0
1173-
1174/*!-
1175 Returns the transient parent of the window.-
1176-
1177 \sa setTransientParent(), parent()-
1178*/-
1179QWindow *QWindow::transientParent() const-
1180{-
1181 Q_D(const QWindow);-
1182 return d->transientParent.data();
never executed: return d->transientParent.data();
0
1183}-
1184-
1185/*!-
1186 \enum QWindow::AncestorMode-
1187-
1188 This enum is used to control whether or not transient parents-
1189 should be considered ancestors.-
1190-
1191 \value ExcludeTransients Transient parents are not considered ancestors.-
1192 \value IncludeTransients Transient parents are considered ancestors.-
1193*/-
1194-
1195/*!-
1196 Returns \c true if the window is an ancestor of the given \a child. If \a mode-
1197 is IncludeTransients, then transient parents are also considered ancestors.-
1198*/-
1199bool QWindow::isAncestorOf(const QWindow *child, AncestorMode mode) const-
1200{-
1201 if (child->parent() == this || (mode == IncludeTransients && child->transientParent() == this))
child->parent() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
mode == IncludeTransientsDescription
TRUEnever evaluated
FALSEnever evaluated
child->transie...rent() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1202 return true;
never executed: return true;
0
1203-
1204 return (child->parent() && isAncestorOf(child->parent(), mode))
never executed: return (child->parent() && isAncestorOf(child->parent(), mode)) || (mode == IncludeTransients && child->transientParent() && isAncestorOf(child->transientParent(), mode));
child->parent()Description
TRUEnever evaluated
FALSEnever evaluated
isAncestorOf(c...arent(), mode)Description
TRUEnever evaluated
FALSEnever evaluated
0
1205 || (mode == IncludeTransients && child->transientParent() && isAncestorOf(child->transientParent(), mode));
never executed: return (child->parent() && isAncestorOf(child->parent(), mode)) || (mode == IncludeTransients && child->transientParent() && isAncestorOf(child->transientParent(), mode));
mode == IncludeTransientsDescription
TRUEnever evaluated
FALSEnever evaluated
child->transientParent()Description
TRUEnever evaluated
FALSEnever evaluated
isAncestorOf(c...arent(), mode)Description
TRUEnever evaluated
FALSEnever evaluated
0
1206}-
1207-
1208/*!-
1209 Returns the minimum size of the window.-
1210-
1211 \sa setMinimumSize()-
1212*/-
1213QSize QWindow::minimumSize() const-
1214{-
1215 Q_D(const QWindow);-
1216 return d->minimumSize;
never executed: return d->minimumSize;
0
1217}-
1218-
1219/*!-
1220 Returns the maximum size of the window.-
1221-
1222 \sa setMaximumSize()-
1223*/-
1224QSize QWindow::maximumSize() const-
1225{-
1226 Q_D(const QWindow);-
1227 return d->maximumSize;
never executed: return d->maximumSize;
0
1228}-
1229-
1230/*!-
1231 Returns the base size of the window.-
1232-
1233 \sa setBaseSize()-
1234*/-
1235QSize QWindow::baseSize() const-
1236{-
1237 Q_D(const QWindow);-
1238 return d->baseSize;
never executed: return d->baseSize;
0
1239}-
1240-
1241/*!-
1242 Returns the size increment of the window.-
1243-
1244 \sa setSizeIncrement()-
1245*/-
1246QSize QWindow::sizeIncrement() const-
1247{-
1248 Q_D(const QWindow);-
1249 return d->sizeIncrement;
never executed: return d->sizeIncrement;
0
1250}-
1251-
1252/*!-
1253 Sets the minimum size of the window.-
1254-
1255 This is a hint to the window manager to prevent resizing below the specified \a size.-
1256-
1257 \sa setMaximumSize(), minimumSize()-
1258*/-
1259void QWindow::setMinimumSize(const QSize &size)-
1260{-
1261 Q_D(QWindow);-
1262 QSize adjustedSize = QSize(qBound(0, size.width(), QWINDOWSIZE_MAX), qBound(0, size.height(), QWINDOWSIZE_MAX));-
1263 if (d->minimumSize == adjustedSize)
d->minimumSize == adjustedSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1264 return;
never executed: return;
0
1265 QSize oldSize = d->minimumSize;-
1266 d->minimumSize = adjustedSize;-
1267 if (d->platformWindow && isTopLevel())
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
0
1268 d->platformWindow->propagateSizeHints();
never executed: d->platformWindow->propagateSizeHints();
0
1269 if (d->minimumSize.width() != oldSize.width())
d->minimumSize...ldSize.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
1270 emit minimumWidthChanged(d->minimumSize.width());
never executed: minimumWidthChanged(d->minimumSize.width());
0
1271 if (d->minimumSize.height() != oldSize.height())
d->minimumSize...dSize.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
1272 emit minimumHeightChanged(d->minimumSize.height());
never executed: minimumHeightChanged(d->minimumSize.height());
0
1273}
never executed: end of block
0
1274-
1275/*!-
1276 \property QWindow::x-
1277 \brief the x position of the window's geometry-
1278*/-
1279void QWindow::setX(int arg)-
1280{-
1281 Q_D(QWindow);-
1282 if (x() != arg)
x() != argDescription
TRUEnever evaluated
FALSEnever evaluated
0
1283 setGeometry(QRect(arg, y(), width(), height()));
never executed: setGeometry(QRect(arg, y(), width(), height()));
0
1284 else-
1285 d->positionAutomatic = false;
never executed: d->positionAutomatic = false;
0
1286}-
1287-
1288/*!-
1289 \property QWindow::y-
1290 \brief the y position of the window's geometry-
1291*/-
1292void QWindow::setY(int arg)-
1293{-
1294 Q_D(QWindow);-
1295 if (y() != arg)
y() != argDescription
TRUEnever evaluated
FALSEnever evaluated
0
1296 setGeometry(QRect(x(), arg, width(), height()));
never executed: setGeometry(QRect(x(), arg, width(), height()));
0
1297 else-
1298 d->positionAutomatic = false;
never executed: d->positionAutomatic = false;
0
1299}-
1300-
1301/*!-
1302 \property QWindow::width-
1303 \brief the width of the window's geometry-
1304*/-
1305void QWindow::setWidth(int arg)-
1306{-
1307 if (width() != arg)
width() != argDescription
TRUEnever evaluated
FALSEnever evaluated
0
1308 resize(arg, height());
never executed: resize(arg, height());
0
1309}
never executed: end of block
0
1310-
1311/*!-
1312 \property QWindow::height-
1313 \brief the height of the window's geometry-
1314*/-
1315void QWindow::setHeight(int arg)-
1316{-
1317 if (height() != arg)
height() != argDescription
TRUEnever evaluated
FALSEnever evaluated
0
1318 resize(width(), arg);
never executed: resize(width(), arg);
0
1319}
never executed: end of block
0
1320-
1321/*!-
1322 \property QWindow::minimumWidth-
1323 \brief the minimum width of the window's geometry-
1324*/-
1325void QWindow::setMinimumWidth(int w)-
1326{-
1327 setMinimumSize(QSize(w, minimumHeight()));-
1328}
never executed: end of block
0
1329-
1330/*!-
1331 \property QWindow::minimumHeight-
1332 \brief the minimum height of the window's geometry-
1333*/-
1334void QWindow::setMinimumHeight(int h)-
1335{-
1336 setMinimumSize(QSize(minimumWidth(), h));-
1337}
never executed: end of block
0
1338-
1339/*!-
1340 Sets the maximum size of the window.-
1341-
1342 This is a hint to the window manager to prevent resizing above the specified \a size.-
1343-
1344 \sa setMinimumSize(), maximumSize()-
1345*/-
1346void QWindow::setMaximumSize(const QSize &size)-
1347{-
1348 Q_D(QWindow);-
1349 QSize adjustedSize = QSize(qBound(0, size.width(), QWINDOWSIZE_MAX), qBound(0, size.height(), QWINDOWSIZE_MAX));-
1350 if (d->maximumSize == adjustedSize)
d->maximumSize == adjustedSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1351 return;
never executed: return;
0
1352 QSize oldSize = d->maximumSize;-
1353 d->maximumSize = adjustedSize;-
1354 if (d->platformWindow && isTopLevel())
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
0
1355 d->platformWindow->propagateSizeHints();
never executed: d->platformWindow->propagateSizeHints();
0
1356 if (d->maximumSize.width() != oldSize.width())
d->maximumSize...ldSize.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
1357 emit maximumWidthChanged(d->maximumSize.width());
never executed: maximumWidthChanged(d->maximumSize.width());
0
1358 if (d->maximumSize.height() != oldSize.height())
d->maximumSize...dSize.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
1359 emit maximumHeightChanged(d->maximumSize.height());
never executed: maximumHeightChanged(d->maximumSize.height());
0
1360}
never executed: end of block
0
1361-
1362/*!-
1363 \property QWindow::maximumWidth-
1364 \brief the maximum width of the window's geometry-
1365*/-
1366void QWindow::setMaximumWidth(int w)-
1367{-
1368 setMaximumSize(QSize(w, maximumHeight()));-
1369}
never executed: end of block
0
1370-
1371/*!-
1372 \property QWindow::maximumHeight-
1373 \brief the maximum height of the window's geometry-
1374*/-
1375void QWindow::setMaximumHeight(int h)-
1376{-
1377 setMaximumSize(QSize(maximumWidth(), h));-
1378}
never executed: end of block
0
1379-
1380/*!-
1381 Sets the base \a size of the window.-
1382-
1383 The base size is used to calculate a proper window size if the-
1384 window defines sizeIncrement().-
1385-
1386 \sa setMinimumSize(), setMaximumSize(), setSizeIncrement(), baseSize()-
1387*/-
1388void QWindow::setBaseSize(const QSize &size)-
1389{-
1390 Q_D(QWindow);-
1391 if (d->baseSize == size)
d->baseSize == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1392 return;
never executed: return;
0
1393 d->baseSize = size;-
1394 if (d->platformWindow && isTopLevel())
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
0
1395 d->platformWindow->propagateSizeHints();
never executed: d->platformWindow->propagateSizeHints();
0
1396}
never executed: end of block
0
1397-
1398/*!-
1399 Sets the size increment (\a size) of the window.-
1400-
1401 When the user resizes the window, the size will move in steps of-
1402 sizeIncrement().width() pixels horizontally and-
1403 sizeIncrement().height() pixels vertically, with baseSize() as the-
1404 basis.-
1405-
1406 By default, this property contains a size with zero width and height.-
1407-
1408 The windowing system might not support size increments.-
1409-
1410 \sa setBaseSize(), setMinimumSize(), setMaximumSize()-
1411*/-
1412void QWindow::setSizeIncrement(const QSize &size)-
1413{-
1414 Q_D(QWindow);-
1415 if (d->sizeIncrement == size)
d->sizeIncrement == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1416 return;
never executed: return;
0
1417 d->sizeIncrement = size;-
1418 if (d->platformWindow && isTopLevel())
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
0
1419 d->platformWindow->propagateSizeHints();
never executed: d->platformWindow->propagateSizeHints();
0
1420}
never executed: end of block
0
1421-
1422/*!-
1423 Sets the geometry of the window, excluding its window frame, to a-
1424 rectangle constructed from \a posx, \a posy, \a w and \a h.-
1425-
1426 \sa geometry()-
1427*/-
1428void QWindow::setGeometry(int posx, int posy, int w, int h)-
1429{-
1430 setGeometry(QRect(posx, posy, w, h));-
1431}
never executed: end of block
0
1432-
1433/*!-
1434 \brief Sets the geometry of the window, excluding its window frame, to \a rect.-
1435-
1436 \sa geometry()-
1437*/-
1438void QWindow::setGeometry(const QRect &rect)-
1439{-
1440 Q_D(QWindow);-
1441 d->positionAutomatic = false;-
1442 if (rect == geometry())
rect == geometry()Description
TRUEnever evaluated
FALSEnever evaluated
0
1443 return;
never executed: return;
0
1444 QRect oldRect = geometry();-
1445-
1446 d->positionPolicy = QWindowPrivate::WindowFrameExclusive;-
1447 if (d->platformWindow) {
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1448 QRect nativeRect;-
1449 QScreen *newScreen = d->screenForGeometry(rect);-
1450 if (newScreen && isTopLevel())
newScreenDescription
TRUEnever evaluated
FALSEnever evaluated
isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
0
1451 nativeRect = QHighDpi::toNativePixels(rect, newScreen);
never executed: nativeRect = QHighDpi::toNativePixels(rect, newScreen);
0
1452 else-
1453 nativeRect = QHighDpi::toNativePixels(rect, this);
never executed: nativeRect = QHighDpi::toNativePixels(rect, this);
0
1454 d->platformWindow->setGeometry(nativeRect);-
1455 } else {
never executed: end of block
0
1456 d->geometry = rect;-
1457-
1458 if (rect.x() != oldRect.x())
rect.x() != oldRect.x()Description
TRUEnever evaluated
FALSEnever evaluated
0
1459 emit xChanged(rect.x());
never executed: xChanged(rect.x());
0
1460 if (rect.y() != oldRect.y())
rect.y() != oldRect.y()Description
TRUEnever evaluated
FALSEnever evaluated
0
1461 emit yChanged(rect.y());
never executed: yChanged(rect.y());
0
1462 if (rect.width() != oldRect.width())
rect.width() !...ldRect.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
1463 emit widthChanged(rect.width());
never executed: widthChanged(rect.width());
0
1464 if (rect.height() != oldRect.height())
rect.height() ...dRect.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
1465 emit heightChanged(rect.height());
never executed: heightChanged(rect.height());
0
1466 }
never executed: end of block
0
1467}-
1468-
1469/*-
1470 This is equivalent to QPlatformWindow::screenForGeometry, but in platform-
1471 independent coordinates. The duplication is unfortunate, but there is a-
1472 chicken and egg problem here: we cannot convert to native coordinates-
1473 before we know which screen we are on.-
1474*/-
1475QScreen *QWindowPrivate::screenForGeometry(const QRect &newGeometry)-
1476{-
1477 Q_Q(QWindow);-
1478 QScreen *currentScreen = q->screen();-
1479 QScreen *fallback = currentScreen;-
1480 QPoint center = newGeometry.center();-
1481 if (!q->parent() && currentScreen && !currentScreen->geometry().contains(center)) {
!q->parent()Description
TRUEnever evaluated
FALSEnever evaluated
currentScreenDescription
TRUEnever evaluated
FALSEnever evaluated
!currentScreen...ntains(center)Description
TRUEnever evaluated
FALSEnever evaluated
0
1482 Q_FOREACH (QScreen* screen, currentScreen->virtualSiblings()) {-
1483 if (screen->geometry().contains(center))
screen->geomet...ntains(center)Description
TRUEnever evaluated
FALSEnever evaluated
0
1484 return screen;
never executed: return screen;
0
1485 if (screen->geometry().intersects(newGeometry))
screen->geomet...s(newGeometry)Description
TRUEnever evaluated
FALSEnever evaluated
0
1486 fallback = screen;
never executed: fallback = screen;
0
1487 }
never executed: end of block
0
1488 }
never executed: end of block
0
1489 return fallback;
never executed: return fallback;
0
1490}-
1491-
1492-
1493/*!-
1494 Returns the geometry of the window, excluding its window frame.-
1495-
1496 \sa frameMargins(), frameGeometry()-
1497*/-
1498QRect QWindow::geometry() const-
1499{-
1500 Q_D(const QWindow);-
1501 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1502 return QHighDpi::fromNativePixels(d->platformWindow->geometry(), this);
never executed: return QHighDpi::fromNativePixels(d->platformWindow->geometry(), this);
0
1503 return d->geometry;
never executed: return d->geometry;
0
1504}-
1505-
1506/*!-
1507 Returns the window frame margins surrounding the window.-
1508-
1509 \sa geometry(), frameGeometry()-
1510*/-
1511QMargins QWindow::frameMargins() const-
1512{-
1513 Q_D(const QWindow);-
1514 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1515 return QHighDpi::fromNativePixels(d->platformWindow->frameMargins(), this);
never executed: return QHighDpi::fromNativePixels(d->platformWindow->frameMargins(), this);
0
1516 return QMargins();
never executed: return QMargins();
0
1517}-
1518-
1519/*!-
1520 Returns the geometry of the window, including its window frame.-
1521-
1522 \sa geometry(), frameMargins()-
1523*/-
1524QRect QWindow::frameGeometry() const-
1525{-
1526 Q_D(const QWindow);-
1527 if (d->platformWindow) {
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1528 QMargins m = frameMargins();-
1529 return QHighDpi::fromNativePixels(d->platformWindow->geometry(), this).adjusted(-m.left(), -m.top(), m.right(), m.bottom());
never executed: return QHighDpi::fromNativePixels(d->platformWindow->geometry(), this).adjusted(-m.left(), -m.top(), m.right(), m.bottom());
0
1530 }-
1531 return d->geometry;
never executed: return d->geometry;
0
1532}-
1533-
1534/*!-
1535 Returns the top left position of the window, including its window frame.-
1536-
1537 This returns the same value as frameGeometry().topLeft().-
1538-
1539 \sa geometry(), frameGeometry()-
1540*/-
1541QPoint QWindow::framePosition() const-
1542{-
1543 Q_D(const QWindow);-
1544 if (d->platformWindow) {
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1545 QMargins margins = frameMargins();-
1546 return QHighDpi::fromNativePixels(d->platformWindow->geometry().topLeft(), this) - QPoint(margins.left(), margins.top());
never executed: return QHighDpi::fromNativePixels(d->platformWindow->geometry().topLeft(), this) - QPoint(margins.left(), margins.top());
0
1547 }-
1548 return d->geometry.topLeft();
never executed: return d->geometry.topLeft();
0
1549}-
1550-
1551/*!-
1552 Sets the upper left position of the window (\a point) including its window frame.-
1553-
1554 \sa setGeometry(), frameGeometry()-
1555*/-
1556void QWindow::setFramePosition(const QPoint &point)-
1557{-
1558 Q_D(QWindow);-
1559 d->positionPolicy = QWindowPrivate::WindowFrameInclusive;-
1560 d->positionAutomatic = false;-
1561 if (d->platformWindow) {
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1562 d->platformWindow->setGeometry(QHighDpi::toNativePixels(QRect(point, size()), this));-
1563 } else {
never executed: end of block
0
1564 d->geometry.moveTopLeft(point);-
1565 }
never executed: end of block
0
1566}-
1567-
1568/*!-
1569 \brief set the position of the window on the desktop to \a pt-
1570-
1571 \sa position()-
1572*/-
1573void QWindow::setPosition(const QPoint &pt)-
1574{-
1575 setGeometry(QRect(pt, size()));-
1576}
never executed: end of block
0
1577-
1578/*!-
1579 \brief set the position of the window on the desktop to \a posx, \a posy-
1580-
1581 \sa position()-
1582*/-
1583void QWindow::setPosition(int posx, int posy)-
1584{-
1585 setPosition(QPoint(posx, posy));-
1586}
never executed: end of block
0
1587-
1588/*!-
1589 \fn QPoint QWindow::position() const-
1590 \brief Returns the position of the window on the desktop excluding any window frame-
1591-
1592 \sa setPosition()-
1593*/-
1594-
1595/*!-
1596 \fn QSize QWindow::size() const-
1597 \brief Returns the size of the window excluding any window frame-
1598-
1599 \sa resize()-
1600*/-
1601-
1602/*!-
1603 set the size of the window, excluding any window frame, to a QSize-
1604 constructed from width \a w and height \a h-
1605-
1606 \sa size(), geometry()-
1607*/-
1608void QWindow::resize(int w, int h)-
1609{-
1610 resize(QSize(w, h));-
1611}
never executed: end of block
0
1612-
1613/*!-
1614 \brief set the size of the window, excluding any window frame, to \a newSize-
1615-
1616 \sa size(), geometry()-
1617*/-
1618void QWindow::resize(const QSize &newSize)-
1619{-
1620 Q_D(QWindow);-
1621 if (d->platformWindow) {
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1622 d->platformWindow->setGeometry(QHighDpi::toNativePixels(QRect(position(), newSize), this));-
1623 } else {
never executed: end of block
0
1624 const QSize oldSize = d->geometry.size();-
1625 d->geometry.setSize(newSize);-
1626 if (newSize.width() != oldSize.width())
newSize.width(...ldSize.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
1627 emit widthChanged(newSize.width());
never executed: widthChanged(newSize.width());
0
1628 if (newSize.height() != oldSize.height())
newSize.height...dSize.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
1629 emit heightChanged(newSize.height());
never executed: heightChanged(newSize.height());
0
1630 }
never executed: end of block
0
1631}-
1632-
1633/*!-
1634 Releases the native platform resources associated with this window.-
1635-
1636 \sa create()-
1637*/-
1638void QWindow::destroy()-
1639{-
1640 Q_D(QWindow);-
1641 if (!d->platformWindow)
!d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1642 return;
never executed: return;
0
1643-
1644 QObjectList childrenWindows = children();-
1645 for (int i = 0; i < childrenWindows.size(); i++) {
i < childrenWindows.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1646 QObject *object = childrenWindows.at(i);-
1647 if (object->isWindowType()) {
object->isWindowType()Description
TRUEnever evaluated
FALSEnever evaluated
0
1648 QWindow *w = static_cast<QWindow*>(object);-
1649 w->destroy();-
1650 }
never executed: end of block
0
1651 }
never executed: end of block
0
1652-
1653 if (QGuiApplicationPrivate::focus_window == this)
QGuiApplicatio...window == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1654 QGuiApplicationPrivate::focus_window = parent();
never executed: QGuiApplicationPrivate::focus_window = parent();
0
1655 if (QGuiApplicationPrivate::currentMouseWindow == this)
QGuiApplicatio...Window == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1656 QGuiApplicationPrivate::currentMouseWindow = parent();
never executed: QGuiApplicationPrivate::currentMouseWindow = parent();
0
1657 if (QGuiApplicationPrivate::currentMousePressWindow == this)
QGuiApplicatio...Window == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1658 QGuiApplicationPrivate::currentMousePressWindow = parent();
never executed: QGuiApplicationPrivate::currentMousePressWindow = parent();
0
1659 if (QGuiApplicationPrivate::tabletPressTarget == this)
QGuiApplicatio...Target == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1660 QGuiApplicationPrivate::tabletPressTarget = parent();
never executed: QGuiApplicationPrivate::tabletPressTarget = parent();
0
1661-
1662 bool wasVisible = isVisible();-
1663 d->visibilityOnDestroy = wasVisible && d->platformWindow;
wasVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1664-
1665 setVisible(false);-
1666-
1667 QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed);-
1668 QGuiApplication::sendEvent(this, &e);-
1669-
1670 delete d->platformWindow;-
1671 d->resizeEventPending = true;-
1672 d->receivedExpose = false;-
1673 d->exposed = false;-
1674 d->platformWindow = 0;-
1675-
1676 if (wasVisible)
wasVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1677 d->maybeQuitOnLastWindowClosed();
never executed: d->maybeQuitOnLastWindowClosed();
0
1678}
never executed: end of block
0
1679-
1680/*!-
1681 Returns the platform window corresponding to the window.-
1682-
1683 \internal-
1684*/-
1685QPlatformWindow *QWindow::handle() const-
1686{-
1687 Q_D(const QWindow);-
1688 return d->platformWindow;
never executed: return d->platformWindow;
0
1689}-
1690-
1691/*!-
1692 Returns the platform surface corresponding to the window.-
1693-
1694 \internal-
1695*/-
1696QPlatformSurface *QWindow::surfaceHandle() const-
1697{-
1698 Q_D(const QWindow);-
1699 return d->platformWindow;
never executed: return d->platformWindow;
0
1700}-
1701-
1702/*!-
1703 Sets whether keyboard grab should be enabled or not (\a grab).-
1704-
1705 If the return value is true, the window receives all key events until-
1706 setKeyboardGrabEnabled(false) is called; other windows get no key events at-
1707 all. Mouse events are not affected. Use setMouseGrabEnabled() if you want-
1708 to grab that.-
1709-
1710 \sa setMouseGrabEnabled()-
1711*/-
1712bool QWindow::setKeyboardGrabEnabled(bool grab)-
1713{-
1714 Q_D(QWindow);-
1715 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1716 return d->platformWindow->setKeyboardGrabEnabled(grab);
never executed: return d->platformWindow->setKeyboardGrabEnabled(grab);
0
1717 return false;
never executed: return false;
0
1718}-
1719-
1720/*!-
1721 Sets whether mouse grab should be enabled or not (\a grab).-
1722-
1723 If the return value is true, the window receives all mouse events until setMouseGrabEnabled(false) is-
1724 called; other windows get no mouse events at all. Keyboard events are not affected.-
1725 Use setKeyboardGrabEnabled() if you want to grab that.-
1726-
1727 \sa setKeyboardGrabEnabled()-
1728*/-
1729bool QWindow::setMouseGrabEnabled(bool grab)-
1730{-
1731 Q_D(QWindow);-
1732 if (d->platformWindow)
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1733 return d->platformWindow->setMouseGrabEnabled(grab);
never executed: return d->platformWindow->setMouseGrabEnabled(grab);
0
1734 return false;
never executed: return false;
0
1735}-
1736-
1737/*!-
1738 Returns the screen on which the window is shown, or null if there is none.-
1739-
1740 For child windows, this returns the screen of the corresponding top level window.-
1741-
1742 \sa setScreen(), QScreen::virtualSiblings()-
1743*/-
1744QScreen *QWindow::screen() const-
1745{-
1746 Q_D(const QWindow);-
1747 return d->parentWindow ? d->parentWindow->screen() : d->topLevelScreen.data();
never executed: return d->parentWindow ? d->parentWindow->screen() : d->topLevelScreen.data();
d->parentWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1748}-
1749-
1750/*!-
1751 Sets the screen on which the window should be shown.-
1752-
1753 If the window has been created, it will be recreated on the \a newScreen.-
1754-
1755 Note that if the screen is part of a virtual desktop of multiple screens,-
1756 the window can appear on any of the screens returned by QScreen::virtualSiblings().-
1757-
1758 This function only works for top level windows.-
1759-
1760 \sa screen(), QScreen::virtualSiblings()-
1761*/-
1762void QWindow::setScreen(QScreen *newScreen)-
1763{-
1764 Q_D(QWindow);-
1765 if (!newScreen)
!newScreenDescription
TRUEnever evaluated
FALSEnever evaluated
0
1766 newScreen = QGuiApplication::primaryScreen();
never executed: newScreen = QGuiApplication::primaryScreen();
0
1767 d->setTopLevelScreen(newScreen, newScreen != 0);-
1768}
never executed: end of block
0
1769-
1770/*!-
1771 \fn QWindow::screenChanged(QScreen *screen)-
1772-
1773 This signal is emitted when a window's \a screen changes, either-
1774 by being set explicitly with setScreen(), or automatically when-
1775 the window's screen is removed.-
1776*/-
1777-
1778/*!-
1779 Returns the accessibility interface for the object that the window represents-
1780 \internal-
1781 \sa QAccessible-
1782 */-
1783QAccessibleInterface *QWindow::accessibleRoot() const-
1784{-
1785 return 0;
never executed: return 0;
0
1786}-
1787-
1788/*!-
1789 \fn QWindow::focusObjectChanged(QObject *object)-
1790-
1791 This signal is emitted when the final receiver of events tied to focus-
1792 is changed to \a object.-
1793-
1794 \sa focusObject()-
1795*/-
1796-
1797/*!-
1798 Returns the QObject that will be the final receiver of events tied focus, such-
1799 as key events.-
1800*/-
1801QObject *QWindow::focusObject() const-
1802{-
1803 return const_cast<QWindow *>(this);
never executed: return const_cast<QWindow *>(this);
0
1804}-
1805-
1806/*!-
1807 Shows the window.-
1808-
1809 This is equivalent to calling showFullScreen(), showMaximized(), or showNormal(),-
1810 depending on the platform's default behavior for the window type and flags.-
1811-
1812 \sa showFullScreen(), showMaximized(), showNormal(), hide(), QStyleHints::showIsFullScreen(), flags()-
1813*/-
1814void QWindow::show()-
1815{-
1816 Qt::WindowState defaultState = QGuiApplicationPrivate::platformIntegration()->defaultWindowState(d_func()->windowFlags);-
1817 if (defaultState == Qt::WindowFullScreen)
defaultState =...ndowFullScreenDescription
TRUEnever evaluated
FALSEnever evaluated
0
1818 showFullScreen();
never executed: showFullScreen();
0
1819 else if (defaultState == Qt::WindowMaximized)
defaultState =...indowMaximizedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1820 showMaximized();
never executed: showMaximized();
0
1821 else-
1822 showNormal();
never executed: showNormal();
0
1823}-
1824-
1825/*!-
1826 Hides the window.-
1827-
1828 Equivalent to calling setVisible(false).-
1829-
1830 \sa show(), setVisible()-
1831*/-
1832void QWindow::hide()-
1833{-
1834 setVisible(false);-
1835}
never executed: end of block
0
1836-
1837/*!-
1838 Shows the window as minimized.-
1839-
1840 Equivalent to calling setWindowState(Qt::WindowMinimized) and then-
1841 setVisible(true).-
1842-
1843 \sa setWindowState(), setVisible()-
1844*/-
1845void QWindow::showMinimized()-
1846{-
1847 setWindowState(Qt::WindowMinimized);-
1848 setVisible(true);-
1849}
never executed: end of block
0
1850-
1851/*!-
1852 Shows the window as maximized.-
1853-
1854 Equivalent to calling setWindowState(Qt::WindowMaximized) and then-
1855 setVisible(true).-
1856-
1857 \sa setWindowState(), setVisible()-
1858*/-
1859void QWindow::showMaximized()-
1860{-
1861 setWindowState(Qt::WindowMaximized);-
1862 setVisible(true);-
1863}
never executed: end of block
0
1864-
1865/*!-
1866 Shows the window as fullscreen.-
1867-
1868 Equivalent to calling setWindowState(Qt::WindowFullScreen) and then-
1869 setVisible(true).-
1870-
1871 \sa setWindowState(), setVisible()-
1872*/-
1873void QWindow::showFullScreen()-
1874{-
1875 setWindowState(Qt::WindowFullScreen);-
1876 setVisible(true);-
1877#if !defined Q_OS_QNX // On QNX this window will be activated anyway from libscreen-
1878 // activating it here before libscreen activates it causes problems-
1879 requestActivate();-
1880#endif-
1881}
never executed: end of block
0
1882-
1883/*!-
1884 Shows the window as normal, i.e. neither maximized, minimized, nor fullscreen.-
1885-
1886 Equivalent to calling setWindowState(Qt::WindowNoState) and then-
1887 setVisible(true).-
1888-
1889 \sa setWindowState(), setVisible()-
1890*/-
1891void QWindow::showNormal()-
1892{-
1893 setWindowState(Qt::WindowNoState);-
1894 setVisible(true);-
1895}
never executed: end of block
0
1896-
1897/*!-
1898 Close the window.-
1899-
1900 This closes the window, effectively calling destroy(), and potentially-
1901 quitting the application. Returns \c true on success, false if it has a parent-
1902 window (in which case the top level window should be closed instead).-
1903-
1904 \sa destroy(), QGuiApplication::quitOnLastWindowClosed()-
1905*/-
1906bool QWindow::close()-
1907{-
1908 Q_D(QWindow);-
1909-
1910 // Do not close non top level windows-
1911 if (parent())
parent()Description
TRUEnever evaluated
FALSEnever evaluated
0
1912 return false;
never executed: return false;
0
1913-
1914 if (!d->platformWindow)
!d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1915 return true;
never executed: return true;
0
1916-
1917 bool accepted = false;-
1918 QWindowSystemInterface::handleCloseEvent(this, &accepted);-
1919 QWindowSystemInterface::flushWindowSystemEvents();-
1920 return accepted;
never executed: return accepted;
0
1921}-
1922-
1923/*!-
1924 The expose event (\a ev) is sent by the window system whenever the window's-
1925 exposure on screen changes.-
1926-
1927 The application can start rendering into the window with QBackingStore-
1928 and QOpenGLContext as soon as it gets an exposeEvent() such that-
1929 isExposed() is true.-
1930-
1931 If the window is moved off screen, is made totally obscured by another-
1932 window, iconified or similar, this function might be called and the-
1933 value of isExposed() might change to false. When this happens,-
1934 an application should stop its rendering as it is no longer visible-
1935 to the user.-
1936-
1937 A resize event will always be sent before the expose event the first time-
1938 a window is shown.-
1939-
1940 \sa isExposed()-
1941*/-
1942void QWindow::exposeEvent(QExposeEvent *ev)-
1943{-
1944 ev->ignore();-
1945}
never executed: end of block
0
1946-
1947/*!-
1948 Override this to handle window move events (\a ev).-
1949*/-
1950void QWindow::moveEvent(QMoveEvent *ev)-
1951{-
1952 ev->ignore();-
1953}
never executed: end of block
0
1954-
1955/*!-
1956 Override this to handle resize events (\a ev).-
1957-
1958 The resize event is called whenever the window is resized in the windowing system,-
1959 either directly through the windowing system acknowledging a setGeometry() or resize() request,-
1960 or indirectly through the user resizing the window manually.-
1961*/-
1962void QWindow::resizeEvent(QResizeEvent *ev)-
1963{-
1964 ev->ignore();-
1965}
never executed: end of block
0
1966-
1967/*!-
1968 Override this to handle show events (\a ev).-
1969-
1970 The function is called when the window has requested becoming visible.-
1971-
1972 If the window is successfully shown by the windowing system, this will-
1973 be followed by a resize and an expose event.-
1974*/-
1975void QWindow::showEvent(QShowEvent *ev)-
1976{-
1977 ev->ignore();-
1978}
never executed: end of block
0
1979-
1980/*!-
1981 Override this to handle hide events (\a ev).-
1982-
1983 The function is called when the window has requested being hidden in the-
1984 windowing system.-
1985*/-
1986void QWindow::hideEvent(QHideEvent *ev)-
1987{-
1988 ev->ignore();-
1989}
never executed: end of block
0
1990-
1991/*!-
1992 Override this to handle any event (\a ev) sent to the window.-
1993 Return \c true if the event was recognized and processed.-
1994-
1995 Remember to call the base class version if you wish for mouse events,-
1996 key events, resize events, etc to be dispatched as usual.-
1997*/-
1998bool QWindow::event(QEvent *ev)-
1999{-
2000 switch (ev->type()) {-
2001 case QEvent::MouseMove:
never executed: case QEvent::MouseMove:
0
2002 mouseMoveEvent(static_cast<QMouseEvent*>(ev));-
2003 break;
never executed: break;
0
2004-
2005 case QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
0
2006 mousePressEvent(static_cast<QMouseEvent*>(ev));-
2007 break;
never executed: break;
0
2008-
2009 case QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
2010 mouseReleaseEvent(static_cast<QMouseEvent*>(ev));-
2011 break;
never executed: break;
0
2012-
2013 case QEvent::MouseButtonDblClick:
never executed: case QEvent::MouseButtonDblClick:
0
2014 mouseDoubleClickEvent(static_cast<QMouseEvent*>(ev));-
2015 break;
never executed: break;
0
2016-
2017 case QEvent::TouchBegin:
never executed: case QEvent::TouchBegin:
0
2018 case QEvent::TouchUpdate:
never executed: case QEvent::TouchUpdate:
0
2019 case QEvent::TouchEnd:
never executed: case QEvent::TouchEnd:
0
2020 case QEvent::TouchCancel:
never executed: case QEvent::TouchCancel:
0
2021 touchEvent(static_cast<QTouchEvent *>(ev));-
2022 break;
never executed: break;
0
2023-
2024 case QEvent::Move:
never executed: case QEvent::Move:
0
2025 moveEvent(static_cast<QMoveEvent*>(ev));-
2026 break;
never executed: break;
0
2027-
2028 case QEvent::Resize:
never executed: case QEvent::Resize:
0
2029 resizeEvent(static_cast<QResizeEvent*>(ev));-
2030 break;
never executed: break;
0
2031-
2032 case QEvent::KeyPress:
never executed: case QEvent::KeyPress:
0
2033 keyPressEvent(static_cast<QKeyEvent *>(ev));-
2034 break;
never executed: break;
0
2035-
2036 case QEvent::KeyRelease:
never executed: case QEvent::KeyRelease:
0
2037 keyReleaseEvent(static_cast<QKeyEvent *>(ev));-
2038 break;
never executed: break;
0
2039-
2040 case QEvent::FocusIn: {
never executed: case QEvent::FocusIn:
0
2041 focusInEvent(static_cast<QFocusEvent *>(ev));-
2042#ifndef QT_NO_ACCESSIBILITY-
2043 QAccessible::State state;-
2044 state.active = true;-
2045 QAccessibleStateChangeEvent event(this, state);-
2046 QAccessible::updateAccessibility(&event);-
2047#endif-
2048 break; }
never executed: break;
0
2049-
2050 case QEvent::FocusOut: {
never executed: case QEvent::FocusOut:
0
2051 focusOutEvent(static_cast<QFocusEvent *>(ev));-
2052#ifndef QT_NO_ACCESSIBILITY-
2053 QAccessible::State state;-
2054 state.active = true;-
2055 QAccessibleStateChangeEvent event(this, state);-
2056 QAccessible::updateAccessibility(&event);-
2057#endif-
2058 break; }
never executed: break;
0
2059-
2060#ifndef QT_NO_WHEELEVENT-
2061 case QEvent::Wheel:
never executed: case QEvent::Wheel:
0
2062 wheelEvent(static_cast<QWheelEvent*>(ev));-
2063 break;
never executed: break;
0
2064#endif-
2065-
2066 case QEvent::Close:
never executed: case QEvent::Close:
0
2067 if (ev->isAccepted())
ev->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
2068 destroy();
never executed: destroy();
0
2069 break;
never executed: break;
0
2070-
2071 case QEvent::Expose:
never executed: case QEvent::Expose:
0
2072 exposeEvent(static_cast<QExposeEvent *>(ev));-
2073 break;
never executed: break;
0
2074-
2075 case QEvent::Show:
never executed: case QEvent::Show:
0
2076 showEvent(static_cast<QShowEvent *>(ev));-
2077 break;
never executed: break;
0
2078-
2079 case QEvent::Hide:
never executed: case QEvent::Hide:
0
2080 hideEvent(static_cast<QHideEvent *>(ev));-
2081 break;
never executed: break;
0
2082-
2083 case QEvent::ApplicationWindowIconChange:
never executed: case QEvent::ApplicationWindowIconChange:
0
2084 setIcon(icon());-
2085 break;
never executed: break;
0
2086-
2087 case QEvent::WindowStateChange: {
never executed: case QEvent::WindowStateChange:
0
2088 Q_D(QWindow);-
2089 emit windowStateChanged(d->windowState);-
2090 d->updateVisibility();-
2091 break;
never executed: break;
0
2092 }-
2093-
2094#ifndef QT_NO_TABLETEVENT-
2095 case QEvent::TabletPress:
never executed: case QEvent::TabletPress:
0
2096 case QEvent::TabletMove:
never executed: case QEvent::TabletMove:
0
2097 case QEvent::TabletRelease:
never executed: case QEvent::TabletRelease:
0
2098 tabletEvent(static_cast<QTabletEvent *>(ev));-
2099 break;
never executed: break;
0
2100#endif-
2101-
2102 case QEvent::Timer: {
never executed: case QEvent::Timer:
0
2103 Q_D(QWindow);-
2104 if (static_cast<QTimerEvent *>(ev)->timerId() == d->updateTimer) {
static_cast<QT...d->updateTimerDescription
TRUEnever evaluated
FALSEnever evaluated
0
2105 killTimer(d->updateTimer);-
2106 d->updateTimer = 0;-
2107 d->deliverUpdateRequest();-
2108 } else {
never executed: end of block
0
2109 QObject::event(ev);-
2110 }
never executed: end of block
0
2111 break;
never executed: break;
0
2112 }-
2113-
2114 case QEvent::PlatformSurface: {
never executed: case QEvent::PlatformSurface:
0
2115 if ((static_cast<QPlatformSurfaceEvent *>(ev))->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) {
(static_cast<Q...tToBeDestroyedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2116#ifndef QT_NO_OPENGL-
2117 QOpenGLContext *context = QOpenGLContext::currentContext();-
2118 if (context && context->surface() == static_cast<QSurface *>(this))
contextDescription
TRUEnever evaluated
FALSEnever evaluated
context->surfa...rface *>(this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2119 context->doneCurrent();
never executed: context->doneCurrent();
0
2120#endif-
2121 }
never executed: end of block
0
2122 break;
never executed: break;
0
2123 }-
2124-
2125 default:
never executed: default:
0
2126 return QObject::event(ev);
never executed: return QObject::event(ev);
0
2127 }-
2128 return true;
never executed: return true;
0
2129}-
2130-
2131void QWindowPrivate::deliverUpdateRequest()-
2132{-
2133 Q_Q(QWindow);-
2134 updateRequestPending = false;-
2135 QEvent request(QEvent::UpdateRequest);-
2136 QCoreApplication::sendEvent(q, &request);-
2137}
never executed: end of block
0
2138-
2139/*!-
2140 Schedules a QEvent::UpdateRequest event to be delivered to this window.-
2141-
2142 The event is delivered in sync with the display vsync on platforms-
2143 where this is possible. When driving animations, this function should-
2144 be called once after drawing has completed.-
2145-
2146 Calling this function multiple times will result in a single event-
2147 being delivered to the window.-
2148-
2149 Subclasses of QWindow should reimplement event(), intercept the event and-
2150 call the application's rendering code, then call the base class-
2151 implementation.-
2152-
2153 \note The subclass' reimplementation of event() must invoke the base class-
2154 implementation, unless it is absolutely sure that the event does not need to-
2155 be handled by the base class. For example, the default implementation of-
2156 this function relies on QEvent::Timer events. Filtering them away would-
2157 therefore break the delivery of the update events.-
2158-
2159 \since 5.5-
2160*/-
2161void QWindow::requestUpdate()-
2162{-
2163 Q_ASSERT_X(QThread::currentThread() == QCoreApplication::instance()->thread(),-
2164 "QWindow", "Updates can only be scheduled from the GUI (main) thread");-
2165-
2166 Q_D(QWindow);-
2167 if (d->updateRequestPending || !d->platformWindow)
d->updateRequestPendingDescription
TRUEnever evaluated
FALSEnever evaluated
!d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
2168 return;
never executed: return;
0
2169 d->updateRequestPending = true;-
2170 d->platformWindow->requestUpdate();-
2171}
never executed: end of block
0
2172-
2173/*!-
2174 Override this to handle key press events (\a ev).-
2175-
2176 \sa keyReleaseEvent()-
2177*/-
2178void QWindow::keyPressEvent(QKeyEvent *ev)-
2179{-
2180 ev->ignore();-
2181}
never executed: end of block
0
2182-
2183/*!-
2184 Override this to handle key release events (\a ev).-
2185-
2186 \sa keyPressEvent()-
2187*/-
2188void QWindow::keyReleaseEvent(QKeyEvent *ev)-
2189{-
2190 ev->ignore();-
2191}
never executed: end of block
0
2192-
2193/*!-
2194 Override this to handle focus in events (\a ev).-
2195-
2196 Focus in events are sent when the window receives keyboard focus.-
2197-
2198 \sa focusOutEvent()-
2199*/-
2200void QWindow::focusInEvent(QFocusEvent *ev)-
2201{-
2202 ev->ignore();-
2203}
never executed: end of block
0
2204-
2205/*!-
2206 Override this to handle focus out events (\a ev).-
2207-
2208 Focus out events are sent when the window loses keyboard focus.-
2209-
2210 \sa focusInEvent()-
2211*/-
2212void QWindow::focusOutEvent(QFocusEvent *ev)-
2213{-
2214 ev->ignore();-
2215}
never executed: end of block
0
2216-
2217/*!-
2218 Override this to handle mouse press events (\a ev).-
2219-
2220 \sa mouseReleaseEvent()-
2221*/-
2222void QWindow::mousePressEvent(QMouseEvent *ev)-
2223{-
2224 ev->ignore();-
2225}
never executed: end of block
0
2226-
2227/*!-
2228 Override this to handle mouse release events (\a ev).-
2229-
2230 \sa mousePressEvent()-
2231*/-
2232void QWindow::mouseReleaseEvent(QMouseEvent *ev)-
2233{-
2234 ev->ignore();-
2235}
never executed: end of block
0
2236-
2237/*!-
2238 Override this to handle mouse double click events (\a ev).-
2239-
2240 \sa mousePressEvent(), QStyleHints::mouseDoubleClickInterval()-
2241*/-
2242void QWindow::mouseDoubleClickEvent(QMouseEvent *ev)-
2243{-
2244 ev->ignore();-
2245}
never executed: end of block
0
2246-
2247/*!-
2248 Override this to handle mouse move events (\a ev).-
2249*/-
2250void QWindow::mouseMoveEvent(QMouseEvent *ev)-
2251{-
2252 ev->ignore();-
2253}
never executed: end of block
0
2254-
2255#ifndef QT_NO_WHEELEVENT-
2256/*!-
2257 Override this to handle mouse wheel or other wheel events (\a ev).-
2258*/-
2259void QWindow::wheelEvent(QWheelEvent *ev)-
2260{-
2261 ev->ignore();-
2262}
never executed: end of block
0
2263#endif //QT_NO_WHEELEVENT-
2264-
2265/*!-
2266 Override this to handle touch events (\a ev).-
2267*/-
2268void QWindow::touchEvent(QTouchEvent *ev)-
2269{-
2270 ev->ignore();-
2271}
never executed: end of block
0
2272-
2273#ifndef QT_NO_TABLETEVENT-
2274/*!-
2275 Override this to handle tablet press, move, and release events (\a ev).-
2276-
2277 Proximity enter and leave events are not sent to windows, they are-
2278 delivered to the application instance.-
2279*/-
2280void QWindow::tabletEvent(QTabletEvent *ev)-
2281{-
2282 ev->ignore();-
2283}
never executed: end of block
0
2284#endif-
2285-
2286/*!-
2287 Override this to handle platform dependent events.-
2288 Will be given \a eventType, \a message and \a result.-
2289-
2290 This might make your application non-portable.-
2291-
2292 Should return true only if the event was handled.-
2293*/-
2294bool QWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)-
2295{-
2296 Q_UNUSED(eventType);-
2297 Q_UNUSED(message);-
2298 Q_UNUSED(result);-
2299 return false;
never executed: return false;
0
2300}-
2301-
2302/*!-
2303 \fn QPoint QWindow::mapToGlobal(const QPoint &pos) const-
2304-
2305 Translates the window coordinate \a pos to global screen-
2306 coordinates. For example, \c{mapToGlobal(QPoint(0,0))} would give-
2307 the global coordinates of the top-left pixel of the window.-
2308-
2309 \sa mapFromGlobal()-
2310*/-
2311QPoint QWindow::mapToGlobal(const QPoint &pos) const-
2312{-
2313 Q_D(const QWindow);-
2314 // QTBUG-43252, prefer platform implementation for foreign windows.-
2315 if (d->platformWindow
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
2316 && (type() == Qt::ForeignWindow || d->platformWindow->isEmbedded())) {
type() == Qt::ForeignWindowDescription
TRUEnever evaluated
FALSEnever evaluated
d->platformWin...->isEmbedded()Description
TRUEnever evaluated
FALSEnever evaluated
0
2317 return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapToGlobal(QHighDpi::toNativeLocalPosition(pos, this)), this);
never executed: return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapToGlobal(QHighDpi::toNativeLocalPosition(pos, this)), this);
0
2318 }-
2319 return pos + d->globalPosition();
never executed: return pos + d->globalPosition();
0
2320}-
2321-
2322-
2323/*!-
2324 \fn QPoint QWindow::mapFromGlobal(const QPoint &pos) const-
2325-
2326 Translates the global screen coordinate \a pos to window-
2327 coordinates.-
2328-
2329 \sa mapToGlobal()-
2330*/-
2331QPoint QWindow::mapFromGlobal(const QPoint &pos) const-
2332{-
2333 Q_D(const QWindow);-
2334 // QTBUG-43252, prefer platform implementation for foreign windows.-
2335 if (d->platformWindow
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
2336 && (type() == Qt::ForeignWindow || d->platformWindow->isEmbedded())) {
type() == Qt::ForeignWindowDescription
TRUEnever evaluated
FALSEnever evaluated
d->platformWin...->isEmbedded()Description
TRUEnever evaluated
FALSEnever evaluated
0
2337 return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapFromGlobal(QHighDpi::toNativeLocalPosition(pos, this)), this);
never executed: return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapFromGlobal(QHighDpi::toNativeLocalPosition(pos, this)), this);
0
2338 }-
2339 return pos - d->globalPosition();
never executed: return pos - d->globalPosition();
0
2340}-
2341-
2342-
2343Q_GUI_EXPORT QWindowPrivate *qt_window_private(QWindow *window)-
2344{-
2345 return window->d_func();
never executed: return window->d_func();
0
2346}-
2347-
2348void QWindowPrivate::maybeQuitOnLastWindowClosed()-
2349{-
2350 if (!QCoreApplication::instance())
!QCoreApplication::instance()Description
TRUEnever evaluated
FALSEnever evaluated
0
2351 return;
never executed: return;
0
2352-
2353 Q_Q(QWindow);-
2354 // Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent-
2355 bool quitOnClose = QGuiApplication::quitOnLastWindowClosed() && !q->parent();
QGuiApplicatio...WindowClosed()Description
TRUEnever evaluated
FALSEnever evaluated
!q->parent()Description
TRUEnever evaluated
FALSEnever evaluated
0
2356 QWindowList list = QGuiApplication::topLevelWindows();-
2357 bool lastWindowClosed = true;-
2358 for (int i = 0; i < list.size(); ++i) {
i < list.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
2359 QWindow *w = list.at(i);-
2360 if (!w->isVisible() || w->transientParent() || w->type() == Qt::ToolTip)
!w->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
w->transientParent()Description
TRUEnever evaluated
FALSEnever evaluated
w->type() == Qt::ToolTipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2361 continue;
never executed: continue;
0
2362 lastWindowClosed = false;-
2363 break;
never executed: break;
0
2364 }-
2365 if (lastWindowClosed) {
lastWindowClosedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2366 QGuiApplicationPrivate::emitLastWindowClosed();-
2367 if (quitOnClose) {
quitOnCloseDescription
TRUEnever evaluated
FALSEnever evaluated
0
2368 QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance()));-
2369 applicationPrivate->maybeQuit();-
2370 }
never executed: end of block
0
2371 }
never executed: end of block
0
2372}
never executed: end of block
0
2373-
2374QWindow *QWindowPrivate::topLevelWindow() const-
2375{-
2376 Q_Q(const QWindow);-
2377-
2378 QWindow *window = const_cast<QWindow *>(q);-
2379-
2380 while (window) {
windowDescription
TRUEnever evaluated
FALSEnever evaluated
0
2381 QWindow *parent = window->parent();-
2382 if (!parent)
!parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2383 parent = window->transientParent();
never executed: parent = window->transientParent();
0
2384-
2385 if (!parent)
!parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2386 break;
never executed: break;
0
2387-
2388 window = parent;-
2389 }
never executed: end of block
0
2390-
2391 return window;
never executed: return window;
0
2392}-
2393-
2394/*!-
2395 Creates a local representation of a window created by another process or by-
2396 using native libraries below Qt.-
2397-
2398 Given the handle \a id to a native window, this method creates a QWindow-
2399 object which can be used to represent the window when invoking methods like-
2400 setParent() and setTransientParent().-
2401-
2402 This can be used, on platforms which support it, to embed a QWindow inside a-
2403 native window, or to embed a native window inside a QWindow.-
2404-
2405 If foreign windows are not supported, this function returns 0.-
2406-
2407 \note The resulting QWindow should not be used to manipulate the underlying-
2408 native window (besides re-parenting), or to observe state changes of the-
2409 native window. Any support for these kind of operations is incidental, highly-
2410 platform dependent and untested.-
2411-
2412 \sa setParent()-
2413 \sa setTransientParent()-
2414*/-
2415QWindow *QWindow::fromWinId(WId id)-
2416{-
2417 if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ForeignWindows)) {
!QGuiApplicati...oreignWindows)Description
TRUEnever evaluated
FALSEnever evaluated
0
2418 qWarning() << "QWindow::fromWinId(): platform plugin does not support foreign windows.";-
2419 return 0;
never executed: return 0;
0
2420 }-
2421-
2422 QWindow *window = new QWindow;-
2423 window->setFlags(Qt::ForeignWindow);-
2424 window->setProperty("_q_foreignWinId", QVariant::fromValue(id));-
2425 window->create();-
2426 return window;
never executed: return window;
0
2427}-
2428-
2429/*!-
2430 Causes an alert to be shown for \a msec miliseconds. If \a msec is \c 0 (the-
2431 default), then the alert is shown indefinitely until the window becomes-
2432 active again. This function has no effect on an active window.-
2433-
2434 In alert state, the window indicates that it demands attention, for example by-
2435 flashing or bouncing the taskbar entry.-
2436-
2437 \since 5.1-
2438*/-
2439-
2440void QWindow::alert(int msec)-
2441{-
2442 Q_D(QWindow);-
2443 if (!d->platformWindow || d->platformWindow->isAlertState() || isActive())
!d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
d->platformWin...isAlertState()Description
TRUEnever evaluated
FALSEnever evaluated
isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
2444 return;
never executed: return;
0
2445 d->platformWindow->setAlertState(true);-
2446 if (d->platformWindow->isAlertState() && msec)
d->platformWin...isAlertState()Description
TRUEnever evaluated
FALSEnever evaluated
msecDescription
TRUEnever evaluated
FALSEnever evaluated
0
2447 QTimer::singleShot(msec, this, SLOT(_q_clearAlert()));
never executed: QTimer::singleShot(msec, this, qFlagLocation("1""_q_clearAlert()" "\0" __FILE__ ":" "2447"));
0
2448}
never executed: end of block
0
2449-
2450void QWindowPrivate::_q_clearAlert()-
2451{-
2452 if (platformWindow && platformWindow->isAlertState())
platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
platformWindow->isAlertState()Description
TRUEnever evaluated
FALSEnever evaluated
0
2453 platformWindow->setAlertState(false);
never executed: platformWindow->setAlertState(false);
0
2454}
never executed: end of block
0
2455-
2456#ifndef QT_NO_CURSOR-
2457/*!-
2458 \brief set the cursor shape for this window-
2459-
2460 The mouse \a cursor will assume this shape when it is over this-
2461 window, unless an override cursor is set.-
2462 See the \l{Qt::CursorShape}{list of predefined cursor objects} for a-
2463 range of useful shapes.-
2464-
2465 If no cursor has been set, or after a call to unsetCursor(), the-
2466 parent window's cursor is used.-
2467-
2468 By default, the cursor has the Qt::ArrowCursor shape.-
2469-
2470 Some underlying window implementations will reset the cursor if it-
2471 leaves a window even if the mouse is grabbed. If you want to have-
2472 a cursor set for all windows, even when outside the window, consider-
2473 QGuiApplication::setOverrideCursor().-
2474-
2475 \sa QGuiApplication::setOverrideCursor()-
2476*/-
2477void QWindow::setCursor(const QCursor &cursor)-
2478{-
2479 Q_D(QWindow);-
2480 d->setCursor(&cursor);-
2481}
never executed: end of block
0
2482-
2483/*!-
2484 \brief Restores the default arrow cursor for this window.-
2485 */-
2486void QWindow::unsetCursor()-
2487{-
2488 Q_D(QWindow);-
2489 d->setCursor(0);-
2490}
never executed: end of block
0
2491-
2492/*!-
2493 \brief the cursor shape for this window-
2494-
2495 \sa setCursor(), unsetCursor()-
2496*/-
2497QCursor QWindow::cursor() const-
2498{-
2499 Q_D(const QWindow);-
2500 return d->cursor;
never executed: return d->cursor;
0
2501}-
2502-
2503void QWindowPrivate::setCursor(const QCursor *newCursor)-
2504{-
2505-
2506 Q_Q(QWindow);-
2507 if (newCursor) {
newCursorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2508 const Qt::CursorShape newShape = newCursor->shape();-
2509 if (newShape <= Qt::LastCursor && hasCursor && newShape == cursor.shape())
newShape <= Qt::LastCursorDescription
TRUEnever evaluated
FALSEnever evaluated
hasCursorDescription
TRUEnever evaluated
FALSEnever evaluated
newShape == cursor.shape()Description
TRUEnever evaluated
FALSEnever evaluated
0
2510 return; // Unchanged and no bitmap/custom cursor.
never executed: return;
0
2511 cursor = *newCursor;-
2512 hasCursor = true;-
2513 } else {
never executed: end of block
0
2514 if (!hasCursor)
!hasCursorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2515 return;
never executed: return;
0
2516 cursor = QCursor(Qt::ArrowCursor);-
2517 hasCursor = false;-
2518 }
never executed: end of block
0
2519 // Only attempt to emit signal if there is an actual platform cursor-
2520 if (applyCursor()) {
applyCursor()Description
TRUEnever evaluated
FALSEnever evaluated
0
2521 QEvent event(QEvent::CursorChange);-
2522 QGuiApplication::sendEvent(q, &event);-
2523 }
never executed: end of block
0
2524}
never executed: end of block
0
2525-
2526// Apply the cursor and returns true iff the platform cursor exists-
2527bool QWindowPrivate::applyCursor()-
2528{-
2529 Q_Q(QWindow);-
2530 if (QScreen *screen = q->screen()) {
QScreen *screen = q->screen()Description
TRUEnever evaluated
FALSEnever evaluated
0
2531 if (QPlatformCursor *platformCursor = screen->handle()->cursor()) {
QPlatformCurso...le()->cursor()Description
TRUEnever evaluated
FALSEnever evaluated
0
2532 if (!platformWindow)
!platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
2533 return true;
never executed: return true;
0
2534 QCursor *c = QGuiApplication::overrideCursor();-
2535 if (!c && hasCursor)
!cDescription
TRUEnever evaluated
FALSEnever evaluated
hasCursorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2536 c = &cursor;
never executed: c = &cursor;
0
2537 platformCursor->changeCursor(c, q);-
2538 return true;
never executed: return true;
0
2539 }-
2540 }
never executed: end of block
0
2541 return false;
never executed: return false;
0
2542}-
2543#endif // QT_NO_CURSOR-
2544-
2545#ifndef QT_NO_DEBUG_STREAM-
2546QDebug operator<<(QDebug debug, const QWindow *window)-
2547{-
2548 QDebugStateSaver saver(debug);-
2549 debug.nospace();-
2550 if (window) {
windowDescription
TRUEnever evaluated
FALSEnever evaluated
0
2551 debug << window->metaObject()->className() << '(' << (const void *)window;-
2552 if (!window->objectName().isEmpty())
!window->objec...me().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2553 debug << ", name=" << window->objectName();
never executed: debug << ", name=" << window->objectName();
0
2554 if (debug.verbosity() > 2) {
debug.verbosity() > 2Description
TRUEnever evaluated
FALSEnever evaluated
0
2555 const QRect geometry = window->geometry();-
2556 if (window->isVisible())
window->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
2557 debug << ", visible";
never executed: debug << ", visible";
0
2558 if (window->isExposed())
window->isExposed()Description
TRUEnever evaluated
FALSEnever evaluated
0
2559 debug << ", exposed";
never executed: debug << ", exposed";
0
2560 debug << ", state=" << window->windowState()-
2561 << ", type=" << window->type() << ", flags=" << window->flags()-
2562 << ", surface type=" << window->surfaceType();-
2563 if (window->isTopLevel())
window->isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
0
2564 debug << ", toplevel";
never executed: debug << ", toplevel";
0
2565 debug << ", " << geometry.width() << 'x' << geometry.height()-
2566 << forcesign << geometry.x() << geometry.y() << noforcesign;-
2567 const QMargins margins = window->frameMargins();-
2568 if (!margins.isNull())
!margins.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2569 debug << ", margins=" << margins;
never executed: debug << ", margins=" << margins;
0
2570 debug << ", devicePixelRatio=" << window->devicePixelRatio();-
2571 if (const QPlatformWindow *platformWindow = window->handle())
const QPlatfor...ndow->handle()Description
TRUEnever evaluated
FALSEnever evaluated
0
2572 debug << ", winId=0x" << hex << platformWindow->winId() << dec;
never executed: debug << ", winId=0x" << hex << platformWindow->winId() << dec;
0
2573 if (const QScreen *screen = window->screen())
const QScreen ...ndow->screen()Description
TRUEnever evaluated
FALSEnever evaluated
0
2574 debug << ", on " << screen->name();
never executed: debug << ", on " << screen->name();
0
2575 }
never executed: end of block
0
2576 debug << ')';-
2577 } else {
never executed: end of block
0
2578 debug << "QWindow(0x0)";-
2579 }
never executed: end of block
0
2580 return debug;
never executed: return debug;
0
2581}-
2582#endif // !QT_NO_DEBUG_STREAM-
2583-
2584QT_END_NAMESPACE-
2585-
2586#include "moc_qwindow.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9