diff options
author | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2015-01-18 15:53:46 +0200 |
---|---|---|
committer | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2015-02-11 13:47:12 +0000 |
commit | 6dff366179a40abd8327170d926cb535ad0ff14d (patch) | |
tree | 64f3c00cd0374b4eab89a7d962e7b969299cc620 | |
parent | dd69958792021e247da8caa7e9ecd503fd5e2540 (diff) |
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>
-rw-r--r-- | src/client/qwaylandwindow.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 965511528..13408b259 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -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); + } } } |