QtWidgets: Change QTLWExtra::window from QWindow to QWidgetWindow
Revert commit a1d4e4c9
: We’re now using QWidgetWindow
API from QWidget code.
Add QWidgetPrivate::windowHandle() which returns
a QWidgetWindow pointer. Use this function to remove
casts where QWidgetWindow API is used.
Change-Id: Ie66a69b5c0461f297996118dc907e1d7b3d78df5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
e3bdad13be
commit
f657dda888
@ -1415,7 +1415,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
|
||||
if (!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow())
|
||||
return; // we only care about real toplevels
|
||||
|
||||
QWindow *win = topData()->window;
|
||||
QWidgetWindow *win = topData()->window;
|
||||
// topData() ensures the extra is created but does not ensure 'window' is non-null
|
||||
// in case the extra was already valid.
|
||||
if (!win) {
|
||||
@ -1516,8 +1516,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
|
||||
q->setAttribute(Qt::WA_OutsideWSRange, true);
|
||||
} else if (q->isVisible()) {
|
||||
// If widget is already shown, set window visible, too
|
||||
QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(win);
|
||||
widgetWindow->setNativeWindowVisibility(true);
|
||||
win->setNativeWindowVisibility(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2640,11 +2639,7 @@ WId QWidget::effectiveWinId() const
|
||||
QWindow *QWidget::windowHandle() const
|
||||
{
|
||||
Q_D(const QWidget);
|
||||
QTLWExtra *extra = d->maybeTopData();
|
||||
if (extra)
|
||||
return extra->window;
|
||||
|
||||
return 0;
|
||||
return d->windowHandle();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_STYLE_STYLESHEET
|
||||
@ -7955,7 +7950,7 @@ void QWidgetPrivate::show_sys()
|
||||
{
|
||||
Q_Q(QWidget);
|
||||
|
||||
QWidgetWindow *window = qobject_cast<QWidgetWindow *>(q->windowHandle());
|
||||
QWidgetWindow *window = windowHandle();
|
||||
|
||||
if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
|
||||
invalidateBuffer(q->rect());
|
||||
@ -8094,7 +8089,7 @@ void QWidgetPrivate::hide_sys()
|
||||
{
|
||||
Q_Q(QWidget);
|
||||
|
||||
QWidgetWindow *window = qobject_cast<QWidgetWindow *>(q->windowHandle());
|
||||
QWidgetWindow *window = windowHandle();
|
||||
|
||||
if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
|
||||
q->setAttribute(Qt::WA_Mapped, false);
|
||||
|
@ -76,6 +76,7 @@ QT_BEGIN_NAMESPACE
|
||||
// Extra QWidget data
|
||||
// - to minimize memory usage for members that are seldom used.
|
||||
// - top-level widgets have extra extra data to reduce cost further
|
||||
class QWidgetWindow;
|
||||
class QPaintEngine;
|
||||
class QPixmap;
|
||||
class QWidgetBackingStore;
|
||||
@ -160,7 +161,7 @@ struct QTLWExtra {
|
||||
QWidgetBackingStoreTracker backingStoreTracker;
|
||||
QBackingStore *backingStore;
|
||||
QPainter *sharedPainter;
|
||||
QWindow *window;
|
||||
QWidgetWindow *window;
|
||||
QOpenGLContext *shareContext;
|
||||
|
||||
// Implicit pointers (shared_null).
|
||||
@ -338,6 +339,7 @@ public:
|
||||
QPainter *sharedPainter() const;
|
||||
void setSharedPainter(QPainter *painter);
|
||||
QWidgetBackingStore *maybeBackingStore() const;
|
||||
QWidgetWindow *windowHandle() const;
|
||||
void init(QWidget *desktopWidget, Qt::WindowFlags f);
|
||||
void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
|
||||
void createRecursively();
|
||||
@ -987,6 +989,13 @@ inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
|
||||
return x ? x->backingStoreTracker.data() : 0;
|
||||
}
|
||||
|
||||
inline QWidgetWindow *QWidgetPrivate::windowHandle() const
|
||||
{
|
||||
if (QTLWExtra *x = maybeTopData())
|
||||
return x->window;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWIDGET_P_H
|
||||
|
Loading…
Reference in New Issue
Block a user