kernel/qwindow.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11 -
12QWindow::QWindow(QScreen *targetScreen) -
13 : QObject(*new QWindowPrivate(), 0) -
14 , QSurface(QSurface::Window) -
15{ -
16 QWindowPrivate * const d = d_func(); -
17 d->screen = targetScreen; -
18 if (!d->screen)
-
19 d->screen = QGuiApplication::primaryScreen();
-
20 -
21 -
22 -
23 qt_noop(); -
24 -
25 connect(d->screen, "2""destroyed(QObject*)", this, "1""screenDestroyed(QObject*)"); -
26 QGuiApplicationPrivate::window_list.prepend(this); -
27}
-
28QWindow::QWindow(QWindow *parent) -
29 : QObject(*new QWindowPrivate(), parent) -
30 , QSurface(QSurface::Window) -
31{ -
32 QWindowPrivate * const d = d_func(); -
33 d->parentWindow = parent; -
34 if (parent)
-
35 d->screen = parent->screen();
-
36 if (!d->screen)
-
37 d->screen = QGuiApplication::primaryScreen();
-
38 connect(d->screen, "2""destroyed(QObject*)", this, "1""screenDestroyed(QObject*)"); -
39 QGuiApplicationPrivate::window_list.prepend(this); -
40}
-
41QWindow::QWindow(QWindowPrivate &dd, QWindow *parent) -
42 : QObject(dd, parent) -
43 , QSurface(QSurface::Window) -
44{ -
45 QWindowPrivate * const d = d_func(); -
46 d->parentWindow = parent; -
47 if (parent)
-
48 d->screen = parent->screen();
-
49 if (!d->screen)
-
50 d->screen = QGuiApplication::primaryScreen();
-
51 connect(d->screen, "2""destroyed(QObject*)", this, "1""screenDestroyed(QObject*)"); -
52 QGuiApplicationPrivate::window_list.prepend(this); -
53}
-
54 -
55 -
56 -
57 -
58QWindow::~QWindow() -
59{ -
60 if (QGuiApplicationPrivate::focus_window == this)
-
61 QGuiApplicationPrivate::focus_window = 0;
-
62 if (QGuiApplicationPrivate::currentMouseWindow == this)
-
63 QGuiApplicationPrivate::currentMouseWindow = 0;
-
64 QGuiApplicationPrivate::window_list.removeAll(this); -
65 destroy(); -
66}
-
67void QWindow::setSurfaceType(SurfaceType surfaceType) -
68{ -
69 QWindowPrivate * const d = d_func(); -
70 d->surfaceType = surfaceType; -
71}
-
72 -
73 -
74 -
75 -
76 -
77 -
78QWindow::SurfaceType QWindow::surfaceType() const -
79{ -
80 const QWindowPrivate * const d = d_func(); -
81 return d->surfaceType;
-
82} -
83void QWindow::setVisible(bool visible) -
84{ -
85 QWindowPrivate * const d = d_func(); -
86 -
87 if (d->visible == visible)
-
88 return;
-
89 d->visible = visible; -
90 visibleChanged(visible); -
91 -
92 if (!d->platformWindow)
-
93 create();
-
94 -
95 if (visible) {
-
96 -
97 QCoreApplication::removePostedEvents((static_cast<QGuiApplication *>(QCoreApplication::instance())), QEvent::Quit); -
98 -
99 QShowEvent showEvent; -
100 QGuiApplication::sendEvent(this, &showEvent); -
101 }
-
102 -
103 if (isModal()) {
-
104 if (visible)
-
105 QGuiApplicationPrivate::showModalWindow(this);
-
106 else -
107 QGuiApplicationPrivate::hideModalWindow(this);
-
108 } -
109 -
110 -
111 if (visible)
-
112 d->applyCursor();
-
113 -
114 d->platformWindow->setVisible(visible); -
115 -
116 if (!visible) {
-
117 QHideEvent hideEvent; -
118 QGuiApplication::sendEvent(this, &hideEvent); -
119 }
-
120}
-
121 -
122bool QWindow::isVisible() const -
123{ -
124 const QWindowPrivate * const d = d_func(); -
125 -
126 return d->visible;
-
127} -
128void QWindow::create() -
129{ -
130 QWindowPrivate * const d = d_func(); -
131 if (!d->platformWindow) {
-
132 d->platformWindow = QGuiApplicationPrivate::platformIntegration()->createPlatformWindow(this); -
133 QObjectList childObjects = children(); -
134 for (int i = 0; i < childObjects.size(); i ++) {
-
135 QObject *object = childObjects.at(i); -
136 if(object->isWindowType()) {
-
137 QWindow *window = static_cast<QWindow *>(object); -
138 if (window->d_func()->platformWindow)
-
139 window->d_func()->platformWindow->setParent(d->platformWindow);
-
140 }
-
141 }
-
142 }
-
143}
-
144WId QWindow::winId() const -
145{ -
146 const QWindowPrivate * const d = d_func(); -
147 if(!d->platformWindow)
-
148 const_cast<QWindow *>(this)->create();
-
149 -
150 WId id = d->platformWindow->winId(); -
151 -
152 qt_noop(); -
153 return id;
-
154} -
155 -
156 -
157 -
158 -
159 -
160 -
161QWindow *QWindow::parent() const -
162{ -
163 const QWindowPrivate * const d = d_func(); -
164 return d->parentWindow;
-
165} -
166void QWindow::setParent(QWindow *parent) -
167{ -
168 QWindowPrivate * const d = d_func(); -
169 -
170 QObject::setParent(parent); -
171 -
172 if (d->platformWindow) {
-
173 if (parent && parent->d_func()->platformWindow) {
-
174 d->platformWindow->setParent(parent->d_func()->platformWindow); -
175 } else {
-
176 d->platformWindow->setParent(0); -
177 }
-
178 } -
179 -
180 d->parentWindow = parent; -
181 -
182 QGuiApplicationPrivate::updateBlockedStatus(this); -
183}
-
184 -
185 -
186 -
187 -
188bool QWindow::isTopLevel() const -
189{ -
190 const QWindowPrivate * const d = d_func(); -
191 return d->parentWindow == 0;
-
192} -
193bool QWindow::isModal() const -
194{ -
195 const QWindowPrivate * const d = d_func(); -
196 return d->modality != Qt::NonModal;
-
197} -
198Qt::WindowModality QWindow::modality() const -
199{ -
200 const QWindowPrivate * const d = d_func(); -
201 return d->modality;
-
202} -
203 -
204void QWindow::setModality(Qt::WindowModality modality) -
205{ -
206 QWindowPrivate * const d = d_func(); -
207 if (d->modality == modality)
-
208 return;
-
209 d->modality = modality; -
210 modalityChanged(modality); -
211}
-
212void QWindow::setFormat(const QSurfaceFormat &format) -
213{ -
214 QWindowPrivate * const d = d_func(); -
215 d->requestedFormat = format; -
216}
-
217QSurfaceFormat QWindow::requestedFormat() const -
218{ -
219 const QWindowPrivate * const d = d_func(); -
220 return d->requestedFormat;
-
221} -
222QSurfaceFormat QWindow::format() const -
223{ -
224 const QWindowPrivate * const d = d_func(); -
225 if (d->platformWindow)
-
226 return d->platformWindow->format();
-
227 return d->requestedFormat;
-
228} -
229void QWindow::setFlags(Qt::WindowFlags flags) -
230{ -
231 QWindowPrivate * const d = d_func(); -
232 if (d->platformWindow)
-
233 d->platformWindow->setWindowFlags(flags);
-
234 d->windowFlags = flags; -
235}
-
236 -
237Qt::WindowFlags QWindow::flags() const -
238{ -
239 const QWindowPrivate * const d = d_func(); -
240 return d->windowFlags;
-
241} -
242Qt::WindowType QWindow::type() const -
243{ -
244 const QWindowPrivate * const d = d_func(); -
245 return static_cast<Qt::WindowType>(int(d->windowFlags & Qt::WindowType_Mask));
-
246} -
247void QWindow::setTitle(const QString &title) -
248{ -
249 QWindowPrivate * const d = d_func(); -
250 d->windowTitle = title; -
251 if (d->platformWindow)
-
252 d->platformWindow->setWindowTitle(title);
-
253}
-
254 -
255QString QWindow::title() const -
256{ -
257 const QWindowPrivate * const d = d_func(); -
258 return d->windowTitle;
-
259} -
260void QWindow::setFilePath(const QString &filePath) -
261{ -
262 QWindowPrivate * const d = d_func(); -
263 d->windowFilePath = filePath; -
264 if (d->platformWindow)
-
265 d->platformWindow->setWindowFilePath(filePath);
-
266}
-
267 -
268 -
269 -
270 -
271 -
272 -
273QString QWindow::filePath() const -
274{ -
275 const QWindowPrivate * const d = d_func(); -
276 return d->windowFilePath;
-
277} -
278 -
279 -
280 -
281 -
282 -
283 -
284 -
285void QWindow::setIcon(const QIcon &icon) -
286{ -
287 QWindowPrivate * const d = d_func(); -
288 d->windowIcon = icon; -
289 if (d->platformWindow)
-
290 d->platformWindow->setWindowIcon(icon);
-
291}
-
292 -
293 -
294 -
295 -
296 -
297 -
298QIcon QWindow::icon() const -
299{ -
300 const QWindowPrivate * const d = d_func(); -
301 return d->windowIcon;
-
302} -
303 -
304 -
305 -
306 -
307 -
308 -
309void QWindow::raise() -
310{ -
311 QWindowPrivate * const d = d_func(); -
312 if (d->platformWindow)
-
313 d->platformWindow->raise();
-
314}
-
315 -
316 -
317 -
318 -
319 -
320 -
321void QWindow::lower() -
322{ -
323 QWindowPrivate * const d = d_func(); -
324 if (d->platformWindow)
-
325 d->platformWindow->lower();
-
326}
-
327void QWindow::setOpacity(qreal level) -
328{ -
329 QWindowPrivate * const d = d_func(); -
330 if (level == d->opacity)
-
331 return;
-
332 d->opacity = level; -
333 if (d->platformWindow)
-
334 d->platformWindow->setOpacity(level);
-
335}
-
336 -
337 -
338 -
339 -
340 -
341 -
342void QWindow::requestActivate() -
343{ -
344 QWindowPrivate * const d = d_func(); -
345 if (d->platformWindow)
-
346 d->platformWindow->requestActivateWindow();
-
347}
-
348bool QWindow::isExposed() const -
349{ -
350 const QWindowPrivate * const d = d_func(); -
351 return d->exposed;
-
352} -
353bool QWindow::isActive() const -
354{ -
355 const QWindowPrivate * const d = d_func(); -
356 if (!d->platformWindow)
-
357 return false;
-
358 -
359 QWindow *focus = QGuiApplication::focusWindow(); -
360 -
361 -
362 if (!focus)
-
363 return false;
-
364 -
365 if (focus == this)
-
366 return true;
-
367 -
368 if (!parent() && !transientParent()) {
-
369 return isAncestorOf(focus);
-
370 } else { -
371 return (parent() && parent()->isActive()) || (transientParent() && transientParent()->isActive());
-
372 } -
373} -
374void QWindow::reportContentOrientationChange(Qt::ScreenOrientation orientation) -
375{ -
376 QWindowPrivate * const d = d_func(); -
377 if (d->contentOrientation == orientation)
-
378 return;
-
379 if (!d->platformWindow)
-
380 create();
-
381 qt_noop(); -
382 d->contentOrientation = orientation; -
383 d->platformWindow->handleContentOrientationChange(orientation); -
384 contentOrientationChanged(orientation); -
385}
-
386 -
387Qt::ScreenOrientation QWindow::contentOrientation() const -
388{ -
389 const QWindowPrivate * const d = d_func(); -
390 return d->contentOrientation;
-
391} -
392qreal QWindow::devicePixelRatio() const -
393{ -
394 const QWindowPrivate * const d = d_func(); -
395 if (!d->platformWindow)
-
396 return 1.0;
-
397 return d->platformWindow->devicePixelRatio();
-
398} -
399void QWindow::setWindowState(Qt::WindowState state) -
400{ -
401 if (state == Qt::WindowActive) {
-
402 QMessageLogger("kernel/qwindow.cpp", 792791, __PRETTY_FUNCTION__).warning() << "QWindow::setWindowState does not accept Qt::WindowActive"; -
403 return;
-
404 } -
405 -
406 QWindowPrivate * const d = d_func(); -
407 if (d->platformWindow)
-
408 d->platformWindow->setWindowState(state);
-
409 d->windowState = state; -
410 windowStateChanged(d->windowState); -
411}
-
412 -
413 -
414 -
415 -
416 -
417 -
418Qt::WindowState QWindow::windowState() const -
419{ -
420 const QWindowPrivate * const d = d_func(); -
421 return d->windowState;
-
422} -
423void QWindow::setTransientParent(QWindow *parent) -
424{ -
425 QWindowPrivate * const d = d_func(); -
426 d->transientParent = parent; -
427 -
428 QGuiApplicationPrivate::updateBlockedStatus(this); -
429}
-
430 -
431 -
432 -
433 -
434 -
435 -
436QWindow *QWindow::transientParent() const -
437{ -
438 const QWindowPrivate * const d = d_func(); -
439 return d->transientParent.data();
-
440} -
441bool QWindow::isAncestorOf(const QWindow *child, AncestorMode mode) const -
442{ -
443 if (child->parent() == this || (mode == IncludeTransients && child->transientParent() == this))
-
444 return true;
-
445 -
446 return (child->parent() && isAncestorOf(child->parent(), mode)) -
447 || (mode == IncludeTransients && child->transientParent() && isAncestorOf(child->transientParent(), mode));
-
448} -
449 -
450 -
451 -
452 -
453 -
454 -
455QSize QWindow::minimumSize() const -
456{ -
457 const QWindowPrivate * const d = d_func(); -
458 return d->minimumSize;
-
459} -
460 -
461 -
462 -
463 -
464 -
465 -
466QSize QWindow::maximumSize() const -
467{ -
468 const QWindowPrivate * const d = d_func(); -
469 return d->maximumSize;
-
470} -
471 -
472 -
473 -
474 -
475 -
476 -
477QSize QWindow::baseSize() const -
478{ -
479 const QWindowPrivate * const d = d_func(); -
480 return d->baseSize;
-
481} -
482 -
483 -
484 -
485 -
486 -
487 -
488QSize QWindow::sizeIncrement() const -
489{ -
490 const QWindowPrivate * const d = d_func(); -
491 return d->sizeIncrement;
-
492} -
493void QWindow::setMinimumSize(const QSize &size) -
494{ -
495 QWindowPrivate * const d = d_func(); -
496 QSize adjustedSize = QSize(qBound(0, size.width(), ((1<<24)-1)), qBound(0, size.height(), ((1<<24)-1))); -
497 if (d->minimumSize == adjustedSize)
-
498 return;
-
499 QSize oldSize = d->minimumSize; -
500 d->minimumSize = adjustedSize; -
501 if (d->platformWindow && isTopLevel())
-
502 d->platformWindow->propagateSizeHints();
-
503 if (d->minimumSize.width() != oldSize.width())
-
504 minimumWidthChanged(d->minimumSize.width());
-
505 if (d->minimumSize.height() != oldSize.height())
-
506 minimumHeightChanged(d->minimumSize.height());
-
507}
-
508 -
509 -
510 -
511 -
512 -
513void QWindow::setX(int arg) -
514{ -
515 if (x() != arg)
-
516 setGeometry(QRect(arg, y(), width(), height()));
-
517}
-
518 -
519 -
520 -
521 -
522 -
523void QWindow::setY(int arg) -
524{ -
525 if (y() != arg)
-
526 setGeometry(QRect(x(), arg, width(), height()));
-
527}
-
528 -
529 -
530 -
531 -
532 -
533void QWindow::setWidth(int arg) -
534{ -
535 if (width() != arg)
-
536 setGeometry(QRect(x(), y(), arg, height()));
-
537}
-
538 -
539 -
540 -
541 -
542 -
543void QWindow::setHeight(int arg) -
544{ -
545 if (height() != arg)
-
546 setGeometry(QRect(x(), y(), width(), arg));
-
547}
-
548 -
549 -
550 -
551 -
552 -
553void QWindow::setMinimumWidth(int w) -
554{ -
555 setMinimumSize(QSize(w, minimumHeight())); -
556}
-
557 -
558 -
559 -
560 -
561 -
562void QWindow::setMinimumHeight(int h) -
563{ -
564 setMinimumSize(QSize(minimumWidth(), h)); -
565}
-
566void QWindow::setMaximumSize(const QSize &size) -
567{ -
568 QWindowPrivate * const d = d_func(); -
569 QSize adjustedSize = QSize(qBound(0, size.width(), ((1<<24)-1)), qBound(0, size.height(), ((1<<24)-1))); -
570 if (d->maximumSize == adjustedSize)
-
571 return;
-
572 QSize oldSize = d->maximumSize; -
573 d->maximumSize = adjustedSize; -
574 if (d->platformWindow && isTopLevel())
-
575 d->platformWindow->propagateSizeHints();
-
576 if (d->maximumSize.width() != oldSize.width())
-
577 maximumWidthChanged(d->maximumSize.width());
-
578 if (d->maximumSize.height() != oldSize.height())
-
579 maximumHeightChanged(d->maximumSize.height());
-
580}
-
581 -
582 -
583 -
584 -
585 -
586void QWindow::setMaximumWidth(int w) -
587{ -
588 setMaximumSize(QSize(w, maximumHeight())); -
589}
-
590 -
591 -
592 -
593 -
594 -
595void QWindow::setMaximumHeight(int h) -
596{ -
597 setMaximumSize(QSize(maximumWidth(), h)); -
598}
-
599void QWindow::setBaseSize(const QSize &size) -
600{ -
601 QWindowPrivate * const d = d_func(); -
602 if (d->baseSize == size)
-
603 return;
-
604 d->baseSize = size; -
605 if (d->platformWindow && isTopLevel())
-
606 d->platformWindow->propagateSizeHints();
-
607}
-
608void QWindow::setSizeIncrement(const QSize &size) -
609{ -
610 QWindowPrivate * const d = d_func(); -
611 if (d->sizeIncrement == size)
-
612 return;
-
613 d->sizeIncrement = size; -
614 if (d->platformWindow && isTopLevel())
-
615 d->platformWindow->propagateSizeHints();
-
616}
-
617 -
618 -
619 -
620 -
621 -
622 -
623 -
624void QWindow::setGeometry(int posx, int posy, int w, int h) -
625{ -
626 setGeometry(QRect(posx, posy, w, h)); -
627}
-
628 -
629 -
630 -
631 -
632 -
633 -
634void QWindow::setGeometry(const QRect &rect) -
635{ -
636 QWindowPrivate * const d = d_func(); -
637 if (rect == geometry())
-
638 return;
-
639 QRect oldRect = geometry(); -
640 -
641 d->positionPolicy = QWindowPrivate::WindowFrameExclusive; -
642 if (d->platformWindow) {
-
643 d->platformWindow->setGeometry(rect); -
644 } else {
-
645 d->geometry = rect; -
646 -
647 if (rect.x() != oldRect.x())
-
648 xChanged(rect.x());
-
649 if (rect.y() != oldRect.y())
-
650 yChanged(rect.y());
-
651 if (rect.width() != oldRect.width())
-
652 widthChanged(rect.width());
-
653 if (rect.height() != oldRect.height())
-
654 heightChanged(rect.height());
-
655 }
-
656} -
657 -
658 -
659 -
660 -
661 -
662 -
663QRect QWindow::geometry() const -
664{ -
665 const QWindowPrivate * const d = d_func(); -
666 if (d->platformWindow)
-
667 return d->platformWindow->geometry();
-
668 return d->geometry;
-
669} -
670 -
671 -
672 -
673 -
674 -
675 -
676QMargins QWindow::frameMargins() const -
677{ -
678 const QWindowPrivate * const d = d_func(); -
679 if (d->platformWindow)
-
680 return d->platformWindow->frameMargins();
-
681 return QMargins();
-
682} -
683 -
684 -
685 -
686 -
687 -
688 -
689QRect QWindow::frameGeometry() const -
690{ -
691 const QWindowPrivate * const d = d_func(); -
692 if (d->platformWindow) {
-
693 QMargins m = frameMargins(); -
694 return d->platformWindow->geometry().adjusted(-m.left(), -m.top(), m.right(), m.bottom());
-
695 } -
696 return d->geometry;
-
697} -
698QPoint QWindow::framePosition() const -
699{ -
700 const QWindowPrivate * const d = d_func(); -
701 if (d->platformWindow) {
-
702 QMargins margins = frameMargins(); -
703 return d->platformWindow->geometry().topLeft() - QPoint(margins.left(), margins.top());
-
704 } -
705 return d->geometry.topLeft();
-
706} -
707 -
708 -
709 -
710 -
711 -
712 -
713void QWindow::setFramePosition(const QPoint &point) -
714{ -
715 QWindowPrivate * const d = d_func(); -
716 d->positionPolicy = QWindowPrivate::WindowFrameInclusive; -
717 if (d->platformWindow) {
evaluated: d->platformWindow
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
718 d->platformWindow->setGeometry(QRect(point, size())); -
719 } else {
executed: }
Execution Count:1
1
720 d->geometry.setTopLeftmoveTopLeft(point); -
721 }
executed: }
Execution Count:1
1
722} -
723 -
724 -
725 -
726 -
727 -
728 -
729void QWindow::setPosition(const QPoint &pt) -
730{ -
731 setGeometry(QRect(pt, size())); -
732}
-
733 -
734 -
735 -
736 -
737 -
738 -
739void QWindow::setPosition(int posx, int posy) -
740{ -
741 setPosition(QPoint(posx, posy)); -
742}
-
743void QWindow::resize(int w, int h) -
744{ -
745 resize(QSize(w, h)); -
746}
-
747 -
748 -
749 -
750 -
751 -
752 -
753void QWindow::resize(const QSize &newSize) -
754{ -
755 QWindowPrivate * const d = d_func(); -
756 if (d->platformWindow) {
-
757 d->platformWindow->setGeometry(QRect(position(), newSize)); -
758 } else {
-
759 d->geometry.setSize(newSize); -
760 }
-
761} -
762 -
763 -
764 -
765 -
766 -
767 -
768void QWindow::destroy() -
769{ -
770 QWindowPrivate * const d = d_func(); -
771 QObjectList childrenWindows = children(); -
772 for (int i = 0; i < childrenWindows.size(); i++) {
-
773 QObject *object = childrenWindows.at(i); -
774 if (object->isWindowType()) {
-
775 QWindow *w = static_cast<QWindow*>(object); -
776 QGuiApplicationPrivate::window_list.removeAll(w); -
777 w->destroy(); -
778 }
-
779 }
-
780 setVisible(false); -
781 delete d->platformWindow; -
782 d->resizeEventPending = true; -
783 d->receivedExpose = false; -
784 d->exposed = false; -
785 d->platformWindow = 0; -
786}
-
787 -
788 -
789 -
790 -
791 -
792 -
793QPlatformWindow *QWindow::handle() const -
794{ -
795 const QWindowPrivate * const d = d_func(); -
796 return d->platformWindow;
-
797} -
798 -
799 -
800 -
801 -
802 -
803 -
804QPlatformSurface *QWindow::surfaceHandle() const -
805{ -
806 const QWindowPrivate * const d = d_func(); -
807 return d->platformWindow;
-
808} -
809bool QWindow::setKeyboardGrabEnabled(bool grab) -
810{ -
811 QWindowPrivate * const d = d_func(); -
812 if (grab && QGuiApplicationPrivate::noGrab)
-
813 return false;
-
814 if (d->platformWindow)
-
815 return d->platformWindow->setKeyboardGrabEnabled(grab);
-
816 return false;
-
817} -
818bool QWindow::setMouseGrabEnabled(bool grab) -
819{ -
820 QWindowPrivate * const d = d_func(); -
821 if (grab && QGuiApplicationPrivate::noGrab)
-
822 return false;
-
823 if (d->platformWindow)
-
824 return d->platformWindow->setMouseGrabEnabled(grab);
-
825 return false;
-
826} -
827QScreen *QWindow::screen() const -
828{ -
829 const QWindowPrivate * const d = d_func(); -
830 return d->screen;
-
831} -
832void QWindow::setScreen(QScreen *newScreen) -
833{ -
834 QWindowPrivate * const d = d_func(); -
835 if (!newScreen)
-
836 newScreen = QGuiApplication::primaryScreen();
-
837 if (newScreen != screen()) {
-
838 const bool wasCreated = d->platformWindow != 0; -
839 if (wasCreated)
-
840 destroy();
-
841 if (d->screen)
-
842 disconnect(d->screen, "2""destroyed(QObject*)", this, "1""screenDestroyed(QObject*)");
-
843 d->screen = newScreen; -
844 if (newScreen) {
-
845 connect(d->screen, "2""destroyed(QObject*)", this, "1""screenDestroyed(QObject*)"); -
846 if (wasCreated)
-
847 create();
-
848 }
-
849 screenChanged(newScreen); -
850 }
-
851}
-
852 -
853void QWindow::screenDestroyed(QObject *object) -
854{ -
855 QWindowPrivate * const d = d_func(); -
856 if (object == static_cast<QObject *>(d->screen)) {
-
857 const bool wasVisible = isVisible(); -
858 setScreen(0); -
859 -
860 -
861 -
862 -
863 if (wasVisible && d->platformWindow)
-
864 setVisible(true);
-
865 }
-
866}
-
867QAccessibleInterface *QWindow::accessibleRoot() const -
868{ -
869 return 0;
-
870} -
871QObject *QWindow::focusObject() const -
872{ -
873 return const_cast<QWindow *>(this);
-
874} -
875void QWindow::show() -
876{ -
877 if ((static_cast<QGuiApplication *>(QCoreApplication::instance()))->styleHints()->showIsFullScreen())
-
878 showFullScreen();
-
879 else -
880 showNormal();
-
881} -
882void QWindow::hide() -
883{ -
884 setVisible(false); -
885}
-
886void QWindow::showMinimized() -
887{ -
888 setWindowState(Qt::WindowMinimized); -
889 setVisible(true); -
890}
-
891void QWindow::showMaximized() -
892{ -
893 setWindowState(Qt::WindowMaximized); -
894 setVisible(true); -
895}
-
896void QWindow::showFullScreen() -
897{ -
898 setWindowState(Qt::WindowFullScreen); -
899 setVisible(true); -
900 requestActivate(); -
901}
-
902void QWindow::showNormal() -
903{ -
904 setWindowState(Qt::WindowNoState); -
905 setVisible(true); -
906}
-
907bool QWindow::close() -
908{ -
909 QWindowPrivate * const d = d_func(); -
910 -
911 -
912 if (parent())
-
913 return false;
-
914 -
915 if (QGuiApplicationPrivate::focus_window == this)
-
916 QGuiApplicationPrivate::focus_window = 0;
-
917 if (QGuiApplicationPrivate::currentMouseWindow == this)
-
918 QGuiApplicationPrivate::currentMouseWindow = 0;
-
919 -
920 QGuiApplicationPrivate::window_list.removeAll(this); -
921 destroy(); -
922 d->maybeQuitOnLastWindowClosed(); -
923 return true;
-
924} -
925void QWindow::exposeEvent(QExposeEvent *ev) -
926{ -
927 ev->ignore(); -
928}
-
929 -
930 -
931 -
932 -
933void QWindow::moveEvent(QMoveEvent *ev) -
934{ -
935 ev->ignore(); -
936}
-
937void QWindow::resizeEvent(QResizeEvent *ev) -
938{ -
939 ev->ignore(); -
940}
-
941void QWindow::showEvent(QShowEvent *ev) -
942{ -
943 ev->ignore(); -
944}
-
945 -
946 -
947 -
948 -
949 -
950 -
951 -
952void QWindow::hideEvent(QHideEvent *ev) -
953{ -
954 ev->ignore(); -
955}
-
956bool QWindow::event(QEvent *ev) -
957{ -
958 switch (ev->type()) { -
959 case QEvent::MouseMove: -
960 mouseMoveEvent(static_cast<QMouseEvent*>(ev)); -
961 break;
-
962 -
963 case QEvent::MouseButtonPress: -
964 mousePressEvent(static_cast<QMouseEvent*>(ev)); -
965 break;
-
966 -
967 case QEvent::MouseButtonRelease: -
968 mouseReleaseEvent(static_cast<QMouseEvent*>(ev)); -
969 break;
-
970 -
971 case QEvent::MouseButtonDblClick: -
972 mouseDoubleClickEvent(static_cast<QMouseEvent*>(ev)); -
973 break;
-
974 -
975 case QEvent::TouchBegin: -
976 case QEvent::TouchUpdate: -
977 case QEvent::TouchEnd: -
978 case QEvent::TouchCancel: -
979 touchEvent(static_cast<QTouchEvent *>(ev)); -
980 break;
-
981 -
982 case QEvent::Move: -
983 moveEvent(static_cast<QMoveEvent*>(ev)); -
984 break;
-
985 -
986 case QEvent::Resize: -
987 resizeEvent(static_cast<QResizeEvent*>(ev)); -
988 break;
-
989 -
990 case QEvent::KeyPress: -
991 keyPressEvent(static_cast<QKeyEvent *>(ev)); -
992 break;
-
993 -
994 case QEvent::KeyRelease: -
995 keyReleaseEvent(static_cast<QKeyEvent *>(ev)); -
996 break;
-
997 -
998 case QEvent::FocusIn: { -
999 focusInEvent(static_cast<QFocusEvent *>(ev)); -
1000 -
1001 QAccessible::State state; -
1002 state.active = true; -
1003 QAccessibleStateChangeEvent event(this, state); -
1004 QAccessible::updateAccessibility(&event); -
1005 -
1006 break; }
-
1007 -
1008 case QEvent::FocusOut: { -
1009 focusOutEvent(static_cast<QFocusEvent *>(ev)); -
1010 -
1011 QAccessible::State state; -
1012 state.active = true; -
1013 QAccessibleStateChangeEvent event(this, state); -
1014 QAccessible::updateAccessibility(&event); -
1015 -
1016 break; }
-
1017 -
1018 -
1019 case QEvent::Wheel: -
1020 wheelEvent(static_cast<QWheelEvent*>(ev)); -
1021 break;
-
1022 -
1023 -
1024 case QEvent::Close: { -
1025 QWindowPrivate * const d = d_func(); -
1026 bool wasVisible = isVisible(); -
1027 destroy(); -
1028 if (wasVisible)
-
1029 d->maybeQuitOnLastWindowClosed();
-
1030 break; }
-
1031 -
1032 case QEvent::Expose: -
1033 exposeEvent(static_cast<QExposeEvent *>(ev)); -
1034 break;
-
1035 -
1036 case QEvent::Show: -
1037 showEvent(static_cast<QShowEvent *>(ev)); -
1038 break;
-
1039 -
1040 case QEvent::Hide: -
1041 hideEvent(static_cast<QHideEvent *>(ev)); -
1042 break;
-
1043 -
1044 case QEvent::WindowStateChange: { -
1045 QWindowPrivate * const d = d_func(); -
1046 windowStateChanged(d->windowState); -
1047 break;
-
1048 } -
1049 -
1050 -
1051 case QEvent::TabletPress: -
1052 case QEvent::TabletMove: -
1053 case QEvent::TabletRelease: -
1054 tabletEvent(static_cast<QTabletEvent *>(ev)); -
1055 break;
-
1056 -
1057 -
1058 default: -
1059 return QObject::event(ev);
-
1060 } -
1061 return true;
-
1062} -
1063 -
1064 -
1065 -
1066 -
1067 -
1068 -
1069void QWindow::keyPressEvent(QKeyEvent *ev) -
1070{ -
1071 ev->ignore(); -
1072}
-
1073 -
1074 -
1075 -
1076 -
1077 -
1078 -
1079void QWindow::keyReleaseEvent(QKeyEvent *ev) -
1080{ -
1081 ev->ignore(); -
1082}
-
1083void QWindow::focusInEvent(QFocusEvent *ev) -
1084{ -
1085 ev->ignore(); -
1086}
-
1087void QWindow::focusOutEvent(QFocusEvent *ev) -
1088{ -
1089 ev->ignore(); -
1090}
-
1091 -
1092 -
1093 -
1094 -
1095 -
1096 -
1097void QWindow::mousePressEvent(QMouseEvent *ev) -
1098{ -
1099 ev->ignore(); -
1100}
-
1101 -
1102 -
1103 -
1104 -
1105 -
1106 -
1107void QWindow::mouseReleaseEvent(QMouseEvent *ev) -
1108{ -
1109 ev->ignore(); -
1110}
-
1111 -
1112 -
1113 -
1114 -
1115 -
1116 -
1117void QWindow::mouseDoubleClickEvent(QMouseEvent *ev) -
1118{ -
1119 ev->ignore(); -
1120}
-
1121 -
1122 -
1123 -
1124 -
1125void QWindow::mouseMoveEvent(QMouseEvent *ev) -
1126{ -
1127 ev->ignore(); -
1128}
-
1129 -
1130 -
1131 -
1132 -
1133 -
1134void QWindow::wheelEvent(QWheelEvent *ev) -
1135{ -
1136 ev->ignore(); -
1137}
-
1138 -
1139 -
1140 -
1141 -
1142 -
1143void QWindow::touchEvent(QTouchEvent *ev) -
1144{ -
1145 ev->ignore(); -
1146}
-
1147void QWindow::tabletEvent(QTabletEvent *ev) -
1148{ -
1149 ev->ignore(); -
1150}
-
1151bool QWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) -
1152{ -
1153 (void)eventType;; -
1154 (void)message;; -
1155 (void)result;; -
1156 return false;
-
1157} -
1158QPoint QWindow::mapToGlobal(const QPoint &pos) const -
1159{ -
1160 const QWindowPrivate * const d = d_func(); -
1161 if (d->platformWindow && d->platformWindow->isEmbedded(0))
-
1162 return d->platformWindow->mapToGlobal(pos);
-
1163 else -
1164 return pos + d_func()->globalPosition();
-
1165} -
1166QPoint QWindow::mapFromGlobal(const QPoint &pos) const -
1167{ -
1168 const QWindowPrivate * const d = d_func(); -
1169 if (d->platformWindow && d->platformWindow->isEmbedded(0))
-
1170 return d->platformWindow->mapFromGlobal(pos);
-
1171 else -
1172 return pos - d_func()->globalPosition();
-
1173} -
1174 -
1175 -
1176__attribute__((visibility("default"))) QWindowPrivate *qt_window_private(QWindow *window) -
1177{ -
1178 return window->d_func();
-
1179} -
1180 -
1181void QWindowPrivate::maybeQuitOnLastWindowClosed() -
1182{ -
1183 QWindow * const q = q_func(); -
1184 -
1185 -
1186 bool quitOnClose = QGuiApplication::quitOnLastWindowClosed() && !q->parent();
-
1187 -
1188 if (quitOnClose) {
-
1189 QWindowList list = QGuiApplication::topLevelWindows(); -
1190 bool lastWindowClosed = true; -
1191 for (int i = 0; i < list.size(); ++i) {
-
1192 QWindow *w = list.at(i); -
1193 if (!w->isVisible() || w->transientParent())
-
1194 continue;
-
1195 lastWindowClosed = false; -
1196 break;
-
1197 } -
1198 if (lastWindowClosed) {
-
1199 QGuiApplicationPrivate::emitLastWindowClosed(); -
1200 QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance())); -
1201 applicationPrivate->maybeQuit(); -
1202 }
-
1203 }
-
1204 -
1205}
-
1206void QWindow::setCursor(const QCursor &cursor) -
1207{ -
1208 QWindowPrivate * const d = d_func(); -
1209 d->cursor = cursor; -
1210 -
1211 if (d->screen->handle()->cursor()) {
-
1212 d->applyCursor(); -
1213 QEvent event(QEvent::CursorChange); -
1214 QGuiApplication::sendEvent(this, &event); -
1215 }
-
1216}
-
1217 -
1218 -
1219 -
1220 -
1221void QWindow::unsetCursor() -
1222{ -
1223 setCursor(Qt::ArrowCursor); -
1224}
-
1225 -
1226 -
1227 -
1228 -
1229 -
1230 -
1231QCursor QWindow::cursor() const -
1232{ -
1233 const QWindowPrivate * const d = d_func(); -
1234 return d->cursor;
-
1235} -
1236 -
1237void QWindowPrivate::applyCursor() -
1238{ -
1239 QWindow * const q = q_func(); -
1240 if (platformWindow) {
-
1241 if (QPlatformCursor *platformCursor = screen->handle()->cursor()) {
-
1242 QCursor *oc = QGuiApplication::overrideCursor(); -
1243 QCursor c = oc ? *oc : cursor;
-
1244 platformCursor->changeCursor(&c, q); -
1245 }
-
1246 }
-
1247}
-
1248 -
1249 -
1250 -
1251 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial