Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qplatformscreen.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||
2 | ** | - | ||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
5 | ** | - | ||||||||||||||||||
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||||||||
7 | ** | - | ||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||
16 | ** | - | ||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
25 | ** | - | ||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
29 | ** | - | ||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
31 | ** | - | ||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||
33 | - | |||||||||||||||||||
34 | #include "qplatformscreen.h" | - | ||||||||||||||||||
35 | #include <QtCore/qdebug.h> | - | ||||||||||||||||||
36 | #include <QtGui/qguiapplication.h> | - | ||||||||||||||||||
37 | #include <qpa/qplatformcursor.h> | - | ||||||||||||||||||
38 | #include <QtGui/private/qguiapplication_p.h> | - | ||||||||||||||||||
39 | #include <qpa/qplatformscreen_p.h> | - | ||||||||||||||||||
40 | #include <qpa/qplatformintegration.h> | - | ||||||||||||||||||
41 | #include <QtGui/qscreen.h> | - | ||||||||||||||||||
42 | #include <QtGui/qwindow.h> | - | ||||||||||||||||||
43 | #include <private/qhighdpiscaling_p.h> | - | ||||||||||||||||||
44 | - | |||||||||||||||||||
45 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | QPlatformScreen::QPlatformScreen() | - | ||||||||||||||||||
48 | : d_ptr(new QPlatformScreenPrivate) | - | ||||||||||||||||||
49 | { | - | ||||||||||||||||||
50 | Q_D(QPlatformScreen); | - | ||||||||||||||||||
51 | d->screen = 0; | - | ||||||||||||||||||
52 | } never executed: end of block | 0 | ||||||||||||||||||
53 | - | |||||||||||||||||||
54 | QPlatformScreen::~QPlatformScreen() | - | ||||||||||||||||||
55 | { | - | ||||||||||||||||||
56 | Q_D(QPlatformScreen); | - | ||||||||||||||||||
57 | if (d->screen) {
| 0 | ||||||||||||||||||
58 | qWarning("Manually deleting a QPlatformScreen. Call QPlatformIntegration::destroyScreen instead."); | - | ||||||||||||||||||
59 | QGuiApplicationPrivate::platformIntegration()->removeScreen(d->screen); | - | ||||||||||||||||||
60 | delete d->screen; | - | ||||||||||||||||||
61 | } never executed: end of block | 0 | ||||||||||||||||||
62 | } never executed: end of block | 0 | ||||||||||||||||||
63 | - | |||||||||||||||||||
64 | /*! | - | ||||||||||||||||||
65 | \fn QPixmap QPlatformScreen::grabWindow(WId window, int x, int y, int width, int height) const | - | ||||||||||||||||||
66 | - | |||||||||||||||||||
67 | This function is called when Qt needs to be able to grab the content of a window. | - | ||||||||||||||||||
68 | - | |||||||||||||||||||
69 | Returnes the content of the window specified with the WId handle within the boundaries of | - | ||||||||||||||||||
70 | QRect(x,y,width,height). | - | ||||||||||||||||||
71 | */ | - | ||||||||||||||||||
72 | QPixmap QPlatformScreen::grabWindow(WId window, int x, int y, int width, int height) const | - | ||||||||||||||||||
73 | { | - | ||||||||||||||||||
74 | Q_UNUSED(window); | - | ||||||||||||||||||
75 | Q_UNUSED(x); | - | ||||||||||||||||||
76 | Q_UNUSED(y); | - | ||||||||||||||||||
77 | Q_UNUSED(width); | - | ||||||||||||||||||
78 | Q_UNUSED(height); | - | ||||||||||||||||||
79 | return QPixmap(); never executed: return QPixmap(); | 0 | ||||||||||||||||||
80 | } | - | ||||||||||||||||||
81 | - | |||||||||||||||||||
82 | /*! | - | ||||||||||||||||||
83 | Return the given top level window for a given position. | - | ||||||||||||||||||
84 | - | |||||||||||||||||||
85 | Default implementation retrieves a list of all top level windows and finds the first window | - | ||||||||||||||||||
86 | which contains point \a pos | - | ||||||||||||||||||
87 | */ | - | ||||||||||||||||||
88 | QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const | - | ||||||||||||||||||
89 | { | - | ||||||||||||||||||
90 | QWindowList list = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
91 | for (int i = list.size()-1; i >= 0; --i) {
| 0 | ||||||||||||||||||
92 | QWindow *w = list[i]; | - | ||||||||||||||||||
93 | if (w->isVisible() && QHighDpi::toNativePixels(w->geometry(), w).contains(pos))
| 0 | ||||||||||||||||||
94 | return w; never executed: return w; | 0 | ||||||||||||||||||
95 | } never executed: end of block | 0 | ||||||||||||||||||
96 | - | |||||||||||||||||||
97 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
98 | } | - | ||||||||||||||||||
99 | - | |||||||||||||||||||
100 | /*! | - | ||||||||||||||||||
101 | Find the sibling screen corresponding to \a globalPos. | - | ||||||||||||||||||
102 | - | |||||||||||||||||||
103 | Returns this screen if no suitable screen is found at the position. | - | ||||||||||||||||||
104 | */ | - | ||||||||||||||||||
105 | const QPlatformScreen *QPlatformScreen::screenForPosition(const QPoint &point) const | - | ||||||||||||||||||
106 | { | - | ||||||||||||||||||
107 | if (!geometry().contains(point)) {
| 0 | ||||||||||||||||||
108 | Q_FOREACH (const QPlatformScreen* screen, virtualSiblings()) { | - | ||||||||||||||||||
109 | if (screen->geometry().contains(point))
| 0 | ||||||||||||||||||
110 | return screen; never executed: return screen; | 0 | ||||||||||||||||||
111 | } never executed: end of block | 0 | ||||||||||||||||||
112 | } never executed: end of block | 0 | ||||||||||||||||||
113 | return this; never executed: return this; | 0 | ||||||||||||||||||
114 | } | - | ||||||||||||||||||
115 | - | |||||||||||||||||||
116 | - | |||||||||||||||||||
117 | /*! | - | ||||||||||||||||||
118 | Returns a list of all the platform screens that are part of the same | - | ||||||||||||||||||
119 | virtual desktop. | - | ||||||||||||||||||
120 | - | |||||||||||||||||||
121 | Screens part of the same virtual desktop share a common coordinate system, | - | ||||||||||||||||||
122 | and windows can be freely moved between them. | - | ||||||||||||||||||
123 | */ | - | ||||||||||||||||||
124 | QList<QPlatformScreen *> QPlatformScreen::virtualSiblings() const | - | ||||||||||||||||||
125 | { | - | ||||||||||||||||||
126 | QList<QPlatformScreen *> list; | - | ||||||||||||||||||
127 | list << const_cast<QPlatformScreen *>(this); | - | ||||||||||||||||||
128 | return list; never executed: return list; | 0 | ||||||||||||||||||
129 | } | - | ||||||||||||||||||
130 | - | |||||||||||||||||||
131 | QScreen *QPlatformScreen::screen() const | - | ||||||||||||||||||
132 | { | - | ||||||||||||||||||
133 | Q_D(const QPlatformScreen); | - | ||||||||||||||||||
134 | return d->screen; never executed: return d->screen; | 0 | ||||||||||||||||||
135 | } | - | ||||||||||||||||||
136 | - | |||||||||||||||||||
137 | /*! | - | ||||||||||||||||||
138 | Reimplement this function in subclass to return the physical size of the | - | ||||||||||||||||||
139 | screen, in millimeters. The physical size represents the actual physical | - | ||||||||||||||||||
140 | dimensions of the display. | - | ||||||||||||||||||
141 | - | |||||||||||||||||||
142 | The default implementation takes the pixel size of the screen, considers a | - | ||||||||||||||||||
143 | resolution of 100 dots per inch, and returns the calculated physical size. | - | ||||||||||||||||||
144 | A device with a screen that has different resolutions will need to be | - | ||||||||||||||||||
145 | supported by a suitable reimplementation of this function. | - | ||||||||||||||||||
146 | - | |||||||||||||||||||
147 | \sa logcalDpi | - | ||||||||||||||||||
148 | */ | - | ||||||||||||||||||
149 | QSizeF QPlatformScreen::physicalSize() const | - | ||||||||||||||||||
150 | { | - | ||||||||||||||||||
151 | static const int dpi = 100; | - | ||||||||||||||||||
152 | return QSizeF(geometry().size()) / dpi * qreal(25.4); never executed: return QSizeF(geometry().size()) / dpi * qreal(25.4); | 0 | ||||||||||||||||||
153 | } | - | ||||||||||||||||||
154 | - | |||||||||||||||||||
155 | /*! | - | ||||||||||||||||||
156 | Reimplement this function in subclass to return the logical horizontal | - | ||||||||||||||||||
157 | and vertical dots per inch metrics of the screen. | - | ||||||||||||||||||
158 | - | |||||||||||||||||||
159 | The logical dots per inch metrics are used by QFont to convert point sizes | - | ||||||||||||||||||
160 | to pixel sizes. | - | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | The default implementation uses the screen pixel size and physical size to | - | ||||||||||||||||||
163 | compute the metrics. | - | ||||||||||||||||||
164 | - | |||||||||||||||||||
165 | \sa physicalSize | - | ||||||||||||||||||
166 | */ | - | ||||||||||||||||||
167 | QDpi QPlatformScreen::logicalDpi() const | - | ||||||||||||||||||
168 | { | - | ||||||||||||||||||
169 | QSizeF ps = physicalSize(); | - | ||||||||||||||||||
170 | QSize s = geometry().size(); | - | ||||||||||||||||||
171 | - | |||||||||||||||||||
172 | return QDpi(25.4 * s.width() / ps.width(), never executed: return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height()); | 0 | ||||||||||||||||||
173 | 25.4 * s.height() / ps.height()); never executed: return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height()); | 0 | ||||||||||||||||||
174 | } | - | ||||||||||||||||||
175 | - | |||||||||||||||||||
176 | /*! | - | ||||||||||||||||||
177 | Reimplement this function in subclass to return the device pixel ratio | - | ||||||||||||||||||
178 | for the screen. This is the ratio between physical pixels and the | - | ||||||||||||||||||
179 | device-independent pixels of the windowing system. The default | - | ||||||||||||||||||
180 | implementation returns 1.0. | - | ||||||||||||||||||
181 | - | |||||||||||||||||||
182 | \sa QPlatformWindow::devicePixelRatio() | - | ||||||||||||||||||
183 | \sa QPlatformScreen::pixelDensity() | - | ||||||||||||||||||
184 | */ | - | ||||||||||||||||||
185 | qreal QPlatformScreen::devicePixelRatio() const | - | ||||||||||||||||||
186 | { | - | ||||||||||||||||||
187 | return 1.0; never executed: return 1.0; | 0 | ||||||||||||||||||
188 | } | - | ||||||||||||||||||
189 | - | |||||||||||||||||||
190 | /*! | - | ||||||||||||||||||
191 | Reimplement this function in subclass to return the pixel density of the | - | ||||||||||||||||||
192 | screen. This is the scale factor needed to make a low-dpi application | - | ||||||||||||||||||
193 | usable on this screen. The default implementation returns 1.0. | - | ||||||||||||||||||
194 | - | |||||||||||||||||||
195 | Returning something else than 1.0 from this function causes Qt to | - | ||||||||||||||||||
196 | apply the scale factor to the application's coordinate system. | - | ||||||||||||||||||
197 | This is different from devicePixelRatio, which reports a scale | - | ||||||||||||||||||
198 | factor already applied by the windowing system. A platform plugin | - | ||||||||||||||||||
199 | typically implements one (or none) of these two functions. | - | ||||||||||||||||||
200 | - | |||||||||||||||||||
201 | \sa QPlatformWindow::devicePixelRatio() | - | ||||||||||||||||||
202 | */ | - | ||||||||||||||||||
203 | qreal QPlatformScreen::pixelDensity() const | - | ||||||||||||||||||
204 | { | - | ||||||||||||||||||
205 | return 1.0; never executed: return 1.0; | 0 | ||||||||||||||||||
206 | } | - | ||||||||||||||||||
207 | - | |||||||||||||||||||
208 | /*! | - | ||||||||||||||||||
209 | Reimplement this function in subclass to return the vertical refresh rate | - | ||||||||||||||||||
210 | of the screen, in Hz. | - | ||||||||||||||||||
211 | - | |||||||||||||||||||
212 | The default returns 60, a sensible default for modern displays. | - | ||||||||||||||||||
213 | */ | - | ||||||||||||||||||
214 | qreal QPlatformScreen::refreshRate() const | - | ||||||||||||||||||
215 | { | - | ||||||||||||||||||
216 | return 60; never executed: return 60; | 0 | ||||||||||||||||||
217 | } | - | ||||||||||||||||||
218 | - | |||||||||||||||||||
219 | /*! | - | ||||||||||||||||||
220 | Reimplement this function in subclass to return the native orientation | - | ||||||||||||||||||
221 | of the screen, e.g. the orientation where the logo sticker of the device | - | ||||||||||||||||||
222 | appears the right way up. | - | ||||||||||||||||||
223 | - | |||||||||||||||||||
224 | The default implementation returns Qt::PrimaryOrientation. | - | ||||||||||||||||||
225 | */ | - | ||||||||||||||||||
226 | Qt::ScreenOrientation QPlatformScreen::nativeOrientation() const | - | ||||||||||||||||||
227 | { | - | ||||||||||||||||||
228 | return Qt::PrimaryOrientation; never executed: return Qt::PrimaryOrientation; | 0 | ||||||||||||||||||
229 | } | - | ||||||||||||||||||
230 | - | |||||||||||||||||||
231 | /*! | - | ||||||||||||||||||
232 | Reimplement this function in subclass to return the current orientation | - | ||||||||||||||||||
233 | of the screen, for example based on accelerometer data to determine | - | ||||||||||||||||||
234 | the device orientation. | - | ||||||||||||||||||
235 | - | |||||||||||||||||||
236 | The default implementation returns Qt::PrimaryOrientation. | - | ||||||||||||||||||
237 | */ | - | ||||||||||||||||||
238 | Qt::ScreenOrientation QPlatformScreen::orientation() const | - | ||||||||||||||||||
239 | { | - | ||||||||||||||||||
240 | return Qt::PrimaryOrientation; never executed: return Qt::PrimaryOrientation; | 0 | ||||||||||||||||||
241 | } | - | ||||||||||||||||||
242 | - | |||||||||||||||||||
243 | /* | - | ||||||||||||||||||
244 | Reimplement this function in subclass to filter out unneeded screen | - | ||||||||||||||||||
245 | orientation updates. | - | ||||||||||||||||||
246 | - | |||||||||||||||||||
247 | The orientations will anyway be filtered before QScreen::orientationChanged() | - | ||||||||||||||||||
248 | is emitted, but the mask can be used by the platform plugin for example to | - | ||||||||||||||||||
249 | prevent having to have an accelerometer sensor running all the time, or to | - | ||||||||||||||||||
250 | improve the reported values. As an example of the latter, in case of only | - | ||||||||||||||||||
251 | Landscape | InvertedLandscape being set in the mask, on a platform that gets | - | ||||||||||||||||||
252 | its orientation readings from an accelerometer sensor embedded in a handheld | - | ||||||||||||||||||
253 | device, the platform can report transitions between the two even when the | - | ||||||||||||||||||
254 | device is held in an orientation that's closer to portrait. | - | ||||||||||||||||||
255 | - | |||||||||||||||||||
256 | By default, the orientation update mask is empty, so unless this function | - | ||||||||||||||||||
257 | has been called with a non-empty mask the platform does not need to report | - | ||||||||||||||||||
258 | any orientation updates through | - | ||||||||||||||||||
259 | QWindowSystemInterface::handleScreenOrientationChange(). | - | ||||||||||||||||||
260 | */ | - | ||||||||||||||||||
261 | void QPlatformScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) | - | ||||||||||||||||||
262 | { | - | ||||||||||||||||||
263 | Q_UNUSED(mask); | - | ||||||||||||||||||
264 | } never executed: end of block | 0 | ||||||||||||||||||
265 | - | |||||||||||||||||||
266 | QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window) | - | ||||||||||||||||||
267 | { | - | ||||||||||||||||||
268 | // QTBUG 32681: It can happen during the transition between screens | - | ||||||||||||||||||
269 | // when one screen is disconnected that the window doesn't have a screen. | - | ||||||||||||||||||
270 | if (!window->screen())
| 0 | ||||||||||||||||||
271 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
272 | return window->screen()->handle(); never executed: return window->screen()->handle(); | 0 | ||||||||||||||||||
273 | } | - | ||||||||||||||||||
274 | - | |||||||||||||||||||
275 | /*! | - | ||||||||||||||||||
276 | \class QPlatformScreen | - | ||||||||||||||||||
277 | \since 4.8 | - | ||||||||||||||||||
278 | \internal | - | ||||||||||||||||||
279 | \preliminary | - | ||||||||||||||||||
280 | \ingroup qpa | - | ||||||||||||||||||
281 | - | |||||||||||||||||||
282 | \brief The QPlatformScreen class provides an abstraction for visual displays. | - | ||||||||||||||||||
283 | - | |||||||||||||||||||
284 | Many window systems has support for retrieving information on the attached displays. To be able | - | ||||||||||||||||||
285 | to query the display QPA uses QPlatformScreen. Qt its self is most dependent on the | - | ||||||||||||||||||
286 | physicalSize() function, since this is the function it uses to calculate the dpi to use when | - | ||||||||||||||||||
287 | converting point sizes to pixels sizes. However, this is unfortunate on some systems, as the | - | ||||||||||||||||||
288 | native system fakes its dpi size. | - | ||||||||||||||||||
289 | - | |||||||||||||||||||
290 | QPlatformScreen is also used by the public api QDesktopWidget for information about the desktop. | - | ||||||||||||||||||
291 | */ | - | ||||||||||||||||||
292 | - | |||||||||||||||||||
293 | /*! \fn QRect QPlatformScreen::geometry() const = 0 | - | ||||||||||||||||||
294 | Reimplement in subclass to return the pixel geometry of the screen | - | ||||||||||||||||||
295 | */ | - | ||||||||||||||||||
296 | - | |||||||||||||||||||
297 | /*! \fn QRect QPlatformScreen::availableGeometry() const | - | ||||||||||||||||||
298 | Reimplement in subclass to return the pixel geometry of the available space | - | ||||||||||||||||||
299 | This normally is the desktop screen minus the task manager, global menubar etc. | - | ||||||||||||||||||
300 | */ | - | ||||||||||||||||||
301 | - | |||||||||||||||||||
302 | /*! \fn int QPlatformScreen::depth() const = 0 | - | ||||||||||||||||||
303 | Reimplement in subclass to return current depth of the screen | - | ||||||||||||||||||
304 | */ | - | ||||||||||||||||||
305 | - | |||||||||||||||||||
306 | /*! \fn QImage::Format QPlatformScreen::format() const = 0 | - | ||||||||||||||||||
307 | Reimplement in subclass to return the image format which corresponds to the screen format | - | ||||||||||||||||||
308 | */ | - | ||||||||||||||||||
309 | - | |||||||||||||||||||
310 | /*! | - | ||||||||||||||||||
311 | Reimplement this function in subclass to return the cursor of the screen. | - | ||||||||||||||||||
312 | - | |||||||||||||||||||
313 | The default implementation returns 0. | - | ||||||||||||||||||
314 | */ | - | ||||||||||||||||||
315 | QPlatformCursor *QPlatformScreen::cursor() const | - | ||||||||||||||||||
316 | { | - | ||||||||||||||||||
317 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
318 | } | - | ||||||||||||||||||
319 | - | |||||||||||||||||||
320 | /*! | - | ||||||||||||||||||
321 | Convenience method to resize all the maximized and fullscreen windows | - | ||||||||||||||||||
322 | of this platform screen. | - | ||||||||||||||||||
323 | */ | - | ||||||||||||||||||
324 | void QPlatformScreen::resizeMaximizedWindows() | - | ||||||||||||||||||
325 | { | - | ||||||||||||||||||
326 | QList<QWindow*> windows = QGuiApplication::allWindows(); | - | ||||||||||||||||||
327 | - | |||||||||||||||||||
328 | // 'screen()' still has the old geometry info while 'this' has the new geometry info | - | ||||||||||||||||||
329 | const QRect oldGeometry = screen()->geometry(); | - | ||||||||||||||||||
330 | const QRect oldAvailableGeometry = screen()->availableGeometry(); | - | ||||||||||||||||||
331 | const QRect newGeometry = deviceIndependentGeometry(); | - | ||||||||||||||||||
332 | const QRect newAvailableGeometry = QHighDpi::fromNative(availableGeometry(), QHighDpiScaling::factor(this), newGeometry.topLeft()); | - | ||||||||||||||||||
333 | - | |||||||||||||||||||
334 | // make sure maximized and fullscreen windows are updated | - | ||||||||||||||||||
335 | for (int i = 0; i < windows.size(); ++i) {
| 0 | ||||||||||||||||||
336 | QWindow *w = windows.at(i); | - | ||||||||||||||||||
337 | - | |||||||||||||||||||
338 | // Skip non-platform windows, e.g., offscreen windows. | - | ||||||||||||||||||
339 | if (!w->handle())
| 0 | ||||||||||||||||||
340 | continue; never executed: continue; | 0 | ||||||||||||||||||
341 | - | |||||||||||||||||||
342 | if (platformScreenForWindow(w) != this)
| 0 | ||||||||||||||||||
343 | continue; never executed: continue; | 0 | ||||||||||||||||||
344 | - | |||||||||||||||||||
345 | if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry)
| 0 | ||||||||||||||||||
346 | w->setGeometry(newAvailableGeometry); never executed: w->setGeometry(newAvailableGeometry); | 0 | ||||||||||||||||||
347 | else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry)
| 0 | ||||||||||||||||||
348 | w->setGeometry(newGeometry); never executed: w->setGeometry(newGeometry); | 0 | ||||||||||||||||||
349 | } never executed: end of block | 0 | ||||||||||||||||||
350 | } never executed: end of block | 0 | ||||||||||||||||||
351 | - | |||||||||||||||||||
352 | // i must be power of two | - | ||||||||||||||||||
353 | static int log2(uint i) | - | ||||||||||||||||||
354 | { | - | ||||||||||||||||||
355 | if (i == 0)
| 0 | ||||||||||||||||||
356 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
357 | - | |||||||||||||||||||
358 | int result = 0; | - | ||||||||||||||||||
359 | while (!(i & 1)) {
| 0 | ||||||||||||||||||
360 | ++result; | - | ||||||||||||||||||
361 | i >>= 1; | - | ||||||||||||||||||
362 | } never executed: end of block | 0 | ||||||||||||||||||
363 | return result; never executed: return result; | 0 | ||||||||||||||||||
364 | } | - | ||||||||||||||||||
365 | - | |||||||||||||||||||
366 | int QPlatformScreen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) | - | ||||||||||||||||||
367 | { | - | ||||||||||||||||||
368 | if (a == Qt::PrimaryOrientation || b == Qt::PrimaryOrientation) {
| 0 | ||||||||||||||||||
369 | qWarning("Use QScreen version of %sBetween() when passing Qt::PrimaryOrientation", "angle"); | - | ||||||||||||||||||
370 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
371 | } | - | ||||||||||||||||||
372 | - | |||||||||||||||||||
373 | if (a == b)
| 0 | ||||||||||||||||||
374 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
375 | - | |||||||||||||||||||
376 | int ia = log2(uint(a)); | - | ||||||||||||||||||
377 | int ib = log2(uint(b)); | - | ||||||||||||||||||
378 | - | |||||||||||||||||||
379 | int delta = ia - ib; | - | ||||||||||||||||||
380 | - | |||||||||||||||||||
381 | if (delta < 0)
| 0 | ||||||||||||||||||
382 | delta = delta + 4; never executed: delta = delta + 4; | 0 | ||||||||||||||||||
383 | - | |||||||||||||||||||
384 | int angles[] = { 0, 90, 180, 270 }; | - | ||||||||||||||||||
385 | return angles[delta]; never executed: return angles[delta]; | 0 | ||||||||||||||||||
386 | } | - | ||||||||||||||||||
387 | - | |||||||||||||||||||
388 | QTransform QPlatformScreen::transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target) | - | ||||||||||||||||||
389 | { | - | ||||||||||||||||||
390 | if (a == Qt::PrimaryOrientation || b == Qt::PrimaryOrientation) {
| 0 | ||||||||||||||||||
391 | qWarning("Use QScreen version of %sBetween() when passing Qt::PrimaryOrientation", "transform"); | - | ||||||||||||||||||
392 | return QTransform(); never executed: return QTransform(); | 0 | ||||||||||||||||||
393 | } | - | ||||||||||||||||||
394 | - | |||||||||||||||||||
395 | if (a == b)
| 0 | ||||||||||||||||||
396 | return QTransform(); never executed: return QTransform(); | 0 | ||||||||||||||||||
397 | - | |||||||||||||||||||
398 | int angle = angleBetween(a, b); | - | ||||||||||||||||||
399 | - | |||||||||||||||||||
400 | QTransform result; | - | ||||||||||||||||||
401 | switch (angle) { | - | ||||||||||||||||||
402 | case 90: never executed: case 90: | 0 | ||||||||||||||||||
403 | result.translate(target.width(), 0); | - | ||||||||||||||||||
404 | break; never executed: break; | 0 | ||||||||||||||||||
405 | case 180: never executed: case 180: | 0 | ||||||||||||||||||
406 | result.translate(target.width(), target.height()); | - | ||||||||||||||||||
407 | break; never executed: break; | 0 | ||||||||||||||||||
408 | case 270: never executed: case 270: | 0 | ||||||||||||||||||
409 | result.translate(0, target.height()); | - | ||||||||||||||||||
410 | break; never executed: break; | 0 | ||||||||||||||||||
411 | default: never executed: default: | 0 | ||||||||||||||||||
412 | Q_ASSERT(false); | - | ||||||||||||||||||
413 | } never executed: end of block | 0 | ||||||||||||||||||
414 | result.rotate(angle); | - | ||||||||||||||||||
415 | - | |||||||||||||||||||
416 | return result; never executed: return result; | 0 | ||||||||||||||||||
417 | } | - | ||||||||||||||||||
418 | - | |||||||||||||||||||
419 | QRect QPlatformScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect) | - | ||||||||||||||||||
420 | { | - | ||||||||||||||||||
421 | if (a == Qt::PrimaryOrientation || b == Qt::PrimaryOrientation) {
| 0 | ||||||||||||||||||
422 | qWarning("Use QScreen version of %sBetween() when passing Qt::PrimaryOrientation", "map"); | - | ||||||||||||||||||
423 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
424 | } | - | ||||||||||||||||||
425 | - | |||||||||||||||||||
426 | if (a == b)
| 0 | ||||||||||||||||||
427 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
428 | - | |||||||||||||||||||
429 | if ((a == Qt::PortraitOrientation || a == Qt::InvertedPortraitOrientation)
| 0 | ||||||||||||||||||
430 | != (b == Qt::PortraitOrientation || b == Qt::InvertedPortraitOrientation))
| 0 | ||||||||||||||||||
431 | { | - | ||||||||||||||||||
432 | return QRect(rect.y(), rect.x(), rect.height(), rect.width()); never executed: return QRect(rect.y(), rect.x(), rect.height(), rect.width()); | 0 | ||||||||||||||||||
433 | } | - | ||||||||||||||||||
434 | - | |||||||||||||||||||
435 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
436 | } | - | ||||||||||||||||||
437 | - | |||||||||||||||||||
438 | QRect QPlatformScreen::deviceIndependentGeometry() const | - | ||||||||||||||||||
439 | { | - | ||||||||||||||||||
440 | qreal scaleFactor = QHighDpiScaling::factor(this); | - | ||||||||||||||||||
441 | QRect nativeGeometry = geometry(); | - | ||||||||||||||||||
442 | return QRect(nativeGeometry.topLeft(), QHighDpi::fromNative(nativeGeometry.size(), scaleFactor)); never executed: return QRect(nativeGeometry.topLeft(), QHighDpi::fromNative(nativeGeometry.size(), scaleFactor)); | 0 | ||||||||||||||||||
443 | } | - | ||||||||||||||||||
444 | - | |||||||||||||||||||
445 | /*! | - | ||||||||||||||||||
446 | Returns a hint about this screen's subpixel layout structure. | - | ||||||||||||||||||
447 | - | |||||||||||||||||||
448 | The default implementation queries the \b{QT_SUBPIXEL_AA_TYPE} env variable. | - | ||||||||||||||||||
449 | This is just a hint because most platforms don't have a way to retrieve the correct value from hardware | - | ||||||||||||||||||
450 | and instead rely on font configurations. | - | ||||||||||||||||||
451 | */ | - | ||||||||||||||||||
452 | QPlatformScreen::SubpixelAntialiasingType QPlatformScreen::subpixelAntialiasingTypeHint() const | - | ||||||||||||||||||
453 | { | - | ||||||||||||||||||
454 | static int type = -1; | - | ||||||||||||||||||
455 | if (type == -1) {
| 0 | ||||||||||||||||||
456 | QByteArray env = qgetenv("QT_SUBPIXEL_AA_TYPE"); | - | ||||||||||||||||||
457 | if (env == "RGB")
| 0 | ||||||||||||||||||
458 | type = QPlatformScreen::Subpixel_RGB; never executed: type = QPlatformScreen::Subpixel_RGB; | 0 | ||||||||||||||||||
459 | else if (env == "BGR")
| 0 | ||||||||||||||||||
460 | type = QPlatformScreen::Subpixel_BGR; never executed: type = QPlatformScreen::Subpixel_BGR; | 0 | ||||||||||||||||||
461 | else if (env == "VRGB")
| 0 | ||||||||||||||||||
462 | type = QPlatformScreen::Subpixel_VRGB; never executed: type = QPlatformScreen::Subpixel_VRGB; | 0 | ||||||||||||||||||
463 | else if (env == "VBGR")
| 0 | ||||||||||||||||||
464 | type = QPlatformScreen::Subpixel_VBGR; never executed: type = QPlatformScreen::Subpixel_VBGR; | 0 | ||||||||||||||||||
465 | else | - | ||||||||||||||||||
466 | type = QPlatformScreen::Subpixel_None; never executed: type = QPlatformScreen::Subpixel_None; | 0 | ||||||||||||||||||
467 | } | - | ||||||||||||||||||
468 | - | |||||||||||||||||||
469 | return static_cast<QPlatformScreen::SubpixelAntialiasingType>(type); never executed: return static_cast<QPlatformScreen::SubpixelAntialiasingType>(type); | 0 | ||||||||||||||||||
470 | } | - | ||||||||||||||||||
471 | - | |||||||||||||||||||
472 | /*! | - | ||||||||||||||||||
473 | Returns the current power state. | - | ||||||||||||||||||
474 | - | |||||||||||||||||||
475 | The default implementation always returns PowerStateOn. | - | ||||||||||||||||||
476 | */ | - | ||||||||||||||||||
477 | QPlatformScreen::PowerState QPlatformScreen::powerState() const | - | ||||||||||||||||||
478 | { | - | ||||||||||||||||||
479 | return PowerStateOn; never executed: return PowerStateOn; | 0 | ||||||||||||||||||
480 | } | - | ||||||||||||||||||
481 | - | |||||||||||||||||||
482 | /*! | - | ||||||||||||||||||
483 | Sets the power state for this screen. | - | ||||||||||||||||||
484 | */ | - | ||||||||||||||||||
485 | void QPlatformScreen::setPowerState(PowerState state) | - | ||||||||||||||||||
486 | { | - | ||||||||||||||||||
487 | Q_UNUSED(state); | - | ||||||||||||||||||
488 | } never executed: end of block | 0 | ||||||||||||||||||
489 | - | |||||||||||||||||||
490 | QT_END_NAMESPACE | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |