summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-02-10 16:15:03 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-02-16 15:30:02 +0000
commit2b34aefcf02f09253473b096eb4faffd3e62b5f4 (patch)
treecf8a3ae12a21a3d550f27d4ad3c6279ec35af3c5 /src/widgets
parent46d060f588a2b90feb833c2bcf093e6964c02367 (diff)
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>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/kernel/qwidget.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index d35ad87c8d..dc55c2d5d9 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -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);