qscreen.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qscreen.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5QScreen::QScreen(QPlatformScreen *screen)-
6 : QObject(*new QScreenPrivate(), 0)-
7{-
8 QScreenPrivate * const d = d_func();-
9 d->setPlatformScreen(screen);-
10}
never executed: end of block
0
11-
12void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen)-
13{-
14 QScreen * const q = q_func();-
15 platformScreen = screen;-
16 platformScreen->d_func()->screen = q;-
17 orientation = platformScreen->orientation();-
18 geometry = platformScreen->deviceIndependentGeometry();-
19 availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());-
20 logicalDpi = platformScreen->logicalDpi();-
21 refreshRate = platformScreen->refreshRate();-
22-
23 if (refreshRate < 1.0
refreshRate < 1.0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
24 refreshRate = 60.0;
never executed: refreshRate = 60.0;
0
25-
26 updatePrimaryOrientation();-
27-
28 filteredOrientation = orientation;-
29 if (filteredOrientation == Qt::PrimaryOrientation
filteredOrient...aryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
30 filteredOrientation = primaryOrientation;
never executed: filteredOrientation = primaryOrientation;
0
31-
32 updateHighDpi();-
33}
never executed: end of block
0
34-
35-
36-
37-
38-
39QScreen::~QScreen()-
40{-
41 if (!(static_cast<QGuiApplication *>(QCoreApplication::instance()))
!(static_cast<...::instance()))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
42 return;
never executed: return;
0
43-
44-
45-
46 (static_cast<QGuiApplication *>(QCoreApplication::instance()))->screenRemoved(this);-
47-
48 if (QGuiApplication::closingDown()
QGuiApplication::closingDown()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
49 return;
never executed: return;
0
50-
51 QScreen *primaryScreen = QGuiApplication::primaryScreen();-
52 if (this == primaryScreen
this == primaryScreenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
53 return;
never executed: return;
0
54-
55 bool movingFromVirtualSibling = primaryScreen
primaryScreenDescription
TRUEnever evaluated
FALSEnever evaluated
&& primaryScreen->handle()->virtualSiblings().contains(handle())
primaryScreen-...ains(handle())Description
TRUEnever evaluated
FALSEnever evaluated
;
0
56-
57-
58 const auto allWindows = QGuiApplication::allWindows();-
59 for (QWindow *window : allWindows) {-
60 if (!window->isTopLevel()
!window->isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
|| window->screen() != this
window->screen() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
61 continue;
never executed: continue;
0
62-
63 const bool wasVisible = window->isVisible();-
64 window->setScreen(primaryScreen);-
65-
66-
67-
68 if (movingFromVirtualSibling
movingFromVirtualSiblingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
69 window->setVisible(wasVisible);
never executed: window->setVisible(wasVisible);
0
70 }
never executed: end of block
0
71}
never executed: end of block
0
72-
73-
74-
75-
76QPlatformScreen *QScreen::handle() const-
77{-
78 const QScreenPrivate * const d = d_func();-
79 return
never executed: return d->platformScreen;
d->platformScreen;
never executed: return d->platformScreen;
0
80}-
81QString QScreen::name() const-
82{-
83 const QScreenPrivate * const d = d_func();-
84 return
never executed: return d->platformScreen->name();
d->platformScreen->name();
never executed: return d->platformScreen->name();
0
85}-
86-
87-
88-
89-
90-
91int QScreen::depth() const-
92{-
93 const QScreenPrivate * const d = d_func();-
94 return
never executed: return d->platformScreen->depth();
d->platformScreen->depth();
never executed: return d->platformScreen->depth();
0
95}-
96-
97-
98-
99-
100-
101QSize QScreen::size() const-
102{-
103 const QScreenPrivate * const d = d_func();-
104 return
never executed: return d->geometry.size();
d->geometry.size();
never executed: return d->geometry.size();
0
105}-
106qreal QScreen::physicalDotsPerInchX() const-
107{-
108 return
never executed: return size().width() / physicalSize().width() * qreal(25.4);
size().width() / physicalSize().width() * qreal(25.4);
never executed: return size().width() / physicalSize().width() * qreal(25.4);
0
109}-
110qreal QScreen::physicalDotsPerInchY() const-
111{-
112 return
never executed: return size().height() / physicalSize().height() * qreal(25.4);
size().height() / physicalSize().height() * qreal(25.4);
never executed: return size().height() / physicalSize().height() * qreal(25.4);
0
113}-
114qreal QScreen::physicalDotsPerInch() const-
115{-
116 QSize sz = size();-
117 QSizeF psz = physicalSize();-
118 return
never executed: return ((sz.height() / psz.height()) + (sz.width() / psz.width())) * qreal(25.4 * 0.5);
((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
119}-
120qreal QScreen::logicalDotsPerInchX() const-
121{-
122 const QScreenPrivate * const d = d_func();-
123 if (QHighDpiScaling::isActive()
QHighDpiScaling::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
124 return
never executed: return QHighDpiScaling::logicalDpi().first;
QHighDpiScaling::logicalDpi().first;
never executed: return QHighDpiScaling::logicalDpi().first;
0
125 return
never executed: return d->logicalDpi.first;
d->logicalDpi.first;
never executed: return d->logicalDpi.first;
0
126}-
127qreal QScreen::logicalDotsPerInchY() const-
128{-
129 const QScreenPrivate * const d = d_func();-
130 if (QHighDpiScaling::isActive()
QHighDpiScaling::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
131 return
never executed: return QHighDpiScaling::logicalDpi().second;
QHighDpiScaling::logicalDpi().second;
never executed: return QHighDpiScaling::logicalDpi().second;
0
132 return
never executed: return d->logicalDpi.second;
d->logicalDpi.second;
never executed: return d->logicalDpi.second;
0
133}-
134qreal QScreen::logicalDotsPerInch() const-
135{-
136 const QScreenPrivate * const d = d_func();-
137 QDpi dpi = QHighDpiScaling::isActive()
QHighDpiScaling::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
? QHighDpiScaling::logicalDpi() : d->logicalDpi;
0
138 return
never executed: return (dpi.first + dpi.second) * qreal(0.5);
(dpi.first + dpi.second) * qreal(0.5);
never executed: return (dpi.first + dpi.second) * qreal(0.5);
0
139}-
140qreal QScreen::devicePixelRatio() const-
141{-
142 const QScreenPrivate * const d = d_func();-
143 return
never executed: return d->platformScreen->devicePixelRatio() * QHighDpiScaling::factor(this);
d->platformScreen->devicePixelRatio() * QHighDpiScaling::factor(this);
never executed: return d->platformScreen->devicePixelRatio() * QHighDpiScaling::factor(this);
0
144}-
145QSizeF QScreen::physicalSize() const-
146{-
147 const QScreenPrivate * const d = d_func();-
148 return
never executed: return d->platformScreen->physicalSize();
d->platformScreen->physicalSize();
never executed: return d->platformScreen->physicalSize();
0
149}-
150QSize QScreen::availableSize() const-
151{-
152 const QScreenPrivate * const d = d_func();-
153 return
never executed: return d->availableGeometry.size();
d->availableGeometry.size();
never executed: return d->availableGeometry.size();
0
154}-
155QRect QScreen::geometry() const-
156{-
157 const QScreenPrivate * const d = d_func();-
158 return
never executed: return d->geometry;
d->geometry;
never executed: return d->geometry;
0
159}-
160QRect QScreen::availableGeometry() const-
161{-
162 const QScreenPrivate * const d = d_func();-
163 return
never executed: return d->availableGeometry;
d->availableGeometry;
never executed: return d->availableGeometry;
0
164}-
165QList<QScreen *> QScreen::virtualSiblings() const-
166{-
167 const QScreenPrivate * const d = d_func();-
168 const QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings();-
169 QList<QScreen *> screens;-
170 screens.reserve(platformScreens.count());-
171 for (QPlatformScreen *platformScreen : platformScreens)-
172 screens << platformScreen->screen();
never executed: screens << platformScreen->screen();
0
173 return
never executed: return screens;
screens;
never executed: return screens;
0
174}-
175QSize QScreen::virtualSize() const-
176{-
177 return
never executed: return virtualGeometry().size();
virtualGeometry().size();
never executed: return virtualGeometry().size();
0
178}-
179QRect QScreen::virtualGeometry() const-
180{-
181 QRect result;-
182 const auto screens = virtualSiblings();-
183 for (QScreen *screen : screens)-
184 result |= screen->geometry();
never executed: result |= screen->geometry();
0
185 return
never executed: return result;
result;
never executed: return result;
0
186}-
187QSize QScreen::availableVirtualSize() const-
188{-
189 return
never executed: return availableVirtualGeometry().size();
availableVirtualGeometry().size();
never executed: return availableVirtualGeometry().size();
0
190}-
191QRect QScreen::availableVirtualGeometry() const-
192{-
193 QRect result;-
194 const auto screens = virtualSiblings();-
195 for (QScreen *screen : screens)-
196 result |= screen->availableGeometry();
never executed: result |= screen->availableGeometry();
0
197 return
never executed: return result;
result;
never executed: return result;
0
198}-
199void QScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask)-
200{-
201 QScreenPrivate * const d = d_func();-
202 d->orientationUpdateMask = mask;-
203 d->platformScreen->setOrientationUpdateMask(mask);-
204 QGuiApplicationPrivate::updateFilteredScreenOrientation(this);-
205}
never executed: end of block
0
206-
207-
208-
209-
210-
211-
212Qt::ScreenOrientations QScreen::orientationUpdateMask() const-
213{-
214 const QScreenPrivate * const d = d_func();-
215 return
never executed: return d->orientationUpdateMask;
d->orientationUpdateMask;
never executed: return d->orientationUpdateMask;
0
216}-
217Qt::ScreenOrientation QScreen::orientation() const-
218{-
219 const QScreenPrivate * const d = d_func();-
220 return
never executed: return d->filteredOrientation;
d->filteredOrientation;
never executed: return d->filteredOrientation;
0
221}-
222-
223-
224-
225-
226-
227qreal QScreen::refreshRate() const-
228{-
229 const QScreenPrivate * const d = d_func();-
230 return
never executed: return d->refreshRate;
d->refreshRate;
never executed: return d->refreshRate;
0
231}-
232Qt::ScreenOrientation QScreen::primaryOrientation() const-
233{-
234 const QScreenPrivate * const d = d_func();-
235 return
never executed: return d->primaryOrientation;
d->primaryOrientation;
never executed: return d->primaryOrientation;
0
236}-
237Qt::ScreenOrientation QScreen::nativeOrientation() const-
238{-
239 const QScreenPrivate * const d = d_func();-
240 return
never executed: return d->platformScreen->nativeOrientation();
d->platformScreen->nativeOrientation();
never executed: return d->platformScreen->nativeOrientation();
0
241}-
242int QScreen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) const-
243{-
244 if (a == Qt::PrimaryOrientation
a == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
245 a = primaryOrientation();
never executed: a = primaryOrientation();
0
246-
247 if (b == Qt::PrimaryOrientation
b == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
248 b = primaryOrientation();
never executed: b = primaryOrientation();
0
249-
250 return
never executed: return QPlatformScreen::angleBetween(a, b);
QPlatformScreen::angleBetween(a, b);
never executed: return QPlatformScreen::angleBetween(a, b);
0
251}-
252QTransform QScreen::transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target) const-
253{-
254 if (a == Qt::PrimaryOrientation
a == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
255 a = primaryOrientation();
never executed: a = primaryOrientation();
0
256-
257 if (b == Qt::PrimaryOrientation
b == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
258 b = primaryOrientation();
never executed: b = primaryOrientation();
0
259-
260 return
never executed: return QPlatformScreen::transformBetween(a, b, target);
QPlatformScreen::transformBetween(a, b, target);
never executed: return QPlatformScreen::transformBetween(a, b, target);
0
261}-
262QRect QScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect) const-
263{-
264 if (a == Qt::PrimaryOrientation
a == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
265 a = primaryOrientation();
never executed: a = primaryOrientation();
0
266-
267 if (b == Qt::PrimaryOrientation
b == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
268 b = primaryOrientation();
never executed: b = primaryOrientation();
0
269-
270 return
never executed: return QPlatformScreen::mapBetween(a, b, rect);
QPlatformScreen::mapBetween(a, b, rect);
never executed: return QPlatformScreen::mapBetween(a, b, rect);
0
271}-
272-
273-
274-
275-
276-
277-
278-
279bool QScreen::isPortrait(Qt::ScreenOrientation o) const-
280{-
281 return
never executed: return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation
never executed: return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
0
282 || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
never executed: return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
0
283}-
284-
285-
286-
287-
288-
289-
290-
291bool QScreen::isLandscape(Qt::ScreenOrientation o) const-
292{-
293 return
never executed: return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation
never executed: return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
0
294 || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
never executed: return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
0
295}-
296void QScreenPrivate::updatePrimaryOrientation()-
297{-
298 primaryOrientation = geometry.width() >= geometry.height()
geometry.width...metry.height()Description
TRUEnever evaluated
FALSEnever evaluated
? Qt::LandscapeOrientation : Qt::PortraitOrientation;
0
299}
never executed: end of block
0
300QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height)-
301{-
302 const QPlatformScreen *platformScreen = handle();-
303 if (!platformScreen
!platformScreenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
304 QMessageLogger(__FILE__, 693, __PRETTY_FUNCTION__).warning("invoked with handle==0");-
305 return
never executed: return QPixmap();
QPixmap();
never executed: return QPixmap();
0
306 }-
307 const qreal factor = QHighDpiScaling::factor(this);-
308 if (qFuzzyCompare(factor, 1)
qFuzzyCompare(factor, 1)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
309 return
never executed: return platformScreen->grabWindow(window, x, y, width, height);
platformScreen->grabWindow(window, x, y, width, height);
never executed: return platformScreen->grabWindow(window, x, y, width, height);
0
310-
311 const QPoint nativePos = QHighDpi::toNative(QPoint(x, y), factor);-
312 QSize nativeSize(width, height);-
313 if (nativeSize.isValid()
nativeSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
314 nativeSize = QHighDpi::toNative(nativeSize, factor);
never executed: nativeSize = QHighDpi::toNative(nativeSize, factor);
0
315 QPixmap result =-
316 platformScreen->grabWindow(window, nativePos.x(), nativePos.y(),-
317 nativeSize.width(), nativeSize.height());-
318 result.setDevicePixelRatio(factor);-
319 return
never executed: return result;
result;
never executed: return result;
0
320}-
321-
322-
323-
324static inline void formatRect(QDebug &debug, const QRect r)-
325{-
326 debug << r.width() << 'x' << r.height()-
327 << forcesign << r.x() << r.y() << noforcesign;-
328}
never executed: end of block
0
329-
330__attribute__((visibility("default"))) QDebug operator<<(QDebug debug, const QScreen *screen)-
331{-
332 const QDebugStateSaver saver(debug);-
333 debug.nospace();-
334 debug << "QScreen(" << (const void *)screen;-
335 if (screen
screenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
336 debug << ", name=" << screen->name();-
337 if (debug.verbosity() > 2
debug.verbosity() > 2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
338 if (screen == QGuiApplication::primaryScreen()
screen == QGui...rimaryScreen()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
339 debug << ", primary";
never executed: debug << ", primary";
0
340 debug << ", geometry=";-
341 formatRect(debug, screen->geometry());-
342 debug << ", available=";-
343 formatRect(debug, screen->availableGeometry());-
344 debug << ", logical DPI=" << screen->logicalDotsPerInchX()-
345 << ',' << screen->logicalDotsPerInchY()-
346 << ", physical DPI=" << screen->physicalDotsPerInchX()-
347 << ',' << screen->physicalDotsPerInchY()-
348 << ", devicePixelRatio=" << screen->devicePixelRatio()-
349 << ", orientation=" << screen->orientation()-
350 << ", physical size=" << screen->physicalSize().width()-
351 << 'x' << screen->physicalSize().height() << "mm";-
352 }
never executed: end of block
0
353 }
never executed: end of block
0
354 debug << ')';-
355 return
never executed: return debug;
debug;
never executed: return debug;
0
356}-
357-
358-
359-
Switch to Source codePreprocessed file

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