Lazily create QPlatformWindow for Qt::Desktop windows

QDesktopWidget only needs a QWindow to access its screen, and has no use
for the platform window. To keep old code working that may have called
winId() on the QDekstopWidget we still ensure it gets created lazily,
even if that will just create hidden fake windows on many platforms.

Change-Id: I2d05b96dfeebeaf3f1278cfef6301ef4cb855a57
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
This commit is contained in:
Tor Arne Vestbø 2017-02-10 16:15:03 +01:00
parent 46d060f588
commit 2b34aefcf0

View File

@ -1477,10 +1477,12 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
qt_window_private(win)->positionPolicy = topData()->posIncludesFrame ?
QWindowPrivate::WindowFrameInclusive : QWindowPrivate::WindowFrameExclusive;
win->create();
// Enable nonclient-area events for QDockWidget and other NonClientArea-mouse event processing.
if ((flags & Qt::Desktop) == Qt::Window)
if (q->windowType() != Qt::Desktop || q->testAttribute(Qt::WA_NativeWindow)) {
win->create();
// Enable nonclient-area events for QDockWidget and other NonClientArea-mouse event processing.
win->handle()->setFrameStrutEventsEnabled(true);
}
data.window_flags = win->flags();
if (!win->isTopLevel()) // In a Widget world foreign windows can only be top level
@ -1501,10 +1503,13 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
}
setWindowModified_helper();
WId id = win->winId();
// See the QPlatformWindow::winId() documentation
Q_ASSERT(id != WId(0));
setWinId(id);
if (win->handle()) {
WId id = win->winId();
// See the QPlatformWindow::winId() documentation
Q_ASSERT(id != WId(0));
setWinId(id);
}
// Check children and create windows for them if necessary
q_createNativeChildrenAndSetParent(q);