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}-
17-
18-
19-
20-
21QPlatformWindow::~QPlatformWindow()-
22{-
23}-
24-
25-
26-
27-
28QWindow *QPlatformWindow::window() const-
29{-
30 return static_cast<QWindow *>(m_surface);-
31}-
32-
33-
34-
35-
36QPlatformWindow *QPlatformWindow::parent() const-
37{-
38 return window()->parent() ? window()->parent()->handle() : 0;-
39}-
40-
41-
42-
43-
44-
45QPlatformScreen *QPlatformWindow::screen() const-
46{-
47 QScreen *scr = window()->screen();-
48 return scr ? scr->handle() : nullptr;-
49}-
50-
51-
52-
53-
54QSurfaceFormat QPlatformWindow::format() const-
55{-
56 return QSurfaceFormat();-
57}-
58void QPlatformWindow::setGeometry(const QRect &rect)-
59{-
60 QPlatformWindowPrivate * const d = d_func();-
61 d->rect = rect;-
62}-
63-
64-
65-
66-
67QRect QPlatformWindow::geometry() const-
68{-
69 const QPlatformWindowPrivate * const d = d_func();-
70 return d->rect;-
71}-
72QRect QPlatformWindow::normalGeometry() const-
73{-
74 return QRect();-
75}-
76-
77QMargins QPlatformWindow::frameMargins() const-
78{-
79 return QMargins();-
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}-
95-
96-
97-
98-
99-
100void QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)-
101{-
102 (void)flags;;-
103}-
104-
105-
106-
107-
108-
109-
110-
111bool QPlatformWindow::isExposed() const-
112{-
113 return window()->isVisible();-
114}-
115-
116-
117-
118-
119-
120-
121-
122bool QPlatformWindow::isActive() const-
123{-
124 return false;-
125}-
126bool QPlatformWindow::isEmbedded(const QPlatformWindow *parentWindow) const-
127{-
128 (void)parentWindow;;-
129 return false;-
130}-
131QPoint QPlatformWindow::mapToGlobal(const QPoint &pos) const-
132{-
133 const QPlatformWindow *p = this;-
134 QPoint result = pos;-
135 while (p) {-
136 result += p->geometry().topLeft();-
137 p = p->parent();-
138 }-
139 return result;-
140}-
141QPoint QPlatformWindow::mapFromGlobal(const QPoint &pos) const-
142{-
143 const QPlatformWindow *p = this;-
144 QPoint result = pos;-
145 while (p) {-
146 result -= p->geometry().topLeft();-
147 p = p->parent();-
148 }-
149 return result;-
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 WId(1);-
172}-
173void QPlatformWindow::setParent(const QPlatformWindow *parent)-
174{-
175 (void)parent;;-
176 QMessageLogger(__FILE__, 269275, __PRETTY_FUNCTION__).warning("This plugin does not support setParent!");-
177}-
178void QPlatformWindow::setWindowTitle(const QString &title) { (void)title;; }-
179-
180-
181-
182-
183void QPlatformWindow::setWindowFilePath(const QString &filePath) { (void)filePath;; }-
184-
185-
186-
187-
188void QPlatformWindow::setWindowIcon(const QIcon &icon) { (void)icon;; }-
189-
190-
191-
192-
193void QPlatformWindow::raise() { QMessageLogger(__FILE__, 295301, __PRETTY_FUNCTION__).warning("This plugin does not support raise()"); }-
194-
195-
196-
197-
198void QPlatformWindow::lower() { QMessageLogger(__FILE__, 300306, __PRETTY_FUNCTION__).warning("This plugin does not support lower()"); }-
199-
200-
201-
202-
203-
204-
205-
206void QPlatformWindow::propagateSizeHints() {QMessageLogger(__FILE__, 308314, __PRETTY_FUNCTION__).warning("This plugin does not support propagateSizeHints()"); }-
207-
208-
209-
210-
211void QPlatformWindow::setOpacity(qreal level)-
212{-
213 (void)level;;-
214 QMessageLogger(__FILE__, 316322, __PRETTY_FUNCTION__).warning("This plugin does not support setting window opacity");-
215}-
216-
217-
218-
219-
220-
221void QPlatformWindow::setMask(const QRegion &region)-
222{-
223 (void)region;;-
224 QMessageLogger(__FILE__, 326332, __PRETTY_FUNCTION__).warning("This plugin does not support setting window masks");-
225}-
226void QPlatformWindow::requestActivateWindow()-
227{-
228 QWindowSystemInterface::handleWindowActivated(window());-
229}-
230void QPlatformWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)-
231{-
232 (void)orientation;;-
233}-
234qreal QPlatformWindow::devicePixelRatio() const-
235{-
236 return 1.0;-
237}-
238-
239bool QPlatformWindow::setKeyboardGrabEnabled(bool grab)-
240{-
241 (void)grab;;-
242 QMessageLogger(__FILE__, 376382, __PRETTY_FUNCTION__).warning("This plugin does not support grabbing the keyboard");-
243 return false;-
244}-
245-
246bool QPlatformWindow::setMouseGrabEnabled(bool grab)-
247{-
248 (void)grab;;-
249 QMessageLogger(__FILE__, 383389, __PRETTY_FUNCTION__).warning("This plugin does not support grabbing the mouse");-
250 return false;-
251}-
252-
253-
254-
255-
256-
257-
258bool QPlatformWindow::setWindowModified(bool modified)-
259{-
260 (void)modified;;-
261 return false;-
262}-
263void QPlatformWindow::windowEvent(QEvent *event)-
264{-
265 (void)event;;-
266}-
267bool QPlatformWindow::startSystemResize(const QPoint &pos, Qt::Corner corner)-
268{-
269 (void)pos;-
270 (void)corner;-
271 return false;-
272}-
273void QPlatformWindow::setFrameStrutEventsEnabled(bool enabled)-
274{-
275 (void)enabled;-
276}-
277-
278-
279-
280-
281-
282-
283bool QPlatformWindow::frameStrutEventsEnabled() const-
284{-
285 return false;-
286}-
287QString QPlatformWindow::formatWindowTitle(const QString &title, const QString &separator)-
288{-
289 QString fullTitle = title;-
290 if (QGuiApplicationPrivate::displayName && !title.endsWith(*QGuiApplicationPrivate::displayName)) {-
291-
292 if (!fullTitle.isEmpty())-
293 fullTitle += separator;-
294 fullTitle += *QGuiApplicationPrivate::displayName;-
295 } else if (fullTitle.isEmpty()) {-
296-
297 fullTitle = QCoreApplication::applicationName();-
298 }-
299 return fullTitle;-
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 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(currentScreen->virtualSiblings())>::type> _container_((const auto screens = currentScreen->virtualSiblings())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)();-
313 for (QPlatformScreen *screen = *_container_.i; _container_.control; _container_.control = 0: screens) {-
314 if (const QRect screenGeometry = screen->geometry().();-
315 if (screenGeometry.
screenGeometry...ntains(center)Description
TRUEnever evaluated
FALSEnever evaluated
screenGeometry...ntains(center)Description
TRUEnever evaluated
FALSEnever evaluated
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 (screen->geometry().screenGeometry.
screenGeometry...s(newGeometry)Description
TRUEnever evaluated
FALSEnever evaluated
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 size.expandedTo(QSize(0, 0)).boundedTo(QSize(((1<<24)-1), ((1<<24)-1)));-
330}-
331void QPlatformWindow::setAlertState(bool enable)-
332{-
333 (void)enable;-
334}-
335bool QPlatformWindow::isAlertState() const-
336{-
337 return false;-
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 (QForeachContainer<typename QtPrivate::remove_reference<decltype(siblings)>::type> _container_((siblings)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QScreen *sibling = *_container_.i; _container_.control; _container_.control = 0: 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) {-
371 const int minWidth = w->minimumWidth();-
372 size.setWidth(minWidth > 0 ? minWidth : defaultWidth);-
373 }-
374 if (size.height() == 0) {-
375 const int minHeight = w->minimumHeight();-
376 size.setHeight(minHeight > 0 ? minHeight : defaultHeight);-
377 }-
378 return size;-
379}-
380QRect QPlatformWindow::initialGeometry(const QWindow *w,-
381 const QRect &initialGeometry, int defaultWidth, int defaultHeight)-
382{-
383 if (!w->isTopLevel()) {-
384 const qreal factor = QHighDpiScaling::factor(w);-
385 const QSize size = fixInitialSize(QHighDpi::fromNative(initialGeometry.size(), factor),-
386 w, defaultWidth, defaultHeight);-
387 return QRect(initialGeometry.topLeft(), QHighDpi::toNative(size, factor));-
388 }-
389 const QScreen *screen = effectiveScreen(w);-
390 if (!screen)-
391 return initialGeometry;-
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-
395 && w->type() != Qt::Popup) {-
396 const QRect availableGeometry = screen->availableGeometry();-
397-
398 if (rect.height() < (availableGeometry.height() * 8) / 9-
399 && rect.width() < (availableGeometry.width() * 8) / 9) {-
400 const QWindow *tp = w->transientParent();-
401 if (tp) {-
402-
403 rect.moveCenter(tp->geometry().center());-
404 } else {-
405-
406-
407 rect.moveCenter(availableGeometry.center());-
408 }-
409 }-
410 }-
411 return QHighDpi::toNativePixels(rect, screen);-
412}-
413void QPlatformWindow::requestUpdate()-
414{-
415 static int timeout = -1;-
416 if (timeout == -1) {-
417 bool ok = false;-
418 timeout = qEnvironmentVariableIntValue("QT_QPA_UPDATE_IDLE_TIME", &ok);-
419 if (!ok)-
420 timeout = 5;-
421 }-
422-
423 QWindow *w = window();-
424 QWindowPrivate *wp = (QWindowPrivate *) QObjectPrivate::get(w);-
425 ((!(wp->updateTimer == 0)) ? qt_assert("wp->updateTimer == 0",__FILE__,658667) : qt_noop());-
426 wp->updateTimer = w->startTimer(timeout, Qt::PreciseTimer);-
427}-
428-
429-
430-
431-
432QSize QPlatformWindow::windowMinimumSize() const-
433{-
434 return constrainWindowSize(QHighDpi::toNativePixels(window()->minimumSize(), window()));-
435}-
436-
437-
438-
439-
440QSize QPlatformWindow::windowMaximumSize() const-
441{-
442 return constrainWindowSize(QHighDpi::toNativePixels(window()->maximumSize(), window()));-
443}-
444-
445-
446-
447-
448QSize QPlatformWindow::windowBaseSize() const-
449{-
450 return QHighDpi::toNativePixels(window()->baseSize(), window());-
451}-
452-
453-
454-
455-
456QSize QPlatformWindow::windowSizeIncrement() const-
457{-
458 QSize increment = window()->sizeIncrement();-
459 if (!QHighDpiScaling::isActive())-
460 return increment;-
461-
462-
463-
464 if (increment.isEmpty())-
465 increment = QSize(1, 1);-
466-
467 return QHighDpi::toNativePixels(increment, window());-
468}-
469-
470-
471-
472-
473QRect QPlatformWindow::windowGeometry() const-
474{-
475 return QHighDpi::toNativePixels(window()->geometry(), window());-
476}-
477-
478-
479-
480-
481QRect QPlatformWindow::windowFrameGeometry() const-
482{-
483 return QHighDpi::toNativePixels(window()->frameGeometry(), window());-
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 !correctedGeometryF.isEmpty() && rectF != correctedGeometryF-
497 ? QHighDpi::toNativePixels(correctedGeometryF, qWindow) : nativeRect;-
498}-
499-
500QRectF QPlatformWindow::windowClosestAcceptableGeometry(const QRectF &nativeRect) const-
501{-
502 return QPlatformWindow::closestAcceptableGeometry(window(), nativeRect);-
503}-
504-
Switch to Source codePreprocessed file

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