Fix popup menus with no parent windows
The QMenu API doesn't play well with Wayland. You can do: QMenu menu; menu.popup(someGlobalPos); which is completely broken on wayland. If some popup window doesn't have a transient parent use the current focus window for that. Fixes right-click popups in qdbusviewer and other apps. Change-Id: I3227f4ec27431ca8ec156971cbfdbf1e848a0527 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
This commit is contained in:
parent
b52533db83
commit
817633a831
@ -226,14 +226,21 @@ void QWaylandWindow::setGeometry(const QRect &rect)
|
||||
void QWaylandWindow::setVisible(bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
if (window()->type() == Qt::Popup && transientParent()) {
|
||||
if (window()->type() == Qt::Popup) {
|
||||
QWaylandWindow *parent = transientParent();
|
||||
mMouseDevice = parent->mMouseDevice;
|
||||
mMouseSerial = parent->mMouseSerial;
|
||||
if (!parent) {
|
||||
// Try with the current focus window. It may be the wrong one but we need to have
|
||||
// some parent to have popups act as popups.
|
||||
parent = mDisplay->currentInputDevice()->pointerFocus();
|
||||
}
|
||||
if (parent) {
|
||||
mMouseDevice = parent->mMouseDevice;
|
||||
mMouseSerial = parent->mMouseSerial;
|
||||
|
||||
QWaylandWlShellSurface *wlshellSurface = dynamic_cast<QWaylandWlShellSurface*>(mShellSurface);
|
||||
if (mMouseDevice && wlshellSurface) {
|
||||
wlshellSurface->setPopup(transientParent(), mMouseDevice, mMouseSerial);
|
||||
QWaylandWlShellSurface *wlshellSurface = dynamic_cast<QWaylandWlShellSurface*>(mShellSurface);
|
||||
if (mMouseDevice && wlshellSurface) {
|
||||
wlshellSurface->setPopup(parent, mMouseDevice, mMouseSerial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user