diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -902,15 +902,28 @@ return QPoint(); } - //if the item is in a dock or in a window that ignores WM we want to position the popups outside of the dock const KWindowInfo winInfo = KWindowSystem::windowInfo(item->window()->winId(), NET::WMWindowType); + + //if the item is in a panel/dock or in a window that ignores WM we want to position the popups outside of the dock. + // Tooltip windows can be ignored from the check because they should be allowed to be inside the main window const bool outsideParentWindow = ((winInfo.windowType(NET::AllTypesMask) == NET::Dock) || (item->window()->flags() & Qt::X11BypassWindowManagerHint)) - && item->window()->mask().isNull(); + && !flags().testFlag(Qt::ToolTip); QRect parentGeometryBounds; if (outsideParentWindow) { - parentGeometryBounds = item->window()->geometry(); + // [1] placement according to window + + //use the mask as boundary when it is available in order to not place window far from the window mask + // fixes also the !compositing case that plasma panels are not placing their popups correctly + if (!item->window()->mask().isNull()) { + QRect maskRect = item->window()->mask().boundingRect(); + maskRect.moveTopLeft(item->window()->mapToGlobal(maskRect.topLeft())); + parentGeometryBounds = maskRect; + } else { + parentGeometryBounds = item->window()->geometry(); + } } else { + // [2] placement according to item parentGeometryBounds = item->mapRectToScene(item->boundingRect()).toRect(); if (item->window()) { parentGeometryBounds.moveTopLeft(item->window()->mapToGlobal(parentGeometryBounds.topLeft()));