OpenCoverage

qscreen.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qscreen.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qscreen.h"-
41#include "qscreen_p.h"-
42#include "qpixmap.h"-
43#include "qguiapplication_p.h"-
44#include <qpa/qplatformscreen.h>-
45#include <qpa/qplatformscreen_p.h>-
46-
47#include <QtCore/QDebug>-
48#include <QtCore/private/qobject_p.h>-
49#include "qhighdpiscaling_p.h"-
50-
51QT_BEGIN_NAMESPACE-
52-
53/*!-
54 \class QScreen-
55 \since 5.0-
56 \brief The QScreen class is used to query screen properties.-
57 \inmodule QtGui-
58-
59 A note on logical vs physical dots per inch: physical DPI is based on the-
60 actual physical pixel sizes when available, and is useful for print preview-
61 and other cases where it's desirable to know the exact physical dimensions-
62 of screen displayed contents.-
63-
64 Logical dots per inch are used to convert font and user interface elements-
65 from point sizes to pixel sizes, and might be different from the physical-
66 dots per inch. The logical dots per inch are sometimes user-settable in the-
67 desktop environment's settings panel, to let the user globally control UI-
68 and font sizes in different applications.-
69-
70 \inmodule QtGui-
71*/-
72-
73QScreen::QScreen(QPlatformScreen *screen)-
74 : QObject(*new QScreenPrivate(), 0)-
75{-
76 Q_D(QScreen);-
77 d->setPlatformScreen(screen);-
78}
never executed: end of block
0
79-
80void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen)-
81{-
82 Q_Q(QScreen);-
83 platformScreen = screen;-
84 platformScreen->d_func()->screen = q;-
85 orientation = platformScreen->orientation();-
86 geometry = platformScreen->deviceIndependentGeometry();-
87 availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());-
88 logicalDpi = platformScreen->logicalDpi();-
89 refreshRate = platformScreen->refreshRate();-
90 // safeguard ourselves against buggy platform behavior...-
91 if (refreshRate < 1.0)
refreshRate < 1.0Description
TRUEnever evaluated
FALSEnever evaluated
0
92 refreshRate = 60.0;
never executed: refreshRate = 60.0;
0
93-
94 updatePrimaryOrientation();-
95-
96 filteredOrientation = orientation;-
97 if (filteredOrientation == Qt::PrimaryOrientation)
filteredOrient...aryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
0
98 filteredOrientation = primaryOrientation;
never executed: filteredOrientation = primaryOrientation;
0
99-
100 updateHighDpi();-
101}
never executed: end of block
0
102-
103-
104/*!-
105 Destroys the screen.-
106 */-
107QScreen::~QScreen()-
108{-
109 if (!qApp)
!(static_cast<...::instance()))Description
TRUEnever evaluated
FALSEnever evaluated
0
110 return;
never executed: return;
0
111-
112 // Allow clients to manage windows that are affected by the screen going-
113 // away, before we fall back to moving them to the primary screen.-
114 emit qApp->screenRemoved(this);-
115-
116 if (QGuiApplication::closingDown())
QGuiApplication::closingDown()Description
TRUEnever evaluated
FALSEnever evaluated
0
117 return;
never executed: return;
0
118-
119 QScreen *primaryScreen = QGuiApplication::primaryScreen();-
120 if (this == primaryScreen)
this == primaryScreenDescription
TRUEnever evaluated
FALSEnever evaluated
0
121 return;
never executed: return;
0
122-
123 bool movingFromVirtualSibling = primaryScreen && primaryScreen->handle()->virtualSiblings().contains(handle());
primaryScreenDescription
TRUEnever evaluated
FALSEnever evaluated
primaryScreen-...ains(handle())Description
TRUEnever evaluated
FALSEnever evaluated
0
124-
125 // Move any leftover windows to the primary screen-
126 const auto allWindows = QGuiApplication::allWindows();-
127 for (QWindow *window : allWindows) {-
128 if (!window->isTopLevel() || window->screen() != this)
!window->isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
window->screen() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
129 continue;
never executed: continue;
0
130-
131 const bool wasVisible = window->isVisible();-
132 window->setScreen(primaryScreen);-
133-
134 // Re-show window if moved from a virtual sibling screen. Otherwise-
135 // leave it up to the application developer to show the window.-
136 if (movingFromVirtualSibling)
movingFromVirtualSiblingDescription
TRUEnever evaluated
FALSEnever evaluated
0
137 window->setVisible(wasVisible);
never executed: window->setVisible(wasVisible);
0
138 }
never executed: end of block
0
139}
never executed: end of block
0
140-
141/*!-
142 Get the platform screen handle.-
143*/-
144QPlatformScreen *QScreen::handle() const-
145{-
146 Q_D(const QScreen);-
147 return d->platformScreen;
never executed: return d->platformScreen;
0
148}-
149-
150/*!-
151 \property QScreen::name-
152 \brief a user presentable string representing the screen-
153-
154 For example, on X11 these correspond to the XRandr screen names,-
155 typically "VGA1", "HDMI1", etc.-
156*/-
157QString QScreen::name() const-
158{-
159 Q_D(const QScreen);-
160 return d->platformScreen->name();
never executed: return d->platformScreen->name();
0
161}-
162-
163/*!-
164 \property QScreen::depth-
165 \brief the color depth of the screen-
166*/-
167int QScreen::depth() const-
168{-
169 Q_D(const QScreen);-
170 return d->platformScreen->depth();
never executed: return d->platformScreen->depth();
0
171}-
172-
173/*!-
174 \property QScreen::size-
175 \brief the pixel resolution of the screen-
176*/-
177QSize QScreen::size() const-
178{-
179 Q_D(const QScreen);-
180 return d->geometry.size();
never executed: return d->geometry.size();
0
181}-
182-
183/*!-
184 \property QScreen::physicalDotsPerInchX-
185 \brief the number of physical dots or pixels per inch in the horizontal direction-
186-
187 This value represents the actual horizontal pixel density on the screen's display.-
188 Depending on what information the underlying system provides the value might not be-
189 entirely accurate.-
190-
191 \sa physicalDotsPerInchY()-
192*/-
193qreal QScreen::physicalDotsPerInchX() const-
194{-
195 return size().width() / physicalSize().width() * qreal(25.4);
never executed: return size().width() / physicalSize().width() * qreal(25.4);
0
196}-
197-
198/*!-
199 \property QScreen::physicalDotsPerInchY-
200 \brief the number of physical dots or pixels per inch in the vertical direction-
201-
202 This value represents the actual vertical pixel density on the screen's display.-
203 Depending on what information the underlying system provides the value might not be-
204 entirely accurate.-
205-
206 \sa physicalDotsPerInchX()-
207*/-
208qreal QScreen::physicalDotsPerInchY() const-
209{-
210 return size().height() / physicalSize().height() * qreal(25.4);
never executed: return size().height() / physicalSize().height() * qreal(25.4);
0
211}-
212-
213/*!-
214 \property QScreen::physicalDotsPerInch-
215 \brief the number of physical dots or pixels per inch-
216-
217 This value represents the pixel density on the screen's display.-
218 Depending on what information the underlying system provides the value might not be-
219 entirely accurate.-
220-
221 This is a convenience property that's simply the average of the physicalDotsPerInchX-
222 and physicalDotsPerInchY properties.-
223-
224 \sa physicalDotsPerInchX()-
225 \sa physicalDotsPerInchY()-
226*/-
227qreal QScreen::physicalDotsPerInch() const-
228{-
229 QSize sz = size();-
230 QSizeF psz = physicalSize();-
231 return ((sz.height() / psz.height()) + (sz.width() / psz.width())) * qreal(25.4 * 0.5);
never executed: return ((sz.height() / psz.height()) + (sz.width() / psz.width())) * qreal(25.4 * 0.5);
0
232}-
233-
234/*!-
235 \property QScreen::logicalDotsPerInchX-
236 \brief the number of logical dots or pixels per inch in the horizontal direction-
237-
238 This value is used to convert font point sizes to pixel sizes.-
239-
240 \sa logicalDotsPerInchY()-
241*/-
242qreal QScreen::logicalDotsPerInchX() const-
243{-
244 Q_D(const QScreen);-
245 if (QHighDpiScaling::isActive())
QHighDpiScaling::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
246 return QHighDpiScaling::logicalDpi().first;
never executed: return QHighDpiScaling::logicalDpi().first;
0
247 return d->logicalDpi.first;
never executed: return d->logicalDpi.first;
0
248}-
249-
250/*!-
251 \property QScreen::logicalDotsPerInchY-
252 \brief the number of logical dots or pixels per inch in the vertical direction-
253-
254 This value is used to convert font point sizes to pixel sizes.-
255-
256 \sa logicalDotsPerInchX()-
257*/-
258qreal QScreen::logicalDotsPerInchY() const-
259{-
260 Q_D(const QScreen);-
261 if (QHighDpiScaling::isActive())
QHighDpiScaling::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
262 return QHighDpiScaling::logicalDpi().second;
never executed: return QHighDpiScaling::logicalDpi().second;
0
263 return d->logicalDpi.second;
never executed: return d->logicalDpi.second;
0
264}-
265-
266/*!-
267 \property QScreen::logicalDotsPerInch-
268 \brief the number of logical dots or pixels per inch-
269-
270 This value can be used to convert font point sizes to pixel sizes.-
271-
272 This is a convenience property that's simply the average of the logicalDotsPerInchX-
273 and logicalDotsPerInchY properties.-
274-
275 \sa logicalDotsPerInchX()-
276 \sa logicalDotsPerInchY()-
277*/-
278qreal QScreen::logicalDotsPerInch() const-
279{-
280 Q_D(const QScreen);-
281 QDpi dpi = QHighDpiScaling::isActive() ? QHighDpiScaling::logicalDpi() : d->logicalDpi;
QHighDpiScaling::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
282 return (dpi.first + dpi.second) * qreal(0.5);
never executed: return (dpi.first + dpi.second) * qreal(0.5);
0
283}-
284-
285/*!-
286 \property QScreen::devicePixelRatio-
287 \brief the screen's ratio between physical pixels and device-independent pixels-
288 \since 5.5-
289-
290 Returns the ratio between physical pixels and device-independent pixels for the screen.-
291-
292 Common values are 1.0 on normal displays and 2.0 on "retina" displays.-
293 Higher values are also possible.-
294-
295 \sa QWindow::devicePixelRatio(), QGuiApplication::devicePixelRatio()-
296*/-
297qreal QScreen::devicePixelRatio() const-
298{-
299 Q_D(const QScreen);-
300 return d->platformScreen->devicePixelRatio() * QHighDpiScaling::factor(this);
never executed: return d->platformScreen->devicePixelRatio() * QHighDpiScaling::factor(this);
0
301}-
302-
303/*!-
304 \property QScreen::physicalSize-
305 \brief the screen's physical size (in millimeters)-
306-
307 The physical size represents the actual physical dimensions of the-
308 screen's display.-
309-
310 Depending on what information the underlying system provides the value-
311 might not be entirely accurate.-
312*/-
313QSizeF QScreen::physicalSize() const-
314{-
315 Q_D(const QScreen);-
316 return d->platformScreen->physicalSize();
never executed: return d->platformScreen->physicalSize();
0
317}-
318-
319/*!-
320 \property QScreen::availableSize-
321 \brief the screen's available size in pixels-
322-
323 The available size is the size excluding window manager reserved areas-
324 such as task bars and system menus.-
325*/-
326QSize QScreen::availableSize() const-
327{-
328 Q_D(const QScreen);-
329 return d->availableGeometry.size();
never executed: return d->availableGeometry.size();
0
330}-
331-
332/*!-
333 \property QScreen::geometry-
334 \brief the screen's geometry in pixels-
335-
336 As an example this might return QRect(0, 0, 1280, 1024), or in a-
337 virtual desktop setting QRect(1280, 0, 1280, 1024).-
338*/-
339QRect QScreen::geometry() const-
340{-
341 Q_D(const QScreen);-
342 return d->geometry;
never executed: return d->geometry;
0
343}-
344-
345/*!-
346 \property QScreen::availableGeometry-
347 \brief the screen's available geometry in pixels-
348-
349 The available geometry is the geometry excluding window manager reserved areas-
350 such as task bars and system menus.-
351*/-
352QRect QScreen::availableGeometry() const-
353{-
354 Q_D(const QScreen);-
355 return d->availableGeometry;
never executed: return d->availableGeometry;
0
356}-
357-
358/*!-
359 Get the screen's virtual siblings.-
360-
361 The virtual siblings are the screen instances sharing the same virtual desktop.-
362 They share a common coordinate system, and windows can freely be moved or-
363 positioned across them without having to be re-created.-
364*/-
365QList<QScreen *> QScreen::virtualSiblings() const-
366{-
367 Q_D(const QScreen);-
368 const QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings();-
369 QList<QScreen *> screens;-
370 screens.reserve(platformScreens.count());-
371 for (QPlatformScreen *platformScreen : platformScreens)-
372 screens << platformScreen->screen();
never executed: screens << platformScreen->screen();
0
373 return screens;
never executed: return screens;
0
374}-
375-
376/*!-
377 \property QScreen::virtualSize-
378 \brief the pixel size of the virtual desktop to which this screen belongs-
379-
380 Returns the pixel size of the virtual desktop corresponding to this screen.-
381-
382 This is the combined size of the virtual siblings' individual geometries.-
383-
384 \sa virtualSiblings()-
385*/-
386QSize QScreen::virtualSize() const-
387{-
388 return virtualGeometry().size();
never executed: return virtualGeometry().size();
0
389}-
390-
391/*!-
392 \property QScreen::virtualGeometry-
393 \brief the pixel geometry of the virtual desktop to which this screen belongs-
394-
395 Returns the pixel geometry of the virtual desktop corresponding to this screen.-
396-
397 This is the union of the virtual siblings' individual geometries.-
398-
399 \sa virtualSiblings()-
400*/-
401QRect QScreen::virtualGeometry() const-
402{-
403 QRect result;-
404 const auto screens = virtualSiblings();-
405 for (QScreen *screen : screens)-
406 result |= screen->geometry();
never executed: result |= screen->geometry();
0
407 return result;
never executed: return result;
0
408}-
409-
410/*!-
411 \property QScreen::availableVirtualSize-
412 \brief the available size of the virtual desktop to which this screen belongs-
413-
414 Returns the available pixel size of the virtual desktop corresponding to this screen.-
415-
416 This is the combined size of the virtual siblings' individual available geometries.-
417-
418 \sa availableSize(), virtualSiblings()-
419*/-
420QSize QScreen::availableVirtualSize() const-
421{-
422 return availableVirtualGeometry().size();
never executed: return availableVirtualGeometry().size();
0
423}-
424-
425/*!-
426 \property QScreen::availableVirtualGeometry-
427 \brief the available geometry of the virtual desktop to which this screen belongs-
428-
429 Returns the available geometry of the virtual desktop corresponding to this screen.-
430-
431 This is the union of the virtual siblings' individual available geometries.-
432-
433 \sa availableGeometry(), virtualSiblings()-
434*/-
435QRect QScreen::availableVirtualGeometry() const-
436{-
437 QRect result;-
438 const auto screens = virtualSiblings();-
439 for (QScreen *screen : screens)-
440 result |= screen->availableGeometry();
never executed: result |= screen->availableGeometry();
0
441 return result;
never executed: return result;
0
442}-
443-
444/*!-
445 Sets the orientations that the application is interested in receiving-
446 updates for in conjunction with this screen.-
447-
448 For example, to receive orientation() updates and thus have-
449 orientationChanged() signals being emitted for LandscapeOrientation and-
450 InvertedLandscapeOrientation, call setOrientationUpdateMask() with-
451 \a{mask} set to Qt::LandscapeOrientation | Qt::InvertedLandscapeOrientation.-
452-
453 The default, 0, means no orientationChanged() signals are fired.-
454*/-
455void QScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask)-
456{-
457 Q_D(QScreen);-
458 d->orientationUpdateMask = mask;-
459 d->platformScreen->setOrientationUpdateMask(mask);-
460 QGuiApplicationPrivate::updateFilteredScreenOrientation(this);-
461}
never executed: end of block
0
462-
463/*!-
464 Returns the currently set orientation update mask.-
465-
466 \sa setOrientationUpdateMask()-
467*/-
468Qt::ScreenOrientations QScreen::orientationUpdateMask() const-
469{-
470 Q_D(const QScreen);-
471 return d->orientationUpdateMask;
never executed: return d->orientationUpdateMask;
0
472}-
473-
474/*!-
475 \property QScreen::orientation-
476 \brief the screen orientation-
477-
478 The screen orientation represents the physical orientation-
479 of the display. For example, the screen orientation of a mobile device-
480 will change based on how it is being held. A change to the orientation-
481 might or might not trigger a change to the primary orientation of the screen.-
482-
483 Changes to this property will be filtered by orientationUpdateMask(),-
484 so in order to receive orientation updates the application must first-
485 call setOrientationUpdateMask() with a mask of the orientations it wants-
486 to receive.-
487-
488 Qt::PrimaryOrientation is never returned.-
489-
490 \sa primaryOrientation()-
491*/-
492Qt::ScreenOrientation QScreen::orientation() const-
493{-
494 Q_D(const QScreen);-
495 return d->filteredOrientation;
never executed: return d->filteredOrientation;
0
496}-
497-
498/*!-
499 \property QScreen::refreshRate-
500 \brief the approximate vertical refresh rate of the screen in Hz-
501*/-
502qreal QScreen::refreshRate() const-
503{-
504 Q_D(const QScreen);-
505 return d->refreshRate;
never executed: return d->refreshRate;
0
506}-
507-
508/*!-
509 \property QScreen::primaryOrientation-
510 \brief the primary screen orientation-
511-
512 The primary screen orientation is Qt::LandscapeOrientation-
513 if the screen geometry's width is greater than or equal to its-
514 height, or Qt::PortraitOrientation otherwise. This property might-
515 change when the screen orientation was changed (i.e. when the-
516 display is rotated).-
517 The behavior is however platform dependent and can often be specified in-
518 an application manifest file.-
519-
520*/-
521Qt::ScreenOrientation QScreen::primaryOrientation() const-
522{-
523 Q_D(const QScreen);-
524 return d->primaryOrientation;
never executed: return d->primaryOrientation;
0
525}-
526-
527/*!-
528 \property QScreen::nativeOrientation-
529 \brief the native screen orientation-
530 \since 5.2-
531-
532 The native orientation of the screen is the orientation where the logo-
533 sticker of the device appears the right way up, or Qt::PrimaryOrientation-
534 if the platform does not support this functionality.-
535-
536 The native orientation is a property of the hardware, and does not change.-
537*/-
538Qt::ScreenOrientation QScreen::nativeOrientation() const-
539{-
540 Q_D(const QScreen);-
541 return d->platformScreen->nativeOrientation();
never executed: return d->platformScreen->nativeOrientation();
0
542}-
543-
544/*!-
545 Convenience function to compute the angle of rotation to get from-
546 rotation \a a to rotation \a b.-
547-
548 The result will be 0, 90, 180, or 270.-
549-
550 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().-
551*/-
552int QScreen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) const-
553{-
554 if (a == Qt::PrimaryOrientation)
a == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
0
555 a = primaryOrientation();
never executed: a = primaryOrientation();
0
556-
557 if (b == Qt::PrimaryOrientation)
b == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
0
558 b = primaryOrientation();
never executed: b = primaryOrientation();
0
559-
560 return QPlatformScreen::angleBetween(a, b);
never executed: return QPlatformScreen::angleBetween(a, b);
0
561}-
562-
563/*!-
564 Convenience function to compute a transform that maps from the coordinate system-
565 defined by orientation \a a into the coordinate system defined by orientation-
566 \a b and target dimensions \a target.-
567-
568 Example, \a a is Qt::Landscape, \a b is Qt::Portrait, and \a target is QRect(0, 0, w, h)-
569 the resulting transform will be such that the point QPoint(0, 0) is mapped to QPoint(0, w),-
570 and QPoint(h, w) is mapped to QPoint(0, h). Thus, the landscape coordinate system QRect(0, 0, h, w)-
571 is mapped (with a 90 degree rotation) into the portrait coordinate system QRect(0, 0, w, h).-
572-
573 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().-
574*/-
575QTransform QScreen::transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target) const-
576{-
577 if (a == Qt::PrimaryOrientation)
a == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
0
578 a = primaryOrientation();
never executed: a = primaryOrientation();
0
579-
580 if (b == Qt::PrimaryOrientation)
b == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
0
581 b = primaryOrientation();
never executed: b = primaryOrientation();
0
582-
583 return QPlatformScreen::transformBetween(a, b, target);
never executed: return QPlatformScreen::transformBetween(a, b, target);
0
584}-
585-
586/*!-
587 Maps the rect between two screen orientations.-
588-
589 This will flip the x and y dimensions of the rectangle \a{rect} if the orientation \a{a} is-
590 Qt::PortraitOrientation or Qt::InvertedPortraitOrientation and orientation \a{b} is-
591 Qt::LandscapeOrientation or Qt::InvertedLandscapeOrientation, or vice versa.-
592-
593 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().-
594*/-
595QRect QScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect) const-
596{-
597 if (a == Qt::PrimaryOrientation)
a == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
0
598 a = primaryOrientation();
never executed: a = primaryOrientation();
0
599-
600 if (b == Qt::PrimaryOrientation)
b == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
0
601 b = primaryOrientation();
never executed: b = primaryOrientation();
0
602-
603 return QPlatformScreen::mapBetween(a, b, rect);
never executed: return QPlatformScreen::mapBetween(a, b, rect);
0
604}-
605-
606/*!-
607 Convenience function that returns \c true if \a o is either portrait or inverted portrait;-
608 otherwise returns \c false.-
609-
610 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().-
611*/-
612bool QScreen::isPortrait(Qt::ScreenOrientation o) const-
613{-
614 return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation
never executed: return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
0
615 || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
never executed: return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
0
616}-
617-
618/*!-
619 Convenience function that returns \c true if \a o is either landscape or inverted landscape;-
620 otherwise returns \c false.-
621-
622 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().-
623*/-
624bool QScreen::isLandscape(Qt::ScreenOrientation o) const-
625{-
626 return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation
never executed: return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
0
627 || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
never executed: return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
0
628}-
629-
630/*!-
631 \fn void QScreen::orientationChanged(Qt::ScreenOrientation orientation)-
632-
633 This signal is emitted when the orientation of the screen-
634 changes with \a orientation as an argument.-
635-
636 \sa orientation()-
637*/-
638-
639/*!-
640 \fn void QScreen::primaryOrientationChanged(Qt::ScreenOrientation orientation)-
641-
642 This signal is emitted when the primary orientation of the screen-
643 changes with \a orientation as an argument.-
644-
645 \sa primaryOrientation()-
646*/-
647-
648void QScreenPrivate::updatePrimaryOrientation()-
649{-
650 primaryOrientation = geometry.width() >= geometry.height() ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
geometry.width...metry.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
651}
never executed: end of block
0
652-
653/*!-
654 Creates and returns a pixmap constructed by grabbing the contents-
655 of the given \a window restricted by QRect(\a x, \a y, \a width,-
656 \a height).-
657-
658 The arguments (\a{x}, \a{y}) specify the offset in the window,-
659 whereas (\a{width}, \a{height}) specify the area to be copied. If-
660 \a width is negative, the function copies everything to the right-
661 border of the window. If \a height is negative, the function-
662 copies everything to the bottom of the window.-
663-
664 The window system identifier (\c WId) can be retrieved using the-
665 QWidget::winId() function. The rationale for using a window-
666 identifier and not a QWidget, is to enable grabbing of windows-
667 that are not part of the application, window system frames, and so-
668 on.-
669-
670 The grabWindow() function grabs pixels from the screen, not from-
671 the window, i.e. if there is another window partially or entirely-
672 over the one you grab, you get pixels from the overlying window,-
673 too. The mouse cursor is generally not grabbed.-
674-
675 Note on X11 that if the given \a window doesn't have the same depth-
676 as the root window, and another window partially or entirely-
677 obscures the one you grab, you will \e not get pixels from the-
678 overlying window. The contents of the obscured areas in the-
679 pixmap will be undefined and uninitialized.-
680-
681 On Windows Vista and above grabbing a layered window, which is-
682 created by setting the Qt::WA_TranslucentBackground attribute, will-
683 not work. Instead grabbing the desktop widget should work.-
684-
685 \warning In general, grabbing an area outside the screen is not-
686 safe. This depends on the underlying window system.-
687*/-
688-
689QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height)-
690{-
691 const QPlatformScreen *platformScreen = handle();-
692 if (!platformScreen) {
!platformScreenDescription
TRUEnever evaluated
FALSEnever evaluated
0
693 qWarning("invoked with handle==0");-
694 return QPixmap();
never executed: return QPixmap();
0
695 }-
696 const qreal factor = QHighDpiScaling::factor(this);-
697 if (qFuzzyCompare(factor, 1))
qFuzzyCompare(factor, 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
698 return platformScreen->grabWindow(window, x, y, width, height);
never executed: return platformScreen->grabWindow(window, x, y, width, height);
0
699-
700 const QPoint nativePos = QHighDpi::toNative(QPoint(x, y), factor);-
701 QSize nativeSize(width, height);-
702 if (nativeSize.isValid())
nativeSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
703 nativeSize = QHighDpi::toNative(nativeSize, factor);
never executed: nativeSize = QHighDpi::toNative(nativeSize, factor);
0
704 QPixmap result =-
705 platformScreen->grabWindow(window, nativePos.x(), nativePos.y(),-
706 nativeSize.width(), nativeSize.height());-
707 result.setDevicePixelRatio(factor);-
708 return result;
never executed: return result;
0
709}-
710-
711#ifndef QT_NO_DEBUG_STREAM-
712-
713static inline void formatRect(QDebug &debug, const QRect r)-
714{-
715 debug << r.width() << 'x' << r.height()-
716 << forcesign << r.x() << r.y() << noforcesign;-
717}
never executed: end of block
0
718-
719Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QScreen *screen)-
720{-
721 const QDebugStateSaver saver(debug);-
722 debug.nospace();-
723 debug << "QScreen(" << (const void *)screen;-
724 if (screen) {
screenDescription
TRUEnever evaluated
FALSEnever evaluated
0
725 debug << ", name=" << screen->name();-
726 if (debug.verbosity() > 2) {
debug.verbosity() > 2Description
TRUEnever evaluated
FALSEnever evaluated
0
727 if (screen == QGuiApplication::primaryScreen())
screen == QGui...rimaryScreen()Description
TRUEnever evaluated
FALSEnever evaluated
0
728 debug << ", primary";
never executed: debug << ", primary";
0
729 debug << ", geometry=";-
730 formatRect(debug, screen->geometry());-
731 debug << ", available=";-
732 formatRect(debug, screen->availableGeometry());-
733 debug << ", logical DPI=" << screen->logicalDotsPerInchX()-
734 << ',' << screen->logicalDotsPerInchY()-
735 << ", physical DPI=" << screen->physicalDotsPerInchX()-
736 << ',' << screen->physicalDotsPerInchY()-
737 << ", devicePixelRatio=" << screen->devicePixelRatio()-
738 << ", orientation=" << screen->orientation()-
739 << ", physical size=" << screen->physicalSize().width()-
740 << 'x' << screen->physicalSize().height() << "mm";-
741 }
never executed: end of block
0
742 }
never executed: end of block
0
743 debug << ')';-
744 return debug;
never executed: return debug;
0
745}-
746#endif // !QT_NO_DEBUG_STREAM-
747-
748QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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