X11: Add support for robust z-order detection

Qt doesn't provide any way to know which window is directly
bellow the cursor. Generally this is fine since floating windows
are always on top of the main window. However, if Qt::Tool is removed,
then they can be behind, and KDDW can't know which window to overlay
the drop indicators onto.

This patch uses XLib's XQueryTree to solve this.
This is still experimental, hence disabled by default.

For now it's disabled by default, since it's experimental.
You can turn it on by passing -DKDDockWidgets_XLib=ON

Fixes bug #256
This commit is contained in:
Sergio Martins
2021-11-25 18:01:13 +00:00
parent e67f55af51
commit b20ce0895b
6 changed files with 129 additions and 1 deletions

View File

@@ -21,6 +21,7 @@
#include "WidgetResizeHandler_p.h"
#include "Config.h"
#include "MDILayoutWidget_p.h"
#include "WindowZOrder_x11_p.h"
#include <QMouseEvent>
#include <QGuiApplication>
@@ -879,6 +880,17 @@ WidgetType *DragController::qtTopLevelUnderCursor() const
}
}
#endif // Q_OS_WIN
} else if (linksToXLib() && isXCB()) {
bool ok = false;
const QVector<QWindow*> orderedWindows = KDDockWidgets::orderedWindows(ok);
FloatingWindow *tlwBeingDragged = m_windowBeingDragged->floatingWindow();
if (auto tl = qtTopLevelUnderCursor_impl(globalPos, orderedWindows, tlwBeingDragged))
return tl;
if (!ok) {
qCDebug(toplevels) << Q_FUNC_INFO << "No top-level found. Some windows weren't seen by XLib";
}
} else {
// !Windows: Linux, macOS, offscreen (offscreen on Windows too), etc.