Fix tooltips without a transient parent
QToolTip has the same problems as QMenu, that is you can create one without a parent and with a global position. Use the same trick and use the window that last received an input event as the parent. Change-Id: I093c8da0d54110903f35670b01dea6fa96abecf4 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
This commit is contained in:
parent
bc63ed702f
commit
837c740cd6
@ -128,7 +128,7 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
|
|||||||
if (window->type() != Qt::Popup) {
|
if (window->type() != Qt::Popup) {
|
||||||
mShellSurface->updateTransientParent(window->transientParent());
|
mShellSurface->updateTransientParent(window->transientParent());
|
||||||
}
|
}
|
||||||
} else if (mShellSurface) {
|
} else if (mShellSurface && window->type() != Qt::ToolTip) {
|
||||||
mShellSurface->setTopLevel();
|
mShellSurface->setTopLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,17 +240,18 @@ void QWaylandWindow::setGeometry(const QRect &rect)
|
|||||||
void QWaylandWindow::setVisible(bool visible)
|
void QWaylandWindow::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
if (visible) {
|
if (visible) {
|
||||||
if (window()->type() == Qt::Popup) {
|
if (mShellSurface) {
|
||||||
QWaylandWindow *parent = transientParent();
|
if (window()->type() == Qt::Popup) {
|
||||||
if (!parent) {
|
QWaylandWindow *parent = transientParent();
|
||||||
// Try with the current focus window. It should be the right one and anyway
|
if (parent) {
|
||||||
// better than having no parent at all.
|
QWaylandWlShellSurface *wlshellSurface = qobject_cast<QWaylandWlShellSurface*>(mShellSurface);
|
||||||
parent = mDisplay->lastInputWindow();
|
if (wlshellSurface)
|
||||||
}
|
wlshellSurface->setPopup(parent, mDisplay->lastInputDevice(), mDisplay->lastInputSerial());
|
||||||
if (parent) {
|
}
|
||||||
QWaylandWlShellSurface *wlshellSurface = qobject_cast<QWaylandWlShellSurface*>(mShellSurface);
|
} else if (window()->type() == Qt::ToolTip) {
|
||||||
if (wlshellSurface)
|
if (QWaylandWindow *parent = transientParent()) {
|
||||||
wlshellSurface->setPopup(parent, mDisplay->lastInputDevice(), mDisplay->lastInputSerial());
|
mShellSurface->updateTransientParent(parent->window());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,7 +610,9 @@ QWaylandWindow *QWaylandWindow::transientParent() const
|
|||||||
// events.
|
// events.
|
||||||
return static_cast<QWaylandWindow *>(topLevelWindow(window()->transientParent())->handle());
|
return static_cast<QWaylandWindow *>(topLevelWindow(window()->transientParent())->handle());
|
||||||
}
|
}
|
||||||
return 0;
|
// Try with the current focus window. It should be the right one and anyway
|
||||||
|
// better than having no parent at all.
|
||||||
|
return mDisplay->lastInputWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e)
|
void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e)
|
||||||
|
@ -159,8 +159,7 @@ void QWaylandWlShellSurface::updateTransientParent(QWindow *parent)
|
|||||||
|
|
||||||
// set_transient expects a position relative to the parent
|
// set_transient expects a position relative to the parent
|
||||||
QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
|
QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
|
||||||
QWindow *parentWin = m_window->window()->transientParent();
|
transientPos -= parent->geometry().topLeft();
|
||||||
transientPos -= parentWin->geometry().topLeft();
|
|
||||||
if (parent_wayland_window->decoration()) {
|
if (parent_wayland_window->decoration()) {
|
||||||
transientPos.setX(transientPos.x() + parent_wayland_window->decoration()->margins().left());
|
transientPos.setX(transientPos.x() + parent_wayland_window->decoration()->margins().left());
|
||||||
transientPos.setY(transientPos.y() + parent_wayland_window->decoration()->margins().top());
|
transientPos.setY(transientPos.y() + parent_wayland_window->decoration()->margins().top());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user