kernel/qscreen.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qscreen.h" -
43#include "qscreen_p.h" -
44#include "qpixmap.h" -
45#include "qguiapplication_p.h" -
46#include <qpa/qplatformscreen.h> -
47 -
48#include <QtCore/private/qobject_p.h> -
49 -
50QT_BEGIN_NAMESPACE -
51 -
52/*! -
53 \class QScreen -
54 \since 5.0 -
55 \brief The QScreen class is used to query screen properties. -
56 \inmodule QtGui -
57 -
58 A note on logical vs physical dots per inch: physical DPI is based on the -
59 actual physical pixel sizes when available, and is useful for print preview -
60 and other cases where it's desirable to know the exact physical dimensions -
61 of screen displayed contents. -
62 -
63 Logical dots per inch are used to convert font and user interface elements -
64 from point sizes to pixel sizes, and might be different from the physical -
65 dots per inch. The logical dots per inch are sometimes user-settable in the -
66 desktop environment's settings panel, to let the user globally control UI -
67 and font sizes in different applications. -
68 -
69 \inmodule QtGui -
70*/ -
71 -
72QScreen::QScreen(QPlatformScreen *screen) -
73 : QObject(*new QScreenPrivate(screen), 0) -
74{ -
75}
executed: }
Execution Count:289
289
76 -
77/*! -
78 Get the platform screen handle. -
79*/ -
80QPlatformScreen *QScreen::handle() const -
81{ -
82 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
83 return d->platformScreen;
executed: return d->platformScreen;
Execution Count:214893
214893
84} -
85 -
86/*! -
87 \property QScreen::name -
88 \brief a user presentable string representing the screen -
89 -
90 For example, on X11 these correspond to the XRandr screen names, -
91 typically "VGA1", "HDMI1", etc. -
92*/ -
93QString QScreen::name() const -
94{ -
95 Q_D(const QScreen);
never executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
96 return d->platformScreen->name();
never executed: return d->platformScreen->name();
0
97} -
98 -
99/*! -
100 \property QScreen::depth -
101 \brief the color depth of the screen -
102*/ -
103int QScreen::depth() const -
104{ -
105 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
106 return d->platformScreen->depth();
executed: return d->platformScreen->depth();
Execution Count:257
257
107} -
108 -
109/*! -
110 \property QScreen::size -
111 \brief the pixel resolution of the screen -
112*/ -
113QSize QScreen::size() const -
114{ -
115 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
116 return d->geometry.size();
executed: return d->geometry.size();
Execution Count:32
32
117} -
118 -
119/*! -
120 \property QScreen::physicalDotsPerInchX -
121 \brief the number of physical dots or pixels per inch in the horizontal direction -
122 -
123 This value represents the actual horizontal pixel density on the screen's display. -
124 Depending on what information the underlying system provides the value might not be -
125 entirely accurate. -
126 -
127 \sa physicalDotsPerInchY() -
128*/ -
129qreal QScreen::physicalDotsPerInchX() const -
130{ -
131 return size().width() / physicalSize().width() * qreal(25.4);
executed: return size().width() / physicalSize().width() * qreal(25.4);
Execution Count:16
16
132} -
133 -
134/*! -
135 \property QScreen::physicalDotsPerInchY -
136 \brief the number of physical dots or pixels per inch in the vertical direction -
137 -
138 This value represents the actual vertical pixel density on the screen's display. -
139 Depending on what information the underlying system provides the value might not be -
140 entirely accurate. -
141 -
142 \sa physicalDotsPerInchX() -
143*/ -
144qreal QScreen::physicalDotsPerInchY() const -
145{ -
146 return size().height() / physicalSize().height() * qreal(25.4);
executed: return size().height() / physicalSize().height() * qreal(25.4);
Execution Count:16
16
147} -
148 -
149/*! -
150 \property QScreen::physicalDotsPerInch -
151 \brief the number of physical dots or pixels per inch -
152 -
153 This value represents the pixel density on the screen's display. -
154 Depending on what information the underlying system provides the value might not be -
155 entirely accurate. -
156 -
157 This is a convenience property that's simply the average of the physicalDotsPerInchX -
158 and physicalDotsPerInchY properties. -
159 -
160 \sa physicalDotsPerInchX() -
161 \sa physicalDotsPerInchY() -
162*/ -
163qreal QScreen::physicalDotsPerInch() const -
164{ -
165 QSize sz = size();
never executed (the execution status of this line is deduced): QSize sz = size();
-
166 QSizeF psz = physicalSize();
never executed (the execution status of this line is deduced): QSizeF psz = physicalSize();
-
167 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
168} -
169 -
170/*! -
171 \property QScreen::logicalDotsPerInchX -
172 \brief the number of logical dots or pixels per inch in the horizontal direction -
173 -
174 This value is used to convert font point sizes to pixel sizes. -
175 -
176 \sa logicalDotsPerInchY() -
177*/ -
178qreal QScreen::logicalDotsPerInchX() const -
179{ -
180 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
181 return d->logicalDpi.first;
executed: return d->logicalDpi.first;
Execution Count:213
213
182} -
183 -
184/*! -
185 \property QScreen::logicalDotsPerInchY -
186 \brief the number of logical dots or pixels per inch in the vertical direction -
187 -
188 This value is used to convert font point sizes to pixel sizes. -
189 -
190 \sa logicalDotsPerInchX() -
191*/ -
192qreal QScreen::logicalDotsPerInchY() const -
193{ -
194 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
195 return d->logicalDpi.second;
executed: return d->logicalDpi.second;
Execution Count:123604
123604
196} -
197 -
198/*! -
199 \property QScreen::logicalDotsPerInch -
200 \brief the number of logical dots or pixels per inch -
201 -
202 This value can be used to convert font point sizes to pixel sizes. -
203 -
204 This is a convenience property that's simply the average of the logicalDotsPerInchX -
205 and logicalDotsPerInchY properties. -
206 -
207 \sa logicalDotsPerInchX() -
208 \sa logicalDotsPerInchY() -
209*/ -
210qreal QScreen::logicalDotsPerInch() const -
211{ -
212 Q_D(const QScreen);
never executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
213 QDpi dpi = d->logicalDpi;
never executed (the execution status of this line is deduced): QDpi dpi = d->logicalDpi;
-
214 return (dpi.first + dpi.second) * qreal(0.5);
never executed: return (dpi.first + dpi.second) * qreal(0.5);
0
215} -
216 -
217/*! -
218 Returns the ratio between physical pixels and device-independent pixels for the screen. -
219 -
220 Common values are 1.0 on normal displays and 2.0 on Apple "retina" displays. -
221 -
222 \sa QWindow::devicePixelRatio(), QGuiApplication::devicePixelRatio() -
223*/ -
224qreal QScreen::devicePixelRatio() const -
225{ -
226 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
227 return d->platformScreen->devicePixelRatio();
executed: return d->platformScreen->devicePixelRatio();
Execution Count:2
2
228} -
229 -
230/*! -
231 \property QScreen::physicalSize -
232 \brief the screen's physical size (in millimeters) -
233 -
234 The physical size represents the actual physical dimensions of the -
235 screen's display. -
236 -
237 Depending on what information the underlying system provides the value -
238 might not be entirely accurate. -
239*/ -
240QSizeF QScreen::physicalSize() const -
241{ -
242 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
243 return d->platformScreen->physicalSize();
executed: return d->platformScreen->physicalSize();
Execution Count:32
32
244} -
245 -
246/*! -
247 \property QScreen::availableSize -
248 \brief the screen's available size in pixels -
249 -
250 The available size is the size excluding window manager reserved areas -
251 such as task bars and system menus. -
252*/ -
253QSize QScreen::availableSize() const -
254{ -
255 Q_D(const QScreen);
never executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
256 return d->availableGeometry.size();
never executed: return d->availableGeometry.size();
0
257} -
258 -
259/*! -
260 \property QScreen::geometry -
261 \brief the screen's geometry in pixels -
262 -
263 As an example this might return QRect(0, 0, 1280, 1024), or in a -
264 virtual desktop setting QRect(1280, 0, 1280, 1024). -
265*/ -
266QRect QScreen::geometry() const -
267{ -
268 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
269 return d->geometry;
executed: return d->geometry;
Execution Count:5480
5480
270} -
271 -
272/*! -
273 \property QScreen::availableGeometry -
274 \brief the screen's available geometry in pixels -
275 -
276 The available geometry is the geometry excluding window manager reserved areas -
277 such as task bars and system menus. -
278*/ -
279QRect QScreen::availableGeometry() const -
280{ -
281 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
282 return d->availableGeometry;
executed: return d->availableGeometry;
Execution Count:3620
3620
283} -
284 -
285/*! -
286 Get the screen's virtual siblings. -
287 -
288 The virtual siblings are the screen instances sharing the same virtual desktop. -
289 They share a common coordinate system, and windows can freely be moved or -
290 positioned across them without having to be re-created. -
291*/ -
292QList<QScreen *> QScreen::virtualSiblings() const -
293{ -
294 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
295 QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings();
executed (the execution status of this line is deduced): QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings();
-
296 QList<QScreen *> screens;
executed (the execution status of this line is deduced): QList<QScreen *> screens;
-
297 foreach (QPlatformScreen *platformScreen, platformScreens)
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(platformScreens)> _container_(platformScreens); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QPlatformScreen *platformScreen = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
298 screens << platformScreen->screen();
executed: screens << platformScreen->screen();
Execution Count:388
388
299 return screens;
executed: return screens;
Execution Count:388
388
300} -
301 -
302/*! -
303 \property QScreen::virtualSize -
304 \brief the pixel size of the virtual desktop to which this screen belongs -
305 -
306 Returns the pixel size of the virtual desktop corresponding to this screen. -
307 -
308 This is the combined size of the virtual siblings' individual geometries. -
309 -
310 \sa virtualSiblings() -
311*/ -
312QSize QScreen::virtualSize() const -
313{ -
314 return virtualGeometry().size();
never executed: return virtualGeometry().size();
0
315} -
316 -
317/*! -
318 \property QScreen::virtualGeometry -
319 \brief the pixel geometry of the virtual desktop to which this screen belongs -
320 -
321 Returns the pixel geometry of the virtual desktop corresponding to this screen. -
322 -
323 This is the union of the virtual siblings' individual geometries. -
324 -
325 \sa virtualSiblings() -
326*/ -
327QRect QScreen::virtualGeometry() const -
328{ -
329 QRect result;
never executed (the execution status of this line is deduced): QRect result;
-
330 foreach (QScreen *screen, virtualSiblings())
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(virtualSiblings())> _container_(virtualSiblings()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QScreen *screen = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
331 result |= screen->geometry();
never executed: result |= screen->geometry();
0
332 return result;
never executed: return result;
0
333} -
334 -
335/*! -
336 \property QScreen::availableVirtualSize -
337 \brief the available size of the virtual desktop to which this screen belongs -
338 -
339 Returns the available pixel size of the virtual desktop corresponding to this screen. -
340 -
341 This is the combined size of the virtual siblings' individual available geometries. -
342 -
343 \sa availableSize(), virtualSiblings() -
344*/ -
345QSize QScreen::availableVirtualSize() const -
346{ -
347 return availableVirtualGeometry().size();
never executed: return availableVirtualGeometry().size();
0
348} -
349 -
350/*! -
351 \property QScreen::availableVirtualGeometry -
352 \brief the available geometry of the virtual desktop to which this screen belongs -
353 -
354 Returns the available geometry of the virtual desktop corresponding to this screen. -
355 -
356 This is the union of the virtual siblings' individual available geometries. -
357 -
358 \sa availableGeometry(), virtualSiblings() -
359*/ -
360QRect QScreen::availableVirtualGeometry() const -
361{ -
362 QRect result;
never executed (the execution status of this line is deduced): QRect result;
-
363 foreach (QScreen *screen, virtualSiblings())
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(virtualSiblings())> _container_(virtualSiblings()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QScreen *screen = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
364 result |= screen->availableGeometry();
never executed: result |= screen->availableGeometry();
0
365 return result;
never executed: return result;
0
366} -
367 -
368/*! -
369 Sets the orientations that the application is interested in receiving -
370 updates for in conjunction with this screen. -
371 -
372 For example, to receive orientation() updates and thus have -
373 orientationChanged() signals being emitted for LandscapeOrientation and -
374 InvertedLandscapeOrientation, call setOrientationUpdateMask() with -
375 \a{mask} set to Qt::LandscapeOrientation | Qt::InvertedLandscapeOrientation. -
376 -
377 The default, 0, means no orientationChanged() signals are fired. -
378*/ -
379void QScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) -
380{ -
381 Q_D(QScreen);
executed (the execution status of this line is deduced): QScreenPrivate * const d = d_func();
-
382 d->orientationUpdateMask = mask;
executed (the execution status of this line is deduced): d->orientationUpdateMask = mask;
-
383 d->platformScreen->setOrientationUpdateMask(mask);
executed (the execution status of this line is deduced): d->platformScreen->setOrientationUpdateMask(mask);
-
384 QGuiApplicationPrivate::updateFilteredScreenOrientation(this);
executed (the execution status of this line is deduced): QGuiApplicationPrivate::updateFilteredScreenOrientation(this);
-
385}
executed: }
Execution Count:3
3
386 -
387/*! -
388 Returns the currently set orientation update mask. -
389 -
390 \sa setOrientationUpdateMask() -
391*/ -
392Qt::ScreenOrientations QScreen::orientationUpdateMask() const -
393{ -
394 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
395 return d->orientationUpdateMask;
executed: return d->orientationUpdateMask;
Execution Count:12
12
396} -
397 -
398/*! -
399 \property QScreen::orientation -
400 \brief the screen orientation -
401 -
402 The screen orientation represents the physical orientation -
403 of the display. For example, the screen orientation of a mobile device -
404 will change based on the device is being held, and a desktop display -
405 might be rotated so that it's in portrait mode. -
406 -
407 Changes to this property will be filtered by orientationUpdateMask(), -
408 so in order to receive orientation updates the application must first -
409 call setOrientationUpdateMask() with a mask of the orientations it wants -
410 to receive. -
411 -
412 Qt::PrimaryOrientation is never returned. -
413 -
414 \sa primaryOrientation() -
415*/ -
416Qt::ScreenOrientation QScreen::orientation() const -
417{ -
418 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
419 return d->filteredOrientation;
executed: return d->filteredOrientation;
Execution Count:24
24
420} -
421 -
422/*! -
423 \property QScreen::refreshRate -
424 \brief the approximate vertical refresh rate of the screen in Hz -
425*/ -
426qreal QScreen::refreshRate() const -
427{ -
428 Q_D(const QScreen);
never executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
429 return d->refreshRate;
never executed: return d->refreshRate;
0
430} -
431 -
432/*! -
433 \property QScreen::primaryOrientation -
434 \brief the primary screen orientation -
435 -
436 The primary screen orientation is Qt::LandscapeOrientation -
437 if the screen geometry's width is greater than or equal to its -
438 height, or Qt::PortraitOrientation otherwise. -
439*/ -
440Qt::ScreenOrientation QScreen::primaryOrientation() const -
441{ -
442 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
443 return d->primaryOrientation;
executed: return d->primaryOrientation;
Execution Count:7
7
444} -
445 -
446// i must be power of two -
447static int log2(uint i) -
448{ -
449 if (i == 0)
partially evaluated: i == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
450 return -1;
never executed: return -1;
0
451 -
452 int result = 0;
executed (the execution status of this line is deduced): int result = 0;
-
453 while (!(i & 1)) {
evaluated: !(i & 1)
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:30
30-45
454 ++result;
executed (the execution status of this line is deduced): ++result;
-
455 i >>= 1;
executed (the execution status of this line is deduced): i >>= 1;
-
456 }
executed: }
Execution Count:45
45
457 return result;
executed: return result;
Execution Count:30
30
458} -
459 -
460/*! -
461 Convenience function to compute the angle of rotation to get from -
462 rotation \a a to rotation \a b. -
463 -
464 The result will be 0, 90, 180, or 270. -
465 -
466 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). -
467*/ -
468int QScreen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) const -
469{ -
470 if (a == Qt::PrimaryOrientation)
evaluated: a == Qt::PrimaryOrientation
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:19
1-19
471 a = primaryOrientation();
executed: a = primaryOrientation();
Execution Count:1
1
472 -
473 if (b == Qt::PrimaryOrientation)
evaluated: b == Qt::PrimaryOrientation
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:19
1-19
474 b = primaryOrientation();
executed: b = primaryOrientation();
Execution Count:1
1
475 -
476 if (a == b)
evaluated: a == b
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:15
5-15
477 return 0;
executed: return 0;
Execution Count:5
5
478 -
479 int ia = log2(uint(a));
executed (the execution status of this line is deduced): int ia = log2(uint(a));
-
480 int ib = log2(uint(b));
executed (the execution status of this line is deduced): int ib = log2(uint(b));
-
481 -
482 int delta = ia - ib;
executed (the execution status of this line is deduced): int delta = ia - ib;
-
483 -
484 if (delta < 0)
evaluated: delta < 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:7
7-8
485 delta = delta + 4;
executed: delta = delta + 4;
Execution Count:8
8
486 -
487 int angles[] = { 0, 90, 180, 270 };
executed (the execution status of this line is deduced): int angles[] = { 0, 90, 180, 270 };
-
488 return angles[delta];
executed: return angles[delta];
Execution Count:15
15
489} -
490 -
491/*! -
492 Convenience function to compute a transform that maps from the coordinate system -
493 defined by orientation \a a into the coordinate system defined by orientation -
494 \a b and target dimensions \a target. -
495 -
496 Example, \a a is Qt::Landscape, \a b is Qt::Portrait, and \a target is QRect(0, 0, w, h) -
497 the resulting transform will be such that the point QPoint(0, 0) is mapped to QPoint(0, w), -
498 and QPoint(h, w) is mapped to QPoint(0, h). Thus, the landscape coordinate system QRect(0, 0, h, w) -
499 is mapped (with a 90 degree rotation) into the portrait coordinate system QRect(0, 0, w, h). -
500 -
501 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). -
502*/ -
503QTransform QScreen::transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target) const -
504{ -
505 if (a == Qt::PrimaryOrientation)
partially evaluated: a == Qt::PrimaryOrientation
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
506 a = primaryOrientation();
never executed: a = primaryOrientation();
0
507 -
508 if (b == Qt::PrimaryOrientation)
evaluated: b == Qt::PrimaryOrientation
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
509 b = primaryOrientation();
executed: b = primaryOrientation();
Execution Count:1
1
510 -
511 if (a == b)
evaluated: a == b
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:5
3-5
512 return QTransform();
executed: return QTransform();
Execution Count:3
3
513 -
514 int angle = angleBetween(a, b);
executed (the execution status of this line is deduced): int angle = angleBetween(a, b);
-
515 -
516 QTransform result;
executed (the execution status of this line is deduced): QTransform result;
-
517 switch (angle) { -
518 case 90: -
519 result.translate(target.width(), 0);
executed (the execution status of this line is deduced): result.translate(target.width(), 0);
-
520 break;
executed: break;
Execution Count:2
2
521 case 180: -
522 result.translate(target.width(), target.height());
executed (the execution status of this line is deduced): result.translate(target.width(), target.height());
-
523 break;
executed: break;
Execution Count:2
2
524 case 270: -
525 result.translate(0, target.height());
executed (the execution status of this line is deduced): result.translate(0, target.height());
-
526 break;
executed: break;
Execution Count:1
1
527 default: -
528 Q_ASSERT(false);
never executed (the execution status of this line is deduced): qt_noop();
-
529 }
never executed: }
0
530 result.rotate(angle);
executed (the execution status of this line is deduced): result.rotate(angle);
-
531 -
532 return result;
executed: return result;
Execution Count:5
5
533} -
534 -
535/*! -
536 Maps the rect between two screen orientations. -
537 -
538 This will flip the x and y dimensions of the rectangle \a{rect} if the orientation \a{a} is -
539 Qt::PortraitOrientation or Qt::InvertedPortraitOrientation and orientation \a{b} is -
540 Qt::LandscapeOrientation or Qt::InvertedLandscapeOrientation, or vice versa. -
541 -
542 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). -
543*/ -
544QRect QScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect) const -
545{ -
546 if (a == Qt::PrimaryOrientation)
never evaluated: a == Qt::PrimaryOrientation
0
547 a = primaryOrientation();
never executed: a = primaryOrientation();
0
548 -
549 if (b == Qt::PrimaryOrientation)
never evaluated: b == Qt::PrimaryOrientation
0
550 b = primaryOrientation();
never executed: b = primaryOrientation();
0
551 -
552 if (a == b)
never evaluated: a == b
0
553 return rect;
never executed: return rect;
0
554 -
555 if ((a == Qt::PortraitOrientation || a == Qt::InvertedPortraitOrientation)
never evaluated: (a == Qt::PortraitOrientation || a == Qt::InvertedPortraitOrientation) != (b == Qt::PortraitOrientation || b == Qt::InvertedPortraitOrientation)
never evaluated: a == Qt::PortraitOrientation
never evaluated: a == Qt::InvertedPortraitOrientation
0
556 != (b == Qt::PortraitOrientation || b == Qt::InvertedPortraitOrientation))
never evaluated: (a == Qt::PortraitOrientation || a == Qt::InvertedPortraitOrientation) != (b == Qt::PortraitOrientation || b == Qt::InvertedPortraitOrientation)
never evaluated: b == Qt::PortraitOrientation
never evaluated: b == Qt::InvertedPortraitOrientation
0
557 { -
558 return QRect(rect.y(), rect.x(), rect.height(), rect.width());
never executed: return QRect(rect.y(), rect.x(), rect.height(), rect.width());
0
559 } -
560 -
561 return rect;
never executed: return rect;
0
562} -
563 -
564/*! -
565 Convenience function that returns true if \a o is either portrait or inverted portrait; -
566 otherwise returns false. -
567 -
568 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). -
569*/ -
570bool QScreen::isPortrait(Qt::ScreenOrientation o) const -
571{ -
572 return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation
never executed: return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
0
573 || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
never executed: return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
0
574} -
575 -
576/*! -
577 Convenience function that returns true if \a o is either landscape or inverted landscape; -
578 otherwise returns false. -
579 -
580 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). -
581*/ -
582bool QScreen::isLandscape(Qt::ScreenOrientation o) const -
583{ -
584 return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation
never executed: return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
0
585 || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
never executed: return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
0
586} -
587 -
588/*! -
589 \fn void QScreen::orientationChanged(Qt::ScreenOrientation orientation) -
590 -
591 This signal is emitted when the orientation of the screen -
592 changes. -
593 -
594 \sa orientation() -
595*/ -
596 -
597/*! -
598 \fn void QScreen::primaryOrientationChanged(Qt::ScreenOrientation orientation) -
599 -
600 This signal is emitted when the primary orientation of the screen -
601 changes. -
602 -
603 \sa primaryOrientation() -
604*/ -
605 -
606void QScreenPrivate::updatePrimaryOrientation() -
607{ -
608 primaryOrientation = geometry.width() >= geometry.height() ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
partially evaluated: geometry.width() >= geometry.height()
TRUEFALSE
yes
Evaluation Count:289
no
Evaluation Count:0
0-289
609}
executed: }
Execution Count:289
289
610 -
611/*! -
612 Creates and returns a pixmap constructed by grabbing the contents -
613 of the given \a window restricted by QRect(\a x, \a y, \a width, -
614 \a height). -
615 -
616 The arguments (\a{x}, \a{y}) specify the offset in the window, -
617 whereas (\a{width}, \a{height}) specify the area to be copied. If -
618 \a width is negative, the function copies everything to the right -
619 border of the window. If \a height is negative, the function -
620 copies everything to the bottom of the window. -
621 -
622 The window system identifier (\c WId) can be retrieved using the -
623 QWidget::winId() function. The rationale for using a window -
624 identifier and not a QWidget, is to enable grabbing of windows -
625 that are not part of the application, window system frames, and so -
626 on. -
627 -
628 The grabWindow() function grabs pixels from the screen, not from -
629 the window, i.e. if there is another window partially or entirely -
630 over the one you grab, you get pixels from the overlying window, -
631 too. The mouse cursor is generally not grabbed. -
632 -
633 Note on X11 that if the given \a window doesn't have the same depth -
634 as the root window, and another window partially or entirely -
635 obscures the one you grab, you will \e not get pixels from the -
636 overlying window. The contents of the obscured areas in the -
637 pixmap will be undefined and uninitialized. -
638 -
639 On Windows Vista and above grabbing a layered window, which is -
640 created by setting the Qt::WA_TranslucentBackground attribute, will -
641 not work. Instead grabbing the desktop widget should work. -
642 -
643 \warning In general, grabbing an area outside the screen is not -
644 safe. This depends on the underlying window system. -
645*/ -
646 -
647QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height) -
648{ -
649 const QPlatformScreen *platformScreen = handle();
executed (the execution status of this line is deduced): const QPlatformScreen *platformScreen = handle();
-
650 if (!platformScreen) {
partially evaluated: !platformScreen
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:44
0-44
651 qWarning("%s invoked with handle==0", Q_FUNC_INFO);
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qscreen.cpp", 651, __PRETTY_FUNCTION__).warning("%s invoked with handle==0", __PRETTY_FUNCTION__);
-
652 return QPixmap();
never executed: return QPixmap();
0
653 } -
654 return platformScreen->grabWindow(window, x, y, width, height);
executed: return platformScreen->grabWindow(window, x, y, width, height);
Execution Count:44
44
655} -
656 -
657QT_END_NAMESPACE -
658 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial