Commit caea7f76 authored by Jan Blackquill's avatar Jan Blackquill 🌈
Browse files

[applets/appmenu] Hide old menu before showing new menu

Summary:
Hiding the old menu after the new menu is shown isn't possible on Wayland:
```
qt.qpa.wayland: setGrabPopup called with a parent, QtWaylandClient::QWaylandXdgSurface(0x17dd550) which does not match the current topmost grabbing popup, QtWaylandClient::QWaylandXdgSurface(0x120d9f0) According to the xdg-shell protocol, this is not allowed. The wayland QPA plugin is currently handling it by setting the parent to the topmost grabbing popup. Note, however, that this may cause positioning errors and popups closing unxpectedly because xdg-shell mandate that child popups close before parents
```

Test Plan:
Before, Wayland: Trying to open a menu under Wayland while one is already open fails.
After, Wayland: Trying to open a menu under Wayland while one is already open succeeds.
Ensure no regressions on X11.

Reviewers: #plasma, #kwin, broulik

Reviewed By: #plasma, broulik

Subscribers: broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D29464
parent b9aba6eb
......@@ -210,11 +210,14 @@ void AppMenuApplet::trigger(QQuickItem *ctx, int idx)
actionMenu->winId();//create window handle
actionMenu->windowHandle()->setTransientParent(ctx->window());
actionMenu->popup(pos);
// hide the old menu only after showing the new one to avoid brief focus flickering on X11.
// on wayland, you can't have more than one grabbing popup at a time so we show it after
// the menu has hidden. thankfully, wayland doesn't have this flickering.
if (!KWindowSystem::isPlatformWayland()) {
actionMenu->popup(pos);
}
if (view() == FullView) {
// hide the old menu only after showing the new one to avoid brief flickering
// in other windows as they briefly re-gain focus
QMenu *oldMenu = m_currentMenu;
m_currentMenu = actionMenu;
if (oldMenu && oldMenu != actionMenu) {
......@@ -224,6 +227,10 @@ void AppMenuApplet::trigger(QQuickItem *ctx, int idx)
}
}
if (KWindowSystem::isPlatformWayland()) {
actionMenu->popup(pos);
}
setCurrentIndex(idx);
// FIXME TODO connect only once
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment