Prevent Qt::ForeignWindow from propagating into QWidget for non-toplevels

Qt::ForeignWindow implies Qt::Window, which QtWidgets interprets as a top
level window, but this is not the case on a QtGui level. A foreign window
can be a child window as well, so we have to make sure the QWindow state
is not propagated to QWidget, which would result in the QWidget becoming
top level.

Change-Id: Ie0c2d769ce92e6988a4d62da46f5fc2da74bdf08
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Tor Arne Vestbø 2017-01-31 13:40:46 +01:00
parent 0c6911e5cd
commit 7e98eb5f5f

View File

@ -1483,6 +1483,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
win->handle()->setFrameStrutEventsEnabled(true);
data.window_flags = win->flags();
if (!win->isTopLevel()) // In a Widget world foreign windows can only be top level
data.window_flags &= ~Qt::ForeignWindow;
if (!topData()->role.isNull())
QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1());