qwindowcontainer.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qwindowcontainer.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5class QWindowContainerPrivate : public QWidgetPrivate-
6{-
7public:-
8 inline QWindowContainer* q_func() { return static_cast<QWindowContainer *>(q_ptr); } inline const QWindowContainer* q_func() const { return static_cast<const QWindowContainer *>(q_ptr); } friend class QWindowContainer;-
9-
10 QWindowContainerPrivate()-
11 : window(0)-
12 , oldFocusWindow(0)-
13 , usesNativeWidgets(false)-
14 {-
15 }
never executed: end of block
0
16-
17 ~QWindowContainerPrivate() { }-
18-
19 static QWindowContainerPrivate *get(QWidget *w) {-
20 QWindowContainer *wc = qobject_cast<QWindowContainer *>(w);-
21 if (wc
wcDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
22 return
never executed: return wc->d_func();
wc->d_func();
never executed: return wc->d_func();
0
23 return
never executed: return 0;
0;
never executed: return 0;
0
24 }-
25-
26 void updateGeometry() {-
27 QWindowContainer * const q = q_func();-
28 if (!q->isWindow()
!q->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
&& (q->geometry().bottom() <= 0
q->geometry().bottom() <= 0Description
TRUEnever evaluated
FALSEnever evaluated
|| q->geometry().right() <= 0
q->geometry().right() <= 0Description
TRUEnever evaluated
FALSEnever evaluated
))
0
29-
30-
31-
32-
33-
34 window->setGeometry(q->geometry());
never executed: window->setGeometry(q->geometry());
0
35 else if (usesNativeWidgets
usesNativeWidgetsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
36 window->setGeometry(q->rect());
never executed: window->setGeometry(q->rect());
0
37 else-
38 window->setGeometry(QRect(q->mapTo(q->window(), QPoint()), q->size()));
never executed: window->setGeometry(QRect(q->mapTo(q->window(), QPoint()), q->size()));
0
39 }-
40-
41 void updateUsesNativeWidgets()-
42 {-
43 if (usesNativeWidgets
usesNativeWidgetsDescription
TRUEnever evaluated
FALSEnever evaluated
|| window->parent() == 0
window->parent() == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
44 return;
never executed: return;
0
45 QWindowContainer * const q = q_func();-
46 if (q->internalWinId()
q->internalWinId()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
47-
48 usesNativeWidgets = true;-
49 return;
never executed: return;
0
50 }-
51 QWidget *p = q->parentWidget();-
52 while (p
pDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
53 if (-
54-
55 qobject_cast<QMdiSubWindow *>(p) != 0
qobject_cast<Q...dow *>(p) != 0Description
TRUEnever evaluated
FALSEnever evaluated
||
0
56-
57 qobject_cast<QAbstractScrollArea *>(p) != 0
qobject_cast<Q...rea *>(p) != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
58 q->winId();-
59 usesNativeWidgets = true;-
60 break;
never executed: break;
0
61 }-
62 p = p->parentWidget();-
63 }
never executed: end of block
0
64 }
never executed: end of block
0
65-
66 void markParentChain() {-
67 QWindowContainer * const q = q_func();-
68 QWidget *p = q;-
69 while (p
pDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
70 QWidgetPrivate *d = static_cast<QWidgetPrivate *>(QWidgetPrivate::get(p));-
71 d->createExtra();-
72 d->extra->hasWindowContainer = true;-
73 p = p->parentWidget();-
74 }
never executed: end of block
0
75 }
never executed: end of block
0
76-
77 bool isStillAnOrphan() const {-
78 return
never executed: return window->parent() == &fakeParent;
window->parent() == &fakeParent;
never executed: return window->parent() == &fakeParent;
0
79 }-
80-
81 QPointer<QWindow> window;-
82 QWindow *oldFocusWindow;-
83 QWindow fakeParent;-
84-
85 uint usesNativeWidgets : 1;-
86};-
87QWidget *QWidget::createWindowContainer(QWindow *window, QWidget *parent, Qt::WindowFlags flags)-
88{-
89 return
never executed: return new QWindowContainer(window, parent, flags);
new QWindowContainer(window, parent, flags);
never executed: return new QWindowContainer(window, parent, flags);
0
90}-
91-
92-
93-
94-
95-
96-
97-
98QWindowContainer::QWindowContainer(QWindow *embeddedWindow, QWidget *parent, Qt::WindowFlags flags)-
99 : QWidget(*new QWindowContainerPrivate, parent, flags)-
100{-
101 QWindowContainerPrivate * const d = d_func();-
102 if (__builtin_expect(!!(!embeddedWindow), false)
__builtin_expe...indow), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
103 QMessageLogger(__FILE__, 210, __PRETTY_FUNCTION__).warning("QWindowContainer: embedded window cannot be null");-
104 return;
never executed: return;
0
105 }-
106-
107-
108-
109 if (embeddedWindow->surfaceType() == QSurface::RasterSurface
embeddedWindow...:RasterSurfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
110 && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface)
QGuiApplicatio...sterGLSurface)Description
TRUEnever evaluated
FALSEnever evaluated
0
111 && !QApplication::testAttribute(Qt::AA_ForceRasterWidgets)
!QApplication:...RasterWidgets)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
112 embeddedWindow->setSurfaceType(QSurface::RasterGLSurface);
never executed: embeddedWindow->setSurfaceType(QSurface::RasterGLSurface);
0
113-
114 d->window = embeddedWindow;-
115 d->window->setParent(&d->fakeParent);-
116 setAcceptDrops(true);-
117-
118 connect(QGuiApplication::instance(), qFlagLocation("2""focusWindowChanged(QWindow*)" "\0" __FILE__ ":" "225"), this, qFlagLocation("1""focusWindowChanged(QWindow*)" "\0" __FILE__ ":" "225"));-
119}
never executed: end of block
0
120-
121QWindow *QWindowContainer::containedWindow() const-
122{-
123 const QWindowContainerPrivate * const d = d_func();-
124 return
never executed: return d->window;
d->window;
never executed: return d->window;
0
125}-
126-
127-
128-
129-
130-
131QWindowContainer::~QWindowContainer()-
132{-
133 QWindowContainerPrivate * const d = d_func();-
134 delete d->window;-
135}
never executed: end of block
0
136-
137-
138-
139-
140-
141-
142-
143void QWindowContainer::focusWindowChanged(QWindow *focusWindow)-
144{-
145 QWindowContainerPrivate * const d = d_func();-
146 d->oldFocusWindow = focusWindow;-
147 if (focusWindow == d->window
focusWindow == d->windowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
148 QWidget *widget = QApplication::focusWidget();-
149 if (widget
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
150 widget->clearFocus();
never executed: widget->clearFocus();
0
151 }
never executed: end of block
0
152}
never executed: end of block
0
153-
154-
155-
156-
157-
158bool QWindowContainer::event(QEvent *e)-
159{-
160 QWindowContainerPrivate * const d = d_func();-
161 if (!d->window
!d->windowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
162 return
never executed: return QWidget::event(e);
QWidget::event(e);
never executed: return QWidget::event(e);
0
163-
164 QEvent::Type type = e->type();-
165 switch (type) {-
166 case
never executed: case QEvent::ChildRemoved:
QEvent::ChildRemoved:
never executed: case QEvent::ChildRemoved:
{
0
167 QChildEvent *ce = static_cast<QChildEvent *>(e);-
168 if (ce->child() == d->window
ce->child() == d->windowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
169 d->window = 0;
never executed: d->window = 0;
0
170 break;
never executed: break;
0
171 }-
172-
173-
174 case
never executed: case QEvent::Resize:
QEvent::Resize:
never executed: case QEvent::Resize:
0
175 d->updateGeometry();-
176 break;
never executed: break;
0
177 case
never executed: case QEvent::Move:
QEvent::Move:
never executed: case QEvent::Move:
0
178 d->updateGeometry();-
179 break;
never executed: break;
0
180 case
never executed: case QEvent::PolishRequest:
QEvent::PolishRequest:
never executed: case QEvent::PolishRequest:
0
181 d->updateGeometry();-
182 break;
never executed: break;
0
183 case
never executed: case QEvent::Show:
QEvent::Show:
never executed: case QEvent::Show:
0
184 d->updateUsesNativeWidgets();-
185 if (d->isStillAnOrphan()
d->isStillAnOrphan()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
186 d->window->setParent(d->usesNativeWidgets-
187 ? windowHandle()-
188 : window()->windowHandle());-
189 }
never executed: end of block
0
190 if (d->window->parent()
d->window->parent()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
191 d->markParentChain();-
192 d->window->show();-
193 }
never executed: end of block
0
194 break;
never executed: break;
0
195 case
never executed: case QEvent::Hide:
QEvent::Hide:
never executed: case QEvent::Hide:
0
196 if (d->window->parent()
d->window->parent()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
197 d->window->hide();
never executed: d->window->hide();
0
198 break;
never executed: break;
0
199 case
never executed: case QEvent::FocusIn:
QEvent::FocusIn:
never executed: case QEvent::FocusIn:
0
200 if (d->window->parent()
d->window->parent()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
201 if (d->oldFocusWindow != d->window
d->oldFocusWindow != d->windowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
202 d->window->requestActivate();-
203 }
never executed: end of block
else {
0
204 QWidget *next = nextInFocusChain();-
205 next->setFocus();-
206 }
never executed: end of block
0
207 }-
208 break;
never executed: break;
0
209-
210 case
never executed: case QEvent::Drop:
QEvent::Drop:
never executed: case QEvent::Drop:
0
211 case
never executed: case QEvent::DragMove:
QEvent::DragMove:
never executed: case QEvent::DragMove:
0
212 case
never executed: case QEvent::DragLeave:
QEvent::DragLeave:
never executed: case QEvent::DragLeave:
0
213 QCoreApplication::sendEvent(d->window, e);-
214 return
never executed: return e->isAccepted();
e->isAccepted();
never executed: return e->isAccepted();
0
215 case
never executed: case QEvent::DragEnter:
QEvent::DragEnter:
never executed: case QEvent::DragEnter:
0
216-
217-
218 QCoreApplication::sendEvent(d->window, e);-
219 e->accept();-
220 return
never executed: return true;
true;
never executed: return true;
0
221-
222 default
never executed: default:
:
never executed: default:
0
223 break;
never executed: break;
0
224 }-
225-
226 return
never executed: return QWidget::event(e);
QWidget::event(e);
never executed: return QWidget::event(e);
0
227}-
228-
229typedef void (*qwindowcontainer_traverse_callback)(QWidget *parent);-
230static void qwindowcontainer_traverse(QWidget *parent, qwindowcontainer_traverse_callback callback)-
231{-
232 const QObjectList &children = parent->children();-
233 for (int i=0; i<children.size()
i<children.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
234 QWidget *w = qobject_cast<QWidget *>(children.at(i));-
235 if (w
wDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
236 QWidgetPrivate *wd = static_cast<QWidgetPrivate *>(QWidgetPrivate::get(w));-
237 if (wd->extra
wd->extraDescription
TRUEnever evaluated
FALSEnever evaluated
&& wd->extra->hasWindowContainer
wd->extra->hasWindowContainerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
238 callback(w);
never executed: callback(w);
0
239 }
never executed: end of block
0
240 }
never executed: end of block
0
241}
never executed: end of block
0
242-
243void QWindowContainer::toplevelAboutToBeDestroyed(QWidget *parent)-
244{-
245 if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)
QWindowContain...e::get(parent)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
246 d->window->setParent(&d->fakeParent);-
247 }
never executed: end of block
0
248 qwindowcontainer_traverse(parent, toplevelAboutToBeDestroyed);-
249}
never executed: end of block
0
250-
251void QWindowContainer::parentWasChanged(QWidget *parent)-
252{-
253 if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)
QWindowContain...e::get(parent)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
254 if (d->window->parent()
d->window->parent()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
255 d->updateUsesNativeWidgets();-
256 d->markParentChain();-
257 QWidget *toplevel = d->usesNativeWidgets
d->usesNativeWidgetsDescription
TRUEnever evaluated
FALSEnever evaluated
? parent : parent->window();
0
258 if (!toplevel->windowHandle()
!toplevel->windowHandle()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
259 QWidgetPrivate *tld = static_cast<QWidgetPrivate *>(QWidgetPrivate::get(toplevel));-
260 tld->createTLExtra();-
261 tld->createTLSysExtra();-
262 ((!(toplevel->windowHandle())) ? qt_assert("toplevel->windowHandle()",__FILE__,369) : qt_noop());-
263 }
never executed: end of block
0
264 d->window->setParent(toplevel->windowHandle());-
265 d->updateGeometry();-
266 }
never executed: end of block
0
267 }
never executed: end of block
0
268 qwindowcontainer_traverse(parent, parentWasChanged);-
269}
never executed: end of block
0
270-
271void QWindowContainer::parentWasMoved(QWidget *parent)-
272{-
273 if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)
QWindowContain...e::get(parent)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
274 if (d->window->parent()
d->window->parent()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
275 d->updateGeometry();
never executed: d->updateGeometry();
0
276 }
never executed: end of block
0
277 qwindowcontainer_traverse(parent, parentWasMoved);-
278}
never executed: end of block
0
279-
280void QWindowContainer::parentWasRaised(QWidget *parent)-
281{-
282 if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)
QWindowContain...e::get(parent)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
283 if (d->window->parent()
d->window->parent()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
284 d->window->raise();
never executed: d->window->raise();
0
285 }
never executed: end of block
0
286 qwindowcontainer_traverse(parent, parentWasRaised);-
287}
never executed: end of block
0
288-
289void QWindowContainer::parentWasLowered(QWidget *parent)-
290{-
291 if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)
QWindowContain...e::get(parent)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
292 if (d->window->parent()
d->window->parent()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
293 d->window->lower();
never executed: d->window->lower();
0
294 }
never executed: end of block
0
295 qwindowcontainer_traverse(parent, parentWasLowered);-
296}
never executed: end of block
0
297-
298-
299-
Switch to Source codePreprocessed file

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