kernel/qscreen.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2012 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:276
276
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:67275
67275
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:237
237
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:383
383
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:47730
47730
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(); -
223 \sa QGuiApplicaiton::devicePixelRatio(); -
224*/ -
225qreal QScreen::devicePixelRatio() const -
226{ -
227 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
228 return d->platformScreen->devicePixelRatio();
executed: return d->platformScreen->devicePixelRatio();
Execution Count:2
2
229} -
230 -
231/*! -
232 \property QScreen::physicalSize -
233 \brief the screen's physical size (in millimeters) -
234 -
235 The physical size represents the actual physical dimensions of the -
236 screen's display. -
237 -
238 Depending on what information the underlying system provides the value -
239 might not be entirely accurate. -
240*/ -
241QSizeF QScreen::physicalSize() const -
242{ -
243 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
244 return d->platformScreen->physicalSize();
executed: return d->platformScreen->physicalSize();
Execution Count:32
32
245} -
246 -
247/*! -
248 \property QScreen::availableSize -
249 \brief the screen's available size in pixels -
250 -
251 The available size is the size excluding window manager reserved areas -
252 such as task bars and system menus. -
253*/ -
254QSize QScreen::availableSize() const -
255{ -
256 Q_D(const QScreen);
never executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
257 return d->availableGeometry.size();
never executed: return d->availableGeometry.size();
0
258} -
259 -
260/*! -
261 \property QScreen::geometry -
262 \brief the screen's geometry in pixels -
263 -
264 As an example this might return QRect(0, 0, 1280, 1024), or in a -
265 virtual desktop setting QRect(1280, 0, 1280, 1024). -
266*/ -
267QRect QScreen::geometry() const -
268{ -
269 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
270 return d->geometry;
executed: return d->geometry;
Execution Count:4349
4349
271} -
272 -
273/*! -
274 \property QScreen::availableGeometry -
275 \brief the screen's available geometry in pixels -
276 -
277 The available geometry is the geometry excluding window manager reserved areas -
278 such as task bars and system menus. -
279*/ -
280QRect QScreen::availableGeometry() const -
281{ -
282 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
283 return d->availableGeometry;
executed: return d->availableGeometry;
Execution Count:2514
2514
284} -
285 -
286/*! -
287 Get the screen's virtual siblings. -
288 -
289 The virtual siblings are the screen instances sharing the same virtual desktop. -
290 They share a common coordinate system, and windows can freely be moved or -
291 positioned across them without having to be re-created. -
292*/ -
293QList<QScreen *> QScreen::virtualSiblings() const -
294{ -
295 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
296 QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings();
executed (the execution status of this line is deduced): QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings();
-
297 QList<QScreen *> screens;
executed (the execution status of this line is deduced): QList<QScreen *> screens;
-
298 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;}))
-
299 screens << platformScreen->screen();
executed: screens << platformScreen->screen();
Execution Count:342
342
300 return screens;
executed: return screens;
Execution Count:342
342
301} -
302 -
303/*! -
304 \property QScreen::virtualSize -
305 \brief the pixel size of the virtual desktop to which this screen belongs -
306 -
307 Returns the pixel size of the virtual desktop corresponding to this screen. -
308 -
309 This is the combined size of the virtual siblings' individual geometries. -
310 -
311 \sa virtualSiblings() -
312*/ -
313QSize QScreen::virtualSize() const -
314{ -
315 return virtualGeometry().size();
never executed: return virtualGeometry().size();
0
316} -
317 -
318/*! -
319 \property QScreen::virtualGeometry -
320 \brief the pixel geometry of the virtual desktop to which this screen belongs -
321 -
322 Returns the pixel geometry of the virtual desktop corresponding to this screen. -
323 -
324 This is the union of the virtual siblings' individual geometries. -
325 -
326 \sa virtualSiblings() -
327*/ -
328QRect QScreen::virtualGeometry() const -
329{ -
330 QRect result;
never executed (the execution status of this line is deduced): QRect result;
-
331 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;}))
-
332 result |= screen->geometry();
never executed: result |= screen->geometry();
0
333 return result;
never executed: return result;
0
334} -
335 -
336/*! -
337 \property QScreen::availableVirtualSize -
338 \brief the available size of the virtual desktop to which this screen belongs -
339 -
340 Returns the available pixel size of the virtual desktop corresponding to this screen. -
341 -
342 This is the combined size of the virtual siblings' individual available geometries. -
343 -
344 \sa availableSize(), virtualSiblings() -
345*/ -
346QSize QScreen::availableVirtualSize() const -
347{ -
348 return availableVirtualGeometry().size();
never executed: return availableVirtualGeometry().size();
0
349} -
350 -
351/*! -
352 \property QScreen::availableVirtualGeometry -
353 \brief the available geometry of the virtual desktop to which this screen belongs -
354 -
355 Returns the available geometry of the virtual desktop corresponding to this screen. -
356 -
357 This is the union of the virtual siblings' individual available geometries. -
358 -
359 \sa availableGeometry(), virtualSiblings() -
360*/ -
361QRect QScreen::availableVirtualGeometry() const -
362{ -
363 QRect result;
never executed (the execution status of this line is deduced): QRect result;
-
364 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;}))
-
365 result |= screen->availableGeometry();
never executed: result |= screen->availableGeometry();
0
366 return result;
never executed: return result;
0
367} -
368 -
369/*! -
370 Sets the orientations that the application is interested in receiving -
371 updates for in conjunction with this screen. -
372 -
373 For example, to receive orientation() updates and thus have -
374 orientationChanged() signals being emitted for LandscapeOrientation and -
375 InvertedLandscapeOrientation, call setOrientationUpdateMask() with -
376 \a{mask} set to Qt::LandscapeOrientation | Qt::InvertedLandscapeOrientation. -
377 -
378 The default, 0, means no orientationChanged() signals are fired. -
379*/ -
380void QScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) -
381{ -
382 Q_D(QScreen);
executed (the execution status of this line is deduced): QScreenPrivate * const d = d_func();
-
383 d->orientationUpdateMask = mask;
executed (the execution status of this line is deduced): d->orientationUpdateMask = mask;
-
384 d->platformScreen->setOrientationUpdateMask(mask);
executed (the execution status of this line is deduced): d->platformScreen->setOrientationUpdateMask(mask);
-
385 QGuiApplicationPrivate::updateFilteredScreenOrientation(this);
executed (the execution status of this line is deduced): QGuiApplicationPrivate::updateFilteredScreenOrientation(this);
-
386}
executed: }
Execution Count:3
3
387 -
388/*! -
389 Returns the currently set orientation update mask. -
390 -
391 \sa setOrientationUpdateMask() -
392*/ -
393Qt::ScreenOrientations QScreen::orientationUpdateMask() const -
394{ -
395 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
396 return d->orientationUpdateMask;
executed: return d->orientationUpdateMask;
Execution Count:12
12
397} -
398 -
399/*! -
400 \property QScreen::orientation -
401 \brief the screen orientation -
402 -
403 The screen orientation represents the physical orientation -
404 of the display. For example, the screen orientation of a mobile device -
405 will change based on the device is being held, and a desktop display -
406 might be rotated so that it's in portrait mode. -
407 -
408 Changes to this property will be filtered by orientationUpdateMask(), -
409 so in order to receive orientation updates the application must first -
410 call setOrientationUpdateMask() with a mask of the orientations it wants -
411 to receive. -
412 -
413 Qt::PrimaryOrientation is never returned. -
414 -
415 \sa primaryOrientation() -
416*/ -
417Qt::ScreenOrientation QScreen::orientation() const -
418{ -
419 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
420 return d->filteredOrientation;
executed: return d->filteredOrientation;
Execution Count:24
24
421} -
422 -
423/*! -
424 \property QScreen::refreshRate -
425 \brief the approximate vertical refresh rate of the screen in Hz -
426*/ -
427qreal QScreen::refreshRate() const -
428{ -
429 Q_D(const QScreen);
never executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
430 return d->refreshRate;
never executed: return d->refreshRate;
0
431} -
432 -
433/*! -
434 \property QScreen::primaryOrientation -
435 \brief the primary screen orientation -
436 -
437 The primary screen orientation is Qt::LandscapeOrientation -
438 if the screen geometry's width is greater than or equal to its -
439 height, or Qt::PortraitOrientation otherwise. -
440*/ -
441Qt::ScreenOrientation QScreen::primaryOrientation() const -
442{ -
443 Q_D(const QScreen);
executed (the execution status of this line is deduced): const QScreenPrivate * const d = d_func();
-
444 return d->primaryOrientation;
executed: return d->primaryOrientation;
Execution Count:7
7
445} -
446 -
447// i must be power of two -
448static int log2(uint i) -
449{ -
450 if (i == 0)
partially evaluated: i == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
451 return -1;
never executed: return -1;
0
452 -
453 int result = 0;
executed (the execution status of this line is deduced): int result = 0;
-
454 while (!(i & 1)) {
evaluated: !(i & 1)
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:30
30-45
455 ++result;
executed (the execution status of this line is deduced): ++result;
-
456 i >>= 1;
executed (the execution status of this line is deduced): i >>= 1;
-
457 }
executed: }
Execution Count:45
45
458 return result;
executed: return result;
Execution Count:30
30
459} -
460 -
461/*! -
462 Convenience function to compute the angle of rotation to get from -
463 rotation \a a to rotation \a b. -
464 -
465 The result will be 0, 90, 180, or 270. -
466 -
467 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). -
468*/ -
469int QScreen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) const -
470{ -
471 if (a == Qt::PrimaryOrientation)
evaluated: a == Qt::PrimaryOrientation
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:19
1-19
472 a = primaryOrientation();
executed: a = primaryOrientation();
Execution Count:1
1
473 -
474 if (b == Qt::PrimaryOrientation)
evaluated: b == Qt::PrimaryOrientation
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:19
1-19
475 b = primaryOrientation();
executed: b = primaryOrientation();
Execution Count:1
1
476 -
477 if (a == b)
evaluated: a == b
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:15
5-15
478 return 0;
executed: return 0;
Execution Count:5
5
479 -
480 int ia = log2(uint(a));
executed (the execution status of this line is deduced): int ia = log2(uint(a));
-
481 int ib = log2(uint(b));
executed (the execution status of this line is deduced): int ib = log2(uint(b));
-
482 -
483 int delta = ia - ib;
executed (the execution status of this line is deduced): int delta = ia - ib;
-
484 -
485 if (delta < 0)
evaluated: delta < 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:7
7-8
486 delta = delta + 4;
executed: delta = delta + 4;
Execution Count:8
8
487 -
488 int angles[] = { 0, 90, 180, 270 };
executed (the execution status of this line is deduced): int angles[] = { 0, 90, 180, 270 };
-
489 return angles[delta];
executed: return angles[delta];
Execution Count:15
15
490} -
491 -
492/*! -
493 Convenience function to compute a transform that maps from the coordinate system -
494 defined by orientation \a a into the coordinate system defined by orientation -
495 \a b and target dimensions \a target. -
496 -
497 Example, \a a is Qt::Landscape, \a b is Qt::Portrait, and \a target is QRect(0, 0, w, h) -
498 the resulting transform will be such that the point QPoint(0, 0) is mapped to QPoint(0, w), -
499 and QPoint(h, w) is mapped to QPoint(0, h). Thus, the landscape coordinate system QRect(0, 0, h, w) -
500 is mapped (with a 90 degree rotation) into the portrait coordinate system QRect(0, 0, w, h). -
501 -
502 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). -
503*/ -
504QTransform QScreen::transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target) const -
505{ -
506 if (a == Qt::PrimaryOrientation)
partially evaluated: a == Qt::PrimaryOrientation
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
507 a = primaryOrientation();
never executed: a = primaryOrientation();
0
508 -
509 if (b == Qt::PrimaryOrientation)
evaluated: b == Qt::PrimaryOrientation
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
510 b = primaryOrientation();
executed: b = primaryOrientation();
Execution Count:1
1
511 -
512 if (a == b)
evaluated: a == b
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:5
3-5
513 return QTransform();
executed: return QTransform();
Execution Count:3
3
514 -
515 int angle = angleBetween(a, b);
executed (the execution status of this line is deduced): int angle = angleBetween(a, b);
-
516 -
517 QTransform result;
executed (the execution status of this line is deduced): QTransform result;
-
518 switch (angle) { -
519 case 90: -
520 result.translate(target.width(), 0);
executed (the execution status of this line is deduced): result.translate(target.width(), 0);
-
521 break;
executed: break;
Execution Count:2
2
522 case 180: -
523 result.translate(target.width(), target.height());
executed (the execution status of this line is deduced): result.translate(target.width(), target.height());
-
524 break;
executed: break;
Execution Count:2
2
525 case 270: -
526 result.translate(0, target.height());
executed (the execution status of this line is deduced): result.translate(0, target.height());
-
527 break;
executed: break;
Execution Count:1
1
528 default: -
529 Q_ASSERT(false);
never executed (the execution status of this line is deduced): qt_noop();
-
530 }
never executed: }
0
531 result.rotate(angle);
executed (the execution status of this line is deduced): result.rotate(angle);
-
532 -
533 return result;
executed: return result;
Execution Count:5
5
534} -
535 -
536/*! -
537 Maps the rect between two screen orientations. -
538 -
539 This will flip the x and y dimensions of the rectangle \a{rect} if the orientation \a{a} is -
540 Qt::PortraitOrientation or Qt::InvertedPortraitOrientation and orientation \a{b} is -
541 Qt::LandscapeOrientation or Qt::InvertedLandscapeOrientation, or vice versa. -
542 -
543 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). -
544*/ -
545QRect QScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect) const -
546{ -
547 if (a == Qt::PrimaryOrientation)
never evaluated: a == Qt::PrimaryOrientation
0
548 a = primaryOrientation();
never executed: a = primaryOrientation();
0
549 -
550 if (b == Qt::PrimaryOrientation)
never evaluated: b == Qt::PrimaryOrientation
0
551 b = primaryOrientation();
never executed: b = primaryOrientation();
0
552 -
553 if (a == b)
never evaluated: a == b
0
554 return rect;
never executed: return rect;
0
555 -
556 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
557 != (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
558 { -
559 return QRect(rect.y(), rect.x(), rect.height(), rect.width());
never executed: return QRect(rect.y(), rect.x(), rect.height(), rect.width());
0
560 } -
561 -
562 return rect;
never executed: return rect;
0
563} -
564 -
565/*! -
566 Convenience function that returns true if \a o is either portrait or inverted portrait; -
567 otherwise returns false. -
568 -
569 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). -
570*/ -
571bool QScreen::isPortrait(Qt::ScreenOrientation o) const -
572{ -
573 return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation
never executed: return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
0
574 || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
never executed: return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
0
575} -
576 -
577/*! -
578 Convenience function that returns true if \a o is either landscape or inverted landscape; -
579 otherwise returns false. -
580 -
581 Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). -
582*/ -
583bool QScreen::isLandscape(Qt::ScreenOrientation o) const -
584{ -
585 return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation
never executed: return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
0
586 || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
never executed: return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
0
587} -
588 -
589/*! -
590 \fn void QScreen::orientationChanged(Qt::ScreenOrientation orientation) -
591 -
592 This signal is emitted when the orientation of the screen -
593 changes. -
594 -
595 \sa orientation() -
596*/ -
597 -
598/*! -
599 \fn void QScreen::primaryOrientationChanged(Qt::ScreenOrientation orientation) -
600 -
601 This signal is emitted when the primary orientation of the screen -
602 changes. -
603 -
604 \sa primaryOrientation() -
605*/ -
606 -
607void QScreenPrivate::updatePrimaryOrientation() -
608{ -
609 primaryOrientation = geometry.width() >= geometry.height() ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
partially evaluated: geometry.width() >= geometry.height()
TRUEFALSE
yes
Evaluation Count:276
no
Evaluation Count:0
0-276
610}
executed: }
Execution Count:276
276
611 -
612/*! -
613 Creates and returns a pixmap constructed by grabbing the contents -
614 of the given \a window restricted by QRect(\a x, \a y, \a width, -
615 \a height). -
616 -
617 The arguments (\a{x}, \a{y}) specify the offset in the window, -
618 whereas (\a{width}, \a{height}) specify the area to be copied. If -
619 \a width is negative, the function copies everything to the right -
620 border of the window. If \a height is negative, the function -
621 copies everything to the bottom of the window. -
622 -
623 The window system identifier (\c WId) can be retrieved using the -
624 QWidget::winId() function. The rationale for using a window -
625 identifier and not a QWidget, is to enable grabbing of windows -
626 that are not part of the application, window system frames, and so -
627 on. -
628 -
629 The grabWindow() function grabs pixels from the screen, not from -
630 the window, i.e. if there is another window partially or entirely -
631 over the one you grab, you get pixels from the overlying window, -
632 too. The mouse cursor is generally not grabbed. -
633 -
634 Note on X11 that if the given \a window doesn't have the same depth -
635 as the root window, and another window partially or entirely -
636 obscures the one you grab, you will \e not get pixels from the -
637 overlying window. The contents of the obscured areas in the -
638 pixmap will be undefined and uninitialized. -
639 -
640 On Windows Vista and above grabbing a layered window, which is -
641 created by setting the Qt::WA_TranslucentBackground attribute, will -
642 not work. Instead grabbing the desktop widget should work. -
643 -
644 \warning In general, grabbing an area outside the screen is not -
645 safe. This depends on the underlying window system. -
646*/ -
647 -
648QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height) -
649{ -
650 const QPlatformScreen *platformScreen = handle();
executed (the execution status of this line is deduced): const QPlatformScreen *platformScreen = handle();
-
651 if (!platformScreen) {
partially evaluated: !platformScreen
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
652 qWarning("%s invoked with handle==0", Q_FUNC_INFO);
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qscreen.cpp", 652, __PRETTY_FUNCTION__).warning("%s invoked with handle==0", __PRETTY_FUNCTION__);
-
653 return QPixmap();
never executed: return QPixmap();
0
654 } -
655 return platformScreen->grabWindow(window, x, y, width, height);
executed: return platformScreen->grabWindow(window, x, y, width, height);
Execution Count:1
1
656} -
657 -
658QT_END_NAMESPACE -
659 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial