qplatformscreen.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qplatformscreen.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4QPlatformScreen::QPlatformScreen()-
5 : d_ptr(new QPlatformScreenPrivate)-
6{-
7 QPlatformScreenPrivate * const d = d_func();-
8 d->screen = 0;-
9}
never executed: end of block
0
10-
11QPlatformScreen::~QPlatformScreen()-
12{-
13 QPlatformScreenPrivate * const d = d_func();-
14 if (d->screen
d->screenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
15 QMessageLogger(__FILE__, 64, __PRETTY_FUNCTION__).warning("Manually deleting a QPlatformScreen. Call QPlatformIntegration::destroyScreen instead.");-
16 QGuiApplicationPrivate::platformIntegration()->removeScreen(d->screen);-
17 delete d->screen;-
18 }
never executed: end of block
0
19}
never executed: end of block
0
20QPixmap QPlatformScreen::grabWindow(WId window, int x, int y, int width, int height) const-
21{-
22 (void)window;;-
23 (void)x;;-
24 (void)y;;-
25 (void)width;;-
26 (void)height;;-
27 return
never executed: return QPixmap();
QPixmap();
never executed: return QPixmap();
0
28}-
29-
30-
31-
32-
33-
34-
35-
36QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const-
37{-
38 const QWindowList list = QGuiApplication::topLevelWindows();-
39 for (int i = list.size()-1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; --i) {
0
40 QWindow *w = list[i];-
41 if (w->isVisible()
w->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
&& QHighDpi::toNativePixels(w->geometry(), w).contains(pos)
QHighDpi::toNa....contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
42 return
never executed: return w;
w;
never executed: return w;
0
43 }
never executed: end of block
0
44-
45 return
never executed: return 0;
0;
never executed: return 0;
0
46}-
47-
48-
49-
50-
51-
52-
53const QPlatformScreen *QPlatformScreen::screenForPosition(const QPoint &point) const-
54{-
55 if (!geometry().contains(point)
!geometry().contains(point)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
56 const auto screens = virtualSiblings();-
57 for (const QPlatformScreen *screen : screens) {-
58 if (screen->geometry().contains(point)
screen->geomet...ontains(point)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
59 return
never executed: return screen;
screen;
never executed: return screen;
0
60 }
never executed: end of block
0
61 }
never executed: end of block
0
62 return
never executed: return this;
this;
never executed: return this;
0
63}-
64QList<QPlatformScreen *> QPlatformScreen::virtualSiblings() const-
65{-
66 QList<QPlatformScreen *> list;-
67 list << const_cast<QPlatformScreen *>(this);-
68 return
never executed: return list;
list;
never executed: return list;
0
69}-
70-
71QScreen *QPlatformScreen::screen() const-
72{-
73 const QPlatformScreenPrivate * const d = d_func();-
74 return
never executed: return d->screen;
d->screen;
never executed: return d->screen;
0
75}-
76QSizeF QPlatformScreen::physicalSize() const-
77{-
78 static const int dpi = 100;-
79 return
never executed: return QSizeF(geometry().size()) / dpi * qreal(25.4);
QSizeF(geometry().size()) / dpi * qreal(25.4);
never executed: return QSizeF(geometry().size()) / dpi * qreal(25.4);
0
80}-
81QDpi QPlatformScreen::logicalDpi() const-
82{-
83 QSizeF ps = physicalSize();-
84 QSize s = geometry().size();-
85-
86 return
never executed: return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height());
QDpi(25.4 * s.width() / ps.width(),
never executed: return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height());
0
87 25.4 * s.height() / ps.height());
never executed: return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height());
0
88}-
89qreal QPlatformScreen::devicePixelRatio() const-
90{-
91 return
never executed: return 1.0;
1.0;
never executed: return 1.0;
0
92}-
93qreal QPlatformScreen::pixelDensity() const-
94{-
95 return
never executed: return 1.0;
1.0;
never executed: return 1.0;
0
96}-
97-
98-
99-
100-
101-
102-
103-
104qreal QPlatformScreen::refreshRate() const-
105{-
106 return
never executed: return 60;
60;
never executed: return 60;
0
107}-
108Qt::ScreenOrientation QPlatformScreen::nativeOrientation() const-
109{-
110 return
never executed: return Qt::PrimaryOrientation;
Qt::PrimaryOrientation;
never executed: return Qt::PrimaryOrientation;
0
111}-
112Qt::ScreenOrientation QPlatformScreen::orientation() const-
113{-
114 return
never executed: return Qt::PrimaryOrientation;
Qt::PrimaryOrientation;
never executed: return Qt::PrimaryOrientation;
0
115}-
116void QPlatformScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask)-
117{-
118 (void)mask;;-
119}
never executed: end of block
0
120-
121QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window)-
122{-
123-
124-
125 if (!window->screen()
!window->screen()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
126 return
never executed: return 0;
0;
never executed: return 0;
0
127 return
never executed: return window->screen()->handle();
window->screen()->handle();
never executed: return window->screen()->handle();
0
128}-
129QPlatformCursor *QPlatformScreen::cursor() const-
130{-
131 return
never executed: return 0;
0;
never executed: return 0;
0
132}-
133-
134-
135-
136-
137-
138void QPlatformScreen::resizeMaximizedWindows()-
139{-
140 QList<QWindow*> windows = QGuiApplication::allWindows();-
141-
142-
143 const QRect oldGeometry = screen()->geometry();-
144 const QRect oldAvailableGeometry = screen()->availableGeometry();-
145 const QRect newGeometry = deviceIndependentGeometry();-
146 const QRect newAvailableGeometry = QHighDpi::fromNative(availableGeometry(), QHighDpiScaling::factor(this), newGeometry.topLeft());-
147-
148-
149 for (int i = 0; i < windows.size()
i < windows.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
150 QWindow *w = windows.at(i);-
151-
152-
153 if (!w->handle()
!w->handle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
154 continue;
never executed: continue;
0
155-
156 if (platformScreenForWindow(w) != this
platformScreen...dow(w) != thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
157 continue;
never executed: continue;
0
158-
159 if (w->windowState() & Qt::WindowMaximized
w->windowState...indowMaximizedDescription
TRUEnever evaluated
FALSEnever evaluated
|| w->geometry() == oldAvailableGeometry
w->geometry() ...ilableGeometryDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
160 w->setGeometry(newAvailableGeometry);
never executed: w->setGeometry(newAvailableGeometry);
0
161 else if (w->windowState() & Qt::WindowFullScreen
w->windowState...ndowFullScreenDescription
TRUEnever evaluated
FALSEnever evaluated
|| w->geometry() == oldGeometry
w->geometry() == oldGeometryDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
162 w->setGeometry(newGeometry);
never executed: w->setGeometry(newGeometry);
0
163 }
never executed: end of block
0
164}
never executed: end of block
0
165-
166-
167static int log2(uint i)-
168{-
169 if (i == 0
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
170 return
never executed: return -1;
-1;
never executed: return -1;
0
171-
172 int result = 0;-
173 while (!(i & 1)
!(i & 1)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
174 ++result;-
175 i >>= 1;-
176 }
never executed: end of block
0
177 return
never executed: return result;
result;
never executed: return result;
0
178}-
179-
180int QPlatformScreen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b)-
181{-
182 if (a == Qt::PrimaryOrientation
a == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
|| b == Qt::PrimaryOrientation
b == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
183 QMessageLogger(__FILE__, 376, __PRETTY_FUNCTION__).warning("Use QScreen version of %sBetween() when passing Qt::PrimaryOrientation", "angle");-
184 return
never executed: return 0;
0;
never executed: return 0;
0
185 }-
186-
187 if (a == b
a == bDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
188 return
never executed: return 0;
0;
never executed: return 0;
0
189-
190 int ia = log2(uint(a));-
191 int ib = log2(uint(b));-
192-
193 int delta = ia - ib;-
194-
195 if (delta < 0
delta < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
196 delta = delta + 4;
never executed: delta = delta + 4;
0
197-
198 int angles[] = { 0, 90, 180, 270 };-
199 return
never executed: return angles[delta];
angles[delta];
never executed: return angles[delta];
0
200}-
201-
202QTransform QPlatformScreen::transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target)-
203{-
204 if (a == Qt::PrimaryOrientation
a == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
|| b == Qt::PrimaryOrientation
b == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
205 QMessageLogger(__FILE__, 398, __PRETTY_FUNCTION__).warning("Use QScreen version of %sBetween() when passing Qt::PrimaryOrientation", "transform");-
206 return
never executed: return QTransform();
QTransform();
never executed: return QTransform();
0
207 }-
208-
209 if (a == b
a == bDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
210 return
never executed: return QTransform();
QTransform();
never executed: return QTransform();
0
211-
212 int angle = angleBetween(a, b);-
213-
214 QTransform result;-
215 switch (angle) {-
216 case
never executed: case 90:
90:
never executed: case 90:
0
217 result.translate(target.width(), 0);-
218 break;
never executed: break;
0
219 case
never executed: case 180:
180:
never executed: case 180:
0
220 result.translate(target.width(), target.height());-
221 break;
never executed: break;
0
222 case
never executed: case 270:
270:
never executed: case 270:
0
223 result.translate(0, target.height());-
224 break;
never executed: break;
0
225 default
never executed: default:
:
never executed: default:
0
226 ((!(false)) ? qt_assert("false",__FILE__,419) : qt_noop());-
227 }
never executed: end of block
0
228 result.rotate(angle);-
229-
230 return
never executed: return result;
result;
never executed: return result;
0
231}-
232-
233QRect QPlatformScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect)-
234{-
235 if (a == Qt::PrimaryOrientation
a == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
|| b == Qt::PrimaryOrientation
b == Qt::PrimaryOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
236 QMessageLogger(__FILE__, 429, __PRETTY_FUNCTION__).warning("Use QScreen version of %sBetween() when passing Qt::PrimaryOrientation", "map");-
237 return
never executed: return rect;
rect;
never executed: return rect;
0
238 }-
239-
240 if (a == b
a == bDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
241 return
never executed: return rect;
rect;
never executed: return rect;
0
242-
243 if ((
(a == Qt::Port...itOrientation)Description
TRUEnever evaluated
FALSEnever evaluated
a == Qt::PortraitOrientation
a == Qt::PortraitOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
|| a == Qt::InvertedPortraitOrientation
a == Qt::Inver...aitOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
)
(a == Qt::Port...itOrientation)Description
TRUEnever evaluated
FALSEnever evaluated
0
244 != (b == Qt::PortraitOrientation
b == Qt::PortraitOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
|| b == Qt::InvertedPortraitOrientation
b == Qt::Inver...aitOrientationDescription
TRUEnever evaluated
FALSEnever evaluated
)
(a == Qt::Port...itOrientation)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
245 {-
246 return
never executed: return QRect(rect.y(), rect.x(), rect.height(), rect.width());
QRect(rect.y(), rect.x(), rect.height(), rect.width());
never executed: return QRect(rect.y(), rect.x(), rect.height(), rect.width());
0
247 }-
248-
249 return
never executed: return rect;
rect;
never executed: return rect;
0
250}-
251-
252QRect QPlatformScreen::deviceIndependentGeometry() const-
253{-
254 qreal scaleFactor = QHighDpiScaling::factor(this);-
255 QRect nativeGeometry = geometry();-
256 return
never executed: return QRect(nativeGeometry.topLeft(), QHighDpi::fromNative(nativeGeometry.size(), scaleFactor));
QRect(nativeGeometry.topLeft(), QHighDpi::fromNative(nativeGeometry.size(), scaleFactor));
never executed: return QRect(nativeGeometry.topLeft(), QHighDpi::fromNative(nativeGeometry.size(), scaleFactor));
0
257}-
258QPlatformScreen::SubpixelAntialiasingType QPlatformScreen::subpixelAntialiasingTypeHint() const-
259{-
260 static int type = -1;-
261 if (type == -1
type == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
262 QByteArray env = qgetenv("QT_SUBPIXEL_AA_TYPE");-
263 if (env == "RGB"
env == "RGB"Description
TRUEnever evaluated
FALSEnever evaluated
)
0
264 type = QPlatformScreen::Subpixel_RGB;
never executed: type = QPlatformScreen::Subpixel_RGB;
0
265 else if (env == "BGR"
env == "BGR"Description
TRUEnever evaluated
FALSEnever evaluated
)
0
266 type = QPlatformScreen::Subpixel_BGR;
never executed: type = QPlatformScreen::Subpixel_BGR;
0
267 else if (env == "VRGB"
env == "VRGB"Description
TRUEnever evaluated
FALSEnever evaluated
)
0
268 type = QPlatformScreen::Subpixel_VRGB;
never executed: type = QPlatformScreen::Subpixel_VRGB;
0
269 else if (env == "VBGR"
env == "VBGR"Description
TRUEnever evaluated
FALSEnever evaluated
)
0
270 type = QPlatformScreen::Subpixel_VBGR;
never executed: type = QPlatformScreen::Subpixel_VBGR;
0
271 else-
272 type = QPlatformScreen::Subpixel_None;
never executed: type = QPlatformScreen::Subpixel_None;
0
273 }-
274-
275 return
never executed: return static_cast<QPlatformScreen::SubpixelAntialiasingType>(type);
static_cast<QPlatformScreen::SubpixelAntialiasingType>(type);
never executed: return static_cast<QPlatformScreen::SubpixelAntialiasingType>(type);
0
276}-
277-
278-
279-
280-
281-
282-
283QPlatformScreen::PowerState QPlatformScreen::powerState() const-
284{-
285 return
never executed: return PowerStateOn;
PowerStateOn;
never executed: return PowerStateOn;
0
286}-
287-
288-
289-
290-
291void QPlatformScreen::setPowerState(PowerState state)-
292{-
293 (void)state;;-
294}
never executed: end of block
0
295-
296-
Switch to Source codePreprocessed file

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