qplatformwindow.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qplatformwindow.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10QPlatformWindow::QPlatformWindow(QWindow *window)-
11 : QPlatformSurface(window)-
12 , d_ptr(new QPlatformWindowPrivate)-
13{-
14 QPlatformWindowPrivate * const d = d_func();-
15 d->rect = window->geometry();-
16}
never executed: end of block
0
17-
18-
19-
20-
21QPlatformWindow::~QPlatformWindow()-
22{-
23}-
24-
25-
26-
27-
28QWindow *QPlatformWindow::window() const-
29{-
30 return
never executed: return static_cast<QWindow *>(m_surface);
static_cast<QWindow *>(m_surface);
never executed: return static_cast<QWindow *>(m_surface);
0
31}-
32-
33-
34-
35-
36QPlatformWindow *QPlatformWindow::parent() const-
37{-
38 return
never executed: return window()->parent() ? window()->parent()->handle() : 0;
window()->parent() ? window()->parent()->handle() : 0;
never executed: return window()->parent() ? window()->parent()->handle() : 0;
0
39}-
40-
41-
42-
43-
44-
45QPlatformScreen *QPlatformWindow::screen() const-
46{-
47 QScreen *scr = window()->screen();-
48 return
never executed: return scr ? scr->handle() : nullptr;
scr ? scr->handle() : nullptr;
never executed: return scr ? scr->handle() : nullptr;
0
49}-
50-
51-
52-
53-
54QSurfaceFormat QPlatformWindow::format() const-
55{-
56 return
never executed: return QSurfaceFormat();
QSurfaceFormat();
never executed: return QSurfaceFormat();
0
57}-
58void QPlatformWindow::setGeometry(const QRect &rect)-
59{-
60 QPlatformWindowPrivate * const d = d_func();-
61 d->rect = rect;-
62}
never executed: end of block
0
63-
64-
65-
66-
67QRect QPlatformWindow::geometry() const-
68{-
69 const QPlatformWindowPrivate * const d = d_func();-
70 return
never executed: return d->rect;
d->rect;
never executed: return d->rect;
0
71}-
72QRect QPlatformWindow::normalGeometry() const-
73{-
74 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
75}-
76-
77QMargins QPlatformWindow::frameMargins() const-
78{-
79 return
never executed: return QMargins();
QMargins();
never executed: return QMargins();
0
80}-
81-
82-
83-
84-
85-
86-
87-
88void QPlatformWindow::setVisible(bool visible)-
89{-
90 (void)visible;;-
91 QRect rect(QPoint(), geometry().size());-
92 QWindowSystemInterface::handleExposeEvent(window(), rect);-
93 QWindowSystemInterface::flushWindowSystemEvents();-
94}
never executed: end of block
0
95-
96-
97-
98-
99-
100void QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)-
101{-
102 (void)flags;;-
103}
never executed: end of block
0
104-
105-
106-
107-
108-
109-
110-
111bool QPlatformWindow::isExposed() const-
112{-
113 return
never executed: return window()->isVisible();
window()->isVisible();
never executed: return window()->isVisible();
0
114}-
115-
116-
117-
118-
119-
120-
121-
122bool QPlatformWindow::isActive() const-
123{-
124 return
never executed: return false;
false;
never executed: return false;
0
125}-
126bool QPlatformWindow::isEmbedded(const QPlatformWindow *parentWindow) const-
127{-
128 (void)parentWindow;;-
129 return
never executed: return false;
false;
never executed: return false;
0
130}-
131QPoint QPlatformWindow::mapToGlobal(const QPoint &pos) const-
132{-
133 const QPlatformWindow *p = this;-
134 QPoint result = pos;-
135 while (p
pDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
136 result += p->geometry().topLeft();-
137 p = p->parent();-
138 }
never executed: end of block
0
139 return
never executed: return result;
result;
never executed: return result;
0
140}-
141QPoint QPlatformWindow::mapFromGlobal(const QPoint &pos) const-
142{-
143 const QPlatformWindow *p = this;-
144 QPoint result = pos;-
145 while (p
pDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
146 result -= p->geometry().topLeft();-
147 p = p->parent();-
148 }
never executed: end of block
0
149 return
never executed: return result;
result;
never executed: return result;
0
150}-
151-
152-
153-
154-
155-
156-
157-
158void QPlatformWindow::setWindowState(Qt::WindowState)-
159{-
160}-
161-
162-
163-
164-
165WId QPlatformWindow::winId() const-
166{-
167-
168-
169-
170-
171 return
never executed: return WId(1);
WId(1);
never executed: return WId(1);
0
172}-
173void QPlatformWindow::setParent(const QPlatformWindow *parent)-
174{-
175 (void)parent;;-
176 QMessageLogger(__FILE__, 275, __PRETTY_FUNCTION__).warning("This plugin does not support setParent!");-
177}
never executed: end of block
0
178void QPlatformWindow::setWindowTitle(const QString &title) { (void)title;; }
never executed: end of block
0
179-
180-
181-
182-
183void QPlatformWindow::setWindowFilePath(const QString &filePath) { (void)filePath;; }
never executed: end of block
0
184-
185-
186-
187-
188void QPlatformWindow::setWindowIcon(const QIcon &icon) { (void)icon;; }
never executed: end of block
0
189-
190-
191-
192-
193void QPlatformWindow::raise() { QMessageLogger(__FILE__, 301, __PRETTY_FUNCTION__).warning("This plugin does not support raise()"); }
never executed: end of block
0
194-
195-
196-
197-
198void QPlatformWindow::lower() { QMessageLogger(__FILE__, 306, __PRETTY_FUNCTION__).warning("This plugin does not support lower()"); }
never executed: end of block
0
199-
200-
201-
202-
203-
204-
205-
206void QPlatformWindow::propagateSizeHints() {QMessageLogger(__FILE__, 314, __PRETTY_FUNCTION__).warning("This plugin does not support propagateSizeHints()"); }
never executed: end of block
0
207-
208-
209-
210-
211void QPlatformWindow::setOpacity(qreal level)-
212{-
213 (void)level;;-
214 QMessageLogger(__FILE__, 322, __PRETTY_FUNCTION__).warning("This plugin does not support setting window opacity");-
215}
never executed: end of block
0
216-
217-
218-
219-
220-
221void QPlatformWindow::setMask(const QRegion &region)-
222{-
223 (void)region;;-
224 QMessageLogger(__FILE__, 332, __PRETTY_FUNCTION__).warning("This plugin does not support setting window masks");-
225}
never executed: end of block
0
226void QPlatformWindow::requestActivateWindow()-
227{-
228 QWindowSystemInterface::handleWindowActivated(window());-
229}
never executed: end of block
0
230void QPlatformWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)-
231{-
232 (void)orientation;;-
233}
never executed: end of block
0
234qreal QPlatformWindow::devicePixelRatio() const-
235{-
236 return
never executed: return 1.0;
1.0;
never executed: return 1.0;
0
237}-
238-
239bool QPlatformWindow::setKeyboardGrabEnabled(bool grab)-
240{-
241 (void)grab;;-
242 QMessageLogger(__FILE__, 382, __PRETTY_FUNCTION__).warning("This plugin does not support grabbing the keyboard");-
243 return
never executed: return false;
false;
never executed: return false;
0
244}-
245-
246bool QPlatformWindow::setMouseGrabEnabled(bool grab)-
247{-
248 (void)grab;;-
249 QMessageLogger(__FILE__, 389, __PRETTY_FUNCTION__).warning("This plugin does not support grabbing the mouse");-
250 return
never executed: return false;
false;
never executed: return false;
0
251}-
252-
253-
254-
255-
256-
257-
258bool QPlatformWindow::setWindowModified(bool modified)-
259{-
260 (void)modified;;-
261 return
never executed: return false;
false;
never executed: return false;
0
262}-
263void QPlatformWindow::windowEvent(QEvent *event)-
264{-
265 (void)event;;-
266}
never executed: end of block
0
267bool QPlatformWindow::startSystemResize(const QPoint &pos, Qt::Corner corner)-
268{-
269 (void)pos;-
270 (void)corner;-
271 return
never executed: return false;
false;
never executed: return false;
0
272}-
273void QPlatformWindow::setFrameStrutEventsEnabled(bool enabled)-
274{-
275 (void)enabled;-
276}
never executed: end of block
0
277-
278-
279-
280-
281-
282-
283bool QPlatformWindow::frameStrutEventsEnabled() const-
284{-
285 return
never executed: return false;
false;
never executed: return false;
0
286}-
287QString QPlatformWindow::formatWindowTitle(const QString &title, const QString &separator)-
288{-
289 QString fullTitle = title;-
290 if (QGuiApplicationPrivate::displayName
QGuiApplicatio...e::displayNameDescription
TRUEnever evaluated
FALSEnever evaluated
&& !title.endsWith(*QGuiApplicationPrivate::displayName)
!title.endsWit...::displayName)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
291-
292 if (!fullTitle.isEmpty()
!fullTitle.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
293 fullTitle += separator;
never executed: fullTitle += separator;
0
294 fullTitle += *QGuiApplicationPrivate::displayName;-
295 }
never executed: end of block
else if (fullTitle.isEmpty()
fullTitle.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
296-
297 fullTitle = QCoreApplication::applicationName();-
298 }
never executed: end of block
0
299 return
never executed: return fullTitle;
fullTitle;
never executed: return fullTitle;
0
300}-
301QPlatformScreen *QPlatformWindow::screenForGeometry(const QRect &newGeometry) const-
302{-
303 QPlatformScreen *currentScreen = screen();-
304 QPlatformScreen *fallback = currentScreen;-
305-
306-
307 QPoint center = newGeometry.isEmpty()
newGeometry.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
? newGeometry.topLeft() : newGeometry.center();
0
308 if (window()->type() == Qt::ForeignWindow
window()->type...:ForeignWindowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
309 center = mapToGlobal(center - newGeometry.topLeft());
never executed: center = mapToGlobal(center - newGeometry.topLeft());
0
310-
311 if (!parent()
!parent()Description
TRUEnever evaluated
FALSEnever evaluated
&& currentScreen
currentScreenDescription
TRUEnever evaluated
FALSEnever evaluated
&& !currentScreen->geometry().contains(center)
!currentScreen...ntains(center)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
312 const auto screens = currentScreen->virtualSiblings();-
313 for (QPlatformScreen *screen : screens) {-
314 const QRect screenGeometry = screen->geometry();-
315 if (screenGeometry.contains(center)
screenGeometry...ntains(center)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
316 return
never executed: return screen;
screen;
never executed: return screen;
0
317 if (screenGeometry.intersects(newGeometry)
screenGeometry...s(newGeometry)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
318 fallback = screen;
never executed: fallback = screen;
0
319 }
never executed: end of block
0
320 }
never executed: end of block
0
321 return
never executed: return fallback;
fallback;
never executed: return fallback;
0
322}-
323-
324-
325-
326-
327QSize QPlatformWindow::constrainWindowSize(const QSize &size)-
328{-
329 return
never executed: return size.expandedTo(QSize(0, 0)).boundedTo(QSize(((1<<24)-1), ((1<<24)-1)));
size.expandedTo(QSize(0, 0)).boundedTo(QSize(((1<<24)-1), ((1<<24)-1)));
never executed: return size.expandedTo(QSize(0, 0)).boundedTo(QSize(((1<<24)-1), ((1<<24)-1)));
0
330}-
331void QPlatformWindow::setAlertState(bool enable)-
332{-
333 (void)enable;-
334}
never executed: end of block
0
335bool QPlatformWindow::isAlertState() const-
336{-
337 return
never executed: return false;
false;
never executed: return false;
0
338}-
339-
340-
341-
342-
343-
344static inline const QScreen *effectiveScreen(const QWindow *window)-
345{-
346 if (!window
!windowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
347 return
never executed: return QGuiApplication::primaryScreen();
QGuiApplication::primaryScreen();
never executed: return QGuiApplication::primaryScreen();
0
348 const QScreen *screen = window->screen();-
349 if (!screen
!screenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
350 return
never executed: return QGuiApplication::primaryScreen();
QGuiApplication::primaryScreen();
never executed: return QGuiApplication::primaryScreen();
0
351-
352 const QList<QScreen *> siblings = screen->virtualSiblings();-
353 if (siblings.size() > 1
siblings.size() > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
354 const QPoint referencePoint = window->transientParent()
window->transientParent()Description
TRUEnever evaluated
FALSEnever evaluated
? window->transientParent()->geometry().center() : QCursor::pos();
0
355 for (const QScreen *sibling : siblings) {-
356 if (sibling->geometry().contains(referencePoint)
sibling->geome...eferencePoint)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
357 return
never executed: return sibling;
sibling;
never executed: return sibling;
0
358 }
never executed: end of block
0
359 }
never executed: end of block
0
360-
361 return
never executed: return screen;
screen;
never executed: return screen;
0
362}-
363void QPlatformWindow::invalidateSurface()-
364{-
365}-
366-
367static QSize fixInitialSize(QSize size, const QWindow *w,-
368 int defaultWidth, int defaultHeight)-
369{-
370 if (size.width() == 0
size.width() == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
371 const int minWidth = w->minimumWidth();-
372 size.setWidth(minWidth > 0 ? minWidth : defaultWidth);-
373 }
never executed: end of block
0
374 if (size.height() == 0
size.height() == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
375 const int minHeight = w->minimumHeight();-
376 size.setHeight(minHeight > 0 ? minHeight : defaultHeight);-
377 }
never executed: end of block
0
378 return
never executed: return size;
size;
never executed: return size;
0
379}-
380QRect QPlatformWindow::initialGeometry(const QWindow *w,-
381 const QRect &initialGeometry, int defaultWidth, int defaultHeight)-
382{-
383 if (!w->isTopLevel()
!w->isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
384 const qreal factor = QHighDpiScaling::factor(w);-
385 const QSize size = fixInitialSize(QHighDpi::fromNative(initialGeometry.size(), factor),-
386 w, defaultWidth, defaultHeight);-
387 return
never executed: return QRect(initialGeometry.topLeft(), QHighDpi::toNative(size, factor));
QRect(initialGeometry.topLeft(), QHighDpi::toNative(size, factor));
never executed: return QRect(initialGeometry.topLeft(), QHighDpi::toNative(size, factor));
0
388 }-
389 const QScreen *screen = effectiveScreen(w);-
390 if (!screen
!screenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
391 return
never executed: return initialGeometry;
initialGeometry;
never executed: return initialGeometry;
0
392 QRect rect(QHighDpi::fromNativePixels(initialGeometry, w));-
393 rect.setSize(fixInitialSize(rect.size(), w, defaultWidth, defaultHeight));-
394 if (qt_window_private(const_cast<QWindow*>(w))->positionAutomatic
qt_window_priv...itionAutomaticDescription
TRUEnever evaluated
FALSEnever evaluated
0
395 && w->type() != Qt::Popup
w->type() != Qt::PopupDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
396 const QRect availableGeometry = screen->availableGeometry();-
397-
398 if (rect.height() < (availableGeometry.height() * 8) / 9
rect.height() ...ght() * 8) / 9Description
TRUEnever evaluated
FALSEnever evaluated
0
399 && rect.width() < (availableGeometry.width() * 8) / 9
rect.width() <...dth() * 8) / 9Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
400 const QWindow *tp = w->transientParent();-
401 if (tp
tpDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
402-
403 rect.moveCenter(tp->geometry().center());-
404 }
never executed: end of block
else {
0
405-
406-
407 rect.moveCenter(availableGeometry.center());-
408 }
never executed: end of block
0
409 }-
410 }
never executed: end of block
0
411 return
never executed: return QHighDpi::toNativePixels(rect, screen);
QHighDpi::toNativePixels(rect, screen);
never executed: return QHighDpi::toNativePixels(rect, screen);
0
412}-
413void QPlatformWindow::requestUpdate()-
414{-
415 static int timeout = -1;-
416 if (timeout == -1
timeout == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
417 bool ok = false;-
418 timeout = qEnvironmentVariableIntValue("QT_QPA_UPDATE_IDLE_TIME", &ok);-
419 if (!ok
!okDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
420 timeout = 5;
never executed: timeout = 5;
0
421 }
never executed: end of block
0
422-
423 QWindow *w = window();-
424 QWindowPrivate *wp = (QWindowPrivate *) QObjectPrivate::get(w);-
425 ((!(wp->updateTimer == 0)) ? qt_assert("wp->updateTimer == 0",__FILE__,667) : qt_noop());-
426 wp->updateTimer = w->startTimer(timeout, Qt::PreciseTimer);-
427}
never executed: end of block
0
428-
429-
430-
431-
432QSize QPlatformWindow::windowMinimumSize() const-
433{-
434 return
never executed: return constrainWindowSize(QHighDpi::toNativePixels(window()->minimumSize(), window()));
constrainWindowSize(QHighDpi::toNativePixels(window()->minimumSize(), window()));
never executed: return constrainWindowSize(QHighDpi::toNativePixels(window()->minimumSize(), window()));
0
435}-
436-
437-
438-
439-
440QSize QPlatformWindow::windowMaximumSize() const-
441{-
442 return
never executed: return constrainWindowSize(QHighDpi::toNativePixels(window()->maximumSize(), window()));
constrainWindowSize(QHighDpi::toNativePixels(window()->maximumSize(), window()));
never executed: return constrainWindowSize(QHighDpi::toNativePixels(window()->maximumSize(), window()));
0
443}-
444-
445-
446-
447-
448QSize QPlatformWindow::windowBaseSize() const-
449{-
450 return
never executed: return QHighDpi::toNativePixels(window()->baseSize(), window());
QHighDpi::toNativePixels(window()->baseSize(), window());
never executed: return QHighDpi::toNativePixels(window()->baseSize(), window());
0
451}-
452-
453-
454-
455-
456QSize QPlatformWindow::windowSizeIncrement() const-
457{-
458 QSize increment = window()->sizeIncrement();-
459 if (!QHighDpiScaling::isActive()
!QHighDpiScaling::isActive()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
460 return
never executed: return increment;
increment;
never executed: return increment;
0
461-
462-
463-
464 if (increment.isEmpty()
increment.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
465 increment = QSize(1, 1);
never executed: increment = QSize(1, 1);
0
466-
467 return
never executed: return QHighDpi::toNativePixels(increment, window());
QHighDpi::toNativePixels(increment, window());
never executed: return QHighDpi::toNativePixels(increment, window());
0
468}-
469-
470-
471-
472-
473QRect QPlatformWindow::windowGeometry() const-
474{-
475 return
never executed: return QHighDpi::toNativePixels(window()->geometry(), window());
QHighDpi::toNativePixels(window()->geometry(), window());
never executed: return QHighDpi::toNativePixels(window()->geometry(), window());
0
476}-
477-
478-
479-
480-
481QRect QPlatformWindow::windowFrameGeometry() const-
482{-
483 return
never executed: return QHighDpi::toNativePixels(window()->frameGeometry(), window());
QHighDpi::toNativePixels(window()->frameGeometry(), window());
never executed: return QHighDpi::toNativePixels(window()->frameGeometry(), window());
0
484}-
485-
486-
487-
488-
489-
490-
491-
492QRectF QPlatformWindow::closestAcceptableGeometry(const QWindow *qWindow, const QRectF &nativeRect)-
493{-
494 const QRectF rectF = QHighDpi::fromNativePixels(nativeRect, qWindow);-
495 const QRectF correctedGeometryF = qt_window_private(const_cast<QWindow *>(qWindow))->closestAcceptableGeometry(rectF);-
496 return
never executed: return !correctedGeometryF.isEmpty() && rectF != correctedGeometryF ? QHighDpi::toNativePixels(correctedGeometryF, qWindow) : nativeRect;
!correctedGeometryF.isEmpty() && rectF != correctedGeometryF
never executed: return !correctedGeometryF.isEmpty() && rectF != correctedGeometryF ? QHighDpi::toNativePixels(correctedGeometryF, qWindow) : nativeRect;
0
497 ? QHighDpi::toNativePixels(correctedGeometryF, qWindow) : nativeRect;
never executed: return !correctedGeometryF.isEmpty() && rectF != correctedGeometryF ? QHighDpi::toNativePixels(correctedGeometryF, qWindow) : nativeRect;
0
498}-
499-
500QRectF QPlatformWindow::windowClosestAcceptableGeometry(const QRectF &nativeRect) const-
501{-
502 return
never executed: return QPlatformWindow::closestAcceptableGeometry(window(), nativeRect);
QPlatformWindow::closestAcceptableGeometry(window(), nativeRect);
never executed: return QPlatformWindow::closestAcceptableGeometry(window(), nativeRect);
0
503}-
504-
Switch to Source codePreprocessed file

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