Fallback to focusWindow as transient parent

The wayland protocol requires Popup windows to have a transient parent
set, in order to correctly position the window on the screen.
In Qt, some popup menus don't have it, so they will appear misplaced in
the screen. This adds an heuristic which makes transientParent()
return the current application focus window, which is an approximation
which won't be always correct, but seems to fix most applications

Task-number: QTBUG-60932
Change-Id: Icec1e306d3f64f4f00ad735a8c2eedb99e85eabb
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
This commit is contained in:
Marco Martin 2017-07-25 14:40:41 +02:00 committed by Marco Martin
parent f41bd9c06e
commit 66af01b17f

View File

@ -720,6 +720,8 @@ QWaylandWindow *QWaylandWindow::transientParent() const
// events.
if (auto transientParent = window()->transientParent())
return static_cast<QWaylandWindow *>(topLevelWindow(transientParent)->handle());
else if (QGuiApplication::focusWindow() && (window()->type() == Qt::ToolTip || window()->type() == Qt::Popup))
return static_cast<QWaylandWindow *>(topLevelWindow(QGuiApplication::focusWindow())->handle());
return nullptr;
}